nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: googleapis/api-linter
Pull request #570 (2020-06-19 20:18:34)

fix: Permit `hour_of_day` and `day_of_week`.
It makes no sense to flag on this because we called the message `google.type.DayOfWeek`.


Patch:
diff --git a/rules/aip0140/prepositions.go b/rules/aip0140/prepositions.go
index 636b3fe..3b0dbd9 100644
--- a/rules/aip0140/prepositions.go
+++ b/rules/aip0140/prepositions.go
@@ -28,7 +28,7 @@ import (
 var noPrepositions = &lint.FieldRule{
 	Name: lint.NewRuleName(140, "prepositions"),
 	OnlyIf: func(f *desc.FieldDescriptor) bool {
-		return !stringset.New("order_by", "group_by").Contains(f.GetName())
+		return !stringset.New("order_by", "group_by", "hour_of_day", "day_of_week").Contains(f.GetName())
 	},
 	LintField: func(f *desc.FieldDescriptor) (problems []lint.Problem) {
 		for _, word := range strings.Split(f.GetName(), "_") {


Test patch:
diff --git a/rules/aip0140/prepositions_test.go b/rules/aip0140/prepositions_test.go
index b86a4bf..189af14 100644
--- a/rules/aip0140/prepositions_test.go
+++ b/rules/aip0140/prepositions_test.go
@@ -30,6 +30,8 @@ func TestNoPrepositions(t *testing.T) {
 		{"move_toward_shelf_at_front", testutils.Problems{{Message: "toward"}, {Message: "at"}}},
 		{"order_by", testutils.Problems{}},
 		{"group_by", testutils.Problems{}},
+		{"hour_of_day", testutils.Problems{}},
+		{"day_of_week", testutils.Problems{}},
 	}
 	for _, test := range tests {
 		t.Run(test.Name, func(t *testing.T) {
Repository: googleapis/api-linter
Pull request #591 (2020-08-14 17:36:30)

fix: Do not flag "created" or "updated" on unexpected types.


Patch:
diff --git a/rules/aip0142/time_field_names.go b/rules/aip0142/time_field_names.go
index 5a87ed0..218fe13 100644
--- a/rules/aip0142/time_field_names.go
+++ b/rules/aip0142/time_field_names.go
@@ -17,6 +17,7 @@ package aip0142
 import (
 	"strings"
 
+	"bitbucket.org/creachadair/stringset"
 	"github.com/googleapis/api-linter/lint"
 	"github.com/googleapis/api-linter/locations"
 	"github.com/googleapis/api-linter/rules/internal/utils"
@@ -25,6 +26,9 @@ import (
 
 var fieldNames = &lint.FieldRule{
 	Name: lint.NewRuleName(142, "time-field-names"),
+	OnlyIf: func(f *desc.FieldDescriptor) bool {
+		return stringset.New("google.protobuf.Timestamp", "int32", "int64", "string").Contains(utils.GetTypeName(f))
+	},
 	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
 		// Look for common non-imperative terms.
 		mistakes := map[string]string{


Test patch:
diff --git a/rules/aip0142/time_field_names_test.go b/rules/aip0142/time_field_names_test.go
index c1cf7d9..d73658d 100644
--- a/rules/aip0142/time_field_names_test.go
+++ b/rules/aip0142/time_field_names_test.go
@@ -35,6 +35,7 @@ func TestFieldName(t *testing.T) {
 		{"ValidSuffixRepeated", "repeated google.protobuf.Timestamp", "sample_time", testutils.Problems{}},
 		{"InvalidNoSuffixRepeated", "repeated google.protobuf.Timestamp", "create", testutils.Problems{{Message: "should end"}}},
 		{"InvalidIsTypeMistake", "int32", "created", testutils.Problems{{Suggestion: "create_time"}}},
+		{"IrrelevantWeirdType", "bytes", "created", nil},
 	}
 	for _, test := range tests {
 		t.Run(test.testName, func(t *testing.T) {
Repository: googleapis/api-linter
Pull request #610 (2020-08-26 13:10:45)

Fix typos in AIP-231's http_uri_suffix rule


Patch:
diff --git a/rules/aip0231/http_uri_suffix.go b/rules/aip0231/http_uri_suffix.go
index 36e4ba3..972e84b 100644
--- a/rules/aip0231/http_uri_suffix.go
+++ b/rules/aip0231/http_uri_suffix.go
@@ -29,7 +29,7 @@ var uriSuffix = &lint.MethodRule{
 		for _, httpRule := range utils.GetHTTPRules(m) {
 			if !batchGetURINameRegexp.MatchString(httpRule.URI) {
 				return []lint.Problem{{
-					Message:    `Get methods URI should be end with ":batchGet".`,
+					Message:    `Batch Get method's URI should end with ":batchGet".`,
 					Descriptor: m,
 				}}
 			}


Test patch:
diff --git a/rules/aip0231/http_uri_suffix_test.go b/rules/aip0231/http_uri_suffix_test.go
index 9568c41..6f2256c 100644
--- a/rules/aip0231/http_uri_suffix_test.go
+++ b/rules/aip0231/http_uri_suffix_test.go
@@ -32,7 +32,7 @@ func TestHttpUrl(t *testing.T) {
 		problems   testutils.Problems
 	}{
 		{"Valid", "/v1/{parent=publishers/*}/books:batchGet", "BatchGetBooks", nil},
-		{"InvalidVarName", "/v1/{parent=publishers/*}/books", "BatchGetBooks", testutils.Problems{{Message: `Get methods URI should be end with ":batchGet".`}}},
+		{"InvalidVarName", "/v1/{parent=publishers/*}/books", "BatchGetBooks", testutils.Problems{{Message: `Batch Get method's URI should end with ":batchGet".`}}},
 		{"Irrelevant", "/v1/{book=publishers/*/books/*}", "AcquireBook", nil},
 	}
Repository: googleapis/api-linter
Pull request #624 (2020-09-16 17:01:23)

fix: Handle nested URI parameters correctly for custom method URI suffixes.


Patch:
diff --git a/rules/aip0136/http_uri_suffix.go b/rules/aip0136/http_uri_suffix.go
index fb28bd2..f789eea 100644
--- a/rules/aip0136/http_uri_suffix.go
+++ b/rules/aip0136/http_uri_suffix.go
@@ -54,9 +54,14 @@ var uriSuffix = &lint.MethodRule{
 			if strings.Contains(httpRule.URI, ":batch") {
 				rpcSlice := strings.Split(strcase.SnakeCase(m.GetName()), "_")
 				want = ":" + strcase.LowerCamelCase(rpcSlice[0]+"_"+rpcSlice[1])
-			} else if strings.Contains(httpRule.URI, "{name=") || strings.Contains(httpRule.URI, "{parent=") {
-				rpcSlice := strings.Split(strcase.SnakeCase(m.GetName()), "_")
-				want = ":" + rpcSlice[0]
+			} else {
+				for key := range httpRule.GetVariables() {
+					if key == "name" || key == "parent" || strings.HasSuffix(key, ".name") {
+						rpcSlice := strings.Split(strcase.SnakeCase(m.GetName()), "_")
+						want = ":" + rpcSlice[0]
+						break
+					}
+				}
 			}
 
 			// AIP-162 introduces some special cases around revisions, where


Test patch:
diff --git a/rules/aip0136/http_uri_suffix_test.go b/rules/aip0136/http_uri_suffix_test.go
index ec92ca6..6285ae5 100644
--- a/rules/aip0136/http_uri_suffix_test.go
+++ b/rules/aip0136/http_uri_suffix_test.go
@@ -28,6 +28,7 @@ func TestURISuffix(t *testing.T) {
 		problems   testutils.Problems
 	}{
 		{"ValidVerb", "ArchiveBook", "/v1/{name=publishers/*/books}:archive", testutils.Problems{}},
+		{"ValidVerbNested", "ArchiveBook", "/v1/{book.name=publishers/*/books}:archive", testutils.Problems{}},
 		{"ValidVerbParent", "ImportBooks", "/v1/{parent=publishers/*}/books:import", testutils.Problems{}},
 		{"ValidVerbParentBatchGet", "BatchGetBooks", "/v1/{parent=publishers/*}/books:batchGet", testutils.Problems{}},
 		{"InvalidVerb", "ArchiveBook", "/v1/{name=publishers/*/books}:archiveBook", testutils.Problems{{Message: ":archive"}}},
Repository: googleapis/api-linter
Pull request #653 (2020-10-08 22:35:00)

fix: Permit ListRevisions methods to include their resource field.


Patch:
diff --git a/rules/aip0132/response_unknown_fields.go b/rules/aip0132/response_unknown_fields.go
index 51fd1ba..d617f73 100644
--- a/rules/aip0132/response_unknown_fields.go
+++ b/rules/aip0132/response_unknown_fields.go
@@ -15,8 +15,11 @@
 package aip0132
 
 import (
+	"strings"
+
 	"bitbucket.org/creachadair/stringset"
 	"github.com/googleapis/api-linter/lint"
+	"github.com/googleapis/api-linter/rules/internal/utils"
 	"github.com/jhump/protoreflect/desc"
 	"github.com/stoewer/go-strcase"
 )
@@ -37,7 +40,15 @@ var responseUnknownFields = &lint.FieldRule{
 	},
 	LintField: func(f *desc.FieldDescriptor) []lint.Problem {
 		// A repeated variant of the resource should be permitted.
-		resource := strcase.SnakeCase(listRespMessageRegexp.FindStringSubmatch(f.GetOwner().GetName())[1])
+		msgName := f.GetOwner().GetName()
+		resource := strcase.SnakeCase(listRespMessageRegexp.FindStringSubmatch(msgName)[1])
+		if strings.HasSuffix(resource, "_revisions") {
+			// This is an AIP-162 ListFooRevisions response, which is subtly
+			// different from an AIP-132 List response. We need to modify the RPC
+			// name to what the AIP-132 List response would be in order to permit
+			// the resource field properly.
+			resource = utils.ToPlural(strings.TrimSuffix(resource, "_revisions"))
+		}
 		if f.GetName() == resource {
 			return nil
 		}


Test patch:
diff --git a/rules/aip0132/response_unknown_fields_test.go b/rules/aip0132/response_unknown_fields_test.go
index 6c00da9..6ec76f7 100644
--- a/rules/aip0132/response_unknown_fields_test.go
+++ b/rules/aip0132/response_unknown_fields_test.go
@@ -23,17 +23,19 @@ import (
 
 func TestResponseUnknownFields(t *testing.T) {
 	for _, test := range []struct {
-		FieldName string
-		problems  testutils.Problems
+		MessageName string
+		FieldName   string
+		problems    testutils.Problems
 	}{
-		{"total_size", testutils.Problems{}},
-		{"unreachable", testutils.Problems{}},
-		{"unreachable_locations", testutils.Problems{}},
-		{"extra", testutils.Problems{{Message: "List responses"}}},
+		{"ListBooksResponse", "total_size", nil},
+		{"ListBooksResponse", "unreachable", nil},
+		{"ListBooksResponse", "unreachable_locations", nil},
+		{"ListBookRevisionsResponse", "total_size", nil},
+		{"ListBooksResponse", "extra", testutils.Problems{{Message: "List responses"}}},
 	} {
 		t.Run(strcase.UpperCamelCase(test.FieldName), func(t *testing.T) {
 			f := testutils.ParseProto3Tmpl(t, `
-				message ListBooksResponse {
+				message {{.MessageName}} {
 					repeated Book books = 1;
 					string next_page_token = 2;
 					string {{.FieldName}} = 3;