From 14856ea917431ca8fe55d712807265f0d93409c5 Mon Sep 17 00:00:00 2001 From: bufdev <4228796+bufdev@users.noreply.github.com> Date: Fri, 13 Sep 2024 18:11:30 -0400 Subject: [PATCH] Cleanup (#88) --- .github/CODEOWNERS | 2 - .github/workflows/ci.yaml | 33 +++----- .github/workflows/release.yaml | 2 +- .gitignore | 2 + .golangci.yml | 21 ++++-- Makefile | 64 ++++++++++++++++ go.mod | 38 ++++++---- go.sum | 75 +++++++++++-------- .../cmd}/quality-checker/main.go | 2 +- .../cmd}/quality-checker/rule_documented.go | 0 .../cmd}/quality-checker/rule_name.go | 0 .../cmd}/quality-checker/rule_registered.go | 0 lint/rule_enabled.go | 12 +-- lint/rule_enabled_test.go | 1 - locations/descriptor_locations_test.go | 2 +- locations/field_locations_test.go | 8 +- locations/file_locations_test.go | 4 +- locations/message_locations_test.go | 2 +- locations/method_locations_test.go | 10 +-- rules/aep0004/path_never_optional_test.go | 2 +- rules/aep0004/resource_annotation_test.go | 6 +- .../resource_definition_pattern_test.go | 2 +- .../resource_definition_variables_test.go | 2 +- ...resource_name_components_alternate_test.go | 2 +- rules/aep0004/resource_pattern_test.go | 2 +- rules/aep0004/resource_variables_test.go | 2 +- rules/aep0122/kebab_case_uris_test.go | 2 +- rules/aep0122/no_self_links_test.go | 2 +- rules/aep0122/path_suffix_test.go | 2 +- .../resource_collection_identifiers_test.go | 2 +- rules/aep0122/resource_id_output_only.go | 2 +- rules/aep0122/resource_id_output_only_test.go | 2 +- rules/aep0122/resource_reference_type_test.go | 2 +- rules/aep0126/unspecified_test.go | 4 +- rules/aep0127/http_annotation_test.go | 2 +- rules/aep0127/http_template_pattern_test.go | 4 +- .../aep0127/resource_path_extraction_test.go | 2 +- rules/aep0127/uri_leading_slash_test.go | 2 +- rules/aep0131/method_signature_test.go | 2 +- rules/aep0131/request_message_name_test.go | 2 +- rules/aep0131/request_path_behavior_test.go | 2 +- rules/aep0131/request_path_reference_test.go | 4 +- rules/aep0131/request_required_fields_test.go | 2 +- rules/aep0131/request_unknown_fields_test.go | 2 +- rules/aep0131/synonyms_test.go | 2 +- rules/aep0132/method_signature_test.go | 4 +- rules/aep0132/request_message_name_test.go | 2 +- rules/aep0132/request_parent_behavior_test.go | 2 +- rules/aep0132/request_parent_field_test.go | 2 +- .../aep0132/request_parent_reference_test.go | 4 +- rules/aep0132/request_parent_required_test.go | 4 +- .../aep0132/request_parent_valid_reference.go | 2 +- .../request_parent_valid_reference_test.go | 2 +- rules/aep0132/request_required_fields_test.go | 2 +- rules/aep0132/request_unknown_fields_test.go | 2 +- rules/aep0132/response_unknown_fields_test.go | 2 +- rules/aep0133/method_signature_test.go | 4 +- rules/aep0133/request_id_field_test.go | 2 +- rules/aep0133/request_message_name_test.go | 2 +- rules/aep0133/request_parent_behavior_test.go | 2 +- rules/aep0133/request_parent_field_test.go | 2 +- rules/aep0133/request_parent_required_test.go | 4 +- rules/aep0133/request_required_fields_test.go | 2 +- .../aep0133/request_resource_behavior_test.go | 2 +- rules/aep0133/request_resource_field_test.go | 2 +- rules/aep0133/request_unknown_fields_test.go | 2 +- rules/aep0133/response_message_name_test.go | 2 +- rules/aep0133/synonyms_test.go | 2 +- rules/aep0134/method_signature_test.go | 2 +- rules/aep0134/request_mask_required_test.go | 2 +- rules/aep0134/request_message_name_test.go | 2 +- rules/aep0134/request_required_fields_test.go | 2 +- rules/aep0134/request_resource_field_test.go | 2 +- .../aep0134/request_resource_required_test.go | 2 +- rules/aep0134/request_unknown_fields_test.go | 2 +- rules/aep0134/response_lro_test.go | 2 +- rules/aep0134/response_message_name_test.go | 2 +- rules/aep0134/synonyms_test.go | 2 +- rules/aep0135/method_signature_test.go | 2 +- rules/aep0135/request_message_name_test.go | 2 +- rules/aep0135/request_path_behavior_test.go | 2 +- rules/aep0135/request_path_reference_test.go | 4 +- rules/aep0135/request_required_fields_test.go | 2 +- rules/aep0135/request_unknown_fields_test.go | 2 +- rules/aep0135/response_lro_test.go | 2 +- rules/aep0135/response_message_name_test.go | 2 +- .../declarative_standard_methods_only_test.go | 2 +- rules/aep0136/http_body_test.go | 2 +- rules/aep0136/http_method_test.go | 2 +- rules/aep0136/prepositions_test.go | 2 +- rules/aep0136/verb_noun_test.go | 2 +- rules/aep0141/count_suffix_test.go | 2 +- rules/aep0141/forbidden_types_test.go | 2 +- rules/aep0142/time_field_names_test.go | 2 +- rules/aep0142/time_field_type_test.go | 2 +- rules/aep0148/human_names_test.go | 2 +- rules/aep0148/ip_address_format_test.go | 2 +- rules/aep0148/uid_format_test.go | 2 +- rules/aep0151/lro_metadata_reachable_test.go | 4 +- rules/aep0151/lro_metadata_type_test.go | 2 +- rules/aep0151/lro_response_type_test.go | 2 +- rules/aep0151/operation_info_test.go | 4 +- rules/aep0151/response_unary_test.go | 2 +- rules/aep0155/request_id_type.go | 6 +- rules/aep0155/request_id_type_test.go | 10 +-- rules/aep0156/forbidden_methods_test.go | 2 +- .../response_next_page_token_field_test.go | 2 +- rules/aep0158/response_repeated_field.go | 4 +- rules/aep0158/response_repeated_field_test.go | 2 +- rules/aep0158/response_unary_test.go | 2 +- rules/aep0159/hardcoded_hyphen_test.go | 2 +- rules/aep0164/http_uri_suffix_test.go | 2 +- rules/aep0164/request_message_name_test.go | 2 +- rules/aep0164/request_name_behavior_test.go | 2 +- rules/aep0164/request_name_reference_test.go | 4 +- rules/aep0164/request_unknown_fields_test.go | 2 +- rules/aep0164/response_lro_test.go | 2 +- rules/aep0164/response_message_name_test.go | 2 +- rules/aep0191/file_layout_test.go | 4 +- rules/aep0191/filenames_test.go | 2 +- rules/aep0191/proto_version_test.go | 2 +- rules/aep0192/absolute_links_test.go | 2 +- rules/aep0192/no_html_test.go | 2 +- rules/aep0192/no_markdown_headings_test.go | 2 +- rules/aep0192/no_markdown_tables_test.go | 2 +- rules/aep0192/only_leading_comments_test.go | 2 +- rules/aep0216/nesting.go | 2 +- rules/aep0216/nesting_test.go | 4 +- rules/aep0216/state_field_output_only.go | 2 +- rules/aep0216/state_field_output_only_test.go | 2 +- rules/aep0216/synonyms.go | 2 +- rules/aep0216/synonyms_test.go | 2 +- rules/aep0216/value_synonyms.go | 2 +- rules/aep0216/value_synonyms_test.go | 2 +- rules/internal/utils/casing.go | 1 - rules/internal/utils/extension_test.go | 4 +- rules/internal/utils/http.go | 4 +- rules/internal/utils/http_test.go | 4 +- 138 files changed, 322 insertions(+), 245 deletions(-) delete mode 100644 .github/CODEOWNERS create mode 100644 Makefile rename {.github => internal/cmd}/quality-checker/main.go (98%) rename {.github => internal/cmd}/quality-checker/rule_documented.go (100%) rename {.github => internal/cmd}/quality-checker/rule_name.go (100%) rename {.github => internal/cmd}/quality-checker/rule_registered.go (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 05d3a95..0000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# The API linter team owns this respository. -* @googleapis/api-linter diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9a7b67f..1eb32ac 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,31 +5,16 @@ on: branches: - main jobs: - unit-tests: + ci: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + - name: Checkout Code + uses: actions/checkout@v4 with: - go-version: "1.20" - - run: go test -p 1 ./... - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: "1.20" - - name: staticcheck - uses: dominikh/staticcheck-action@v1.3.0 - with: - version: "2022.1.1" - quality-checker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 + fetch-depth: 1 + - name: Install Go + uses: actions/setup-go@v5 with: - go-version: "1.20" - - name: Run the quality checker (which catches obvious mistakes, missing docs, etc.) - run: go run ./.github/quality-checker + go-version: 1.23.x + - name: Make + run: make all diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fbe0737..684d562 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version-file: 'go.mod' + go-version: 1.23.x # The API linter does not use these, but we need them to build the # binaries. # diff --git a/.gitignore b/.gitignore index 8c79f56..6036ee6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ docs/.jekyll-metadata # Ruby .ruby-version + +/.tmp/ diff --git a/.golangci.yml b/.golangci.yml index 0552b55..771f451 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,16 @@ ---- -linters: - enable: - - goimports - - misspell +linters-settings: + errcheck: + check-type-assertions: true + forbidigo: + forbid: + - '^fmt\.Print' + - '^log\.' + - '^print$' + - '^println$' + - '^panic$' +issues: + exclude-dirs-use-default: false + exclude-rules: + - linters: + - staticcheck + text: 'SA1019: "github.com/jhump/protoreflect/desc' diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fb606d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# See https://tech.davis-hansson.com/p/make/ +SHELL := bash +.DELETE_ON_ERROR: +.SHELLFLAGS := -eu -o pipefail -c +.DEFAULT_GOAL := all +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules +MAKEFLAGS += --no-print-directory +BIN := .tmp/bin +export PATH := $(abspath $(BIN)):$(PATH) +export GOBIN := $(abspath $(BIN)) + +GO_MOD_GOTOOLCHAIN := go1.23.1 +GOLANGCI_LINT_VERSION := v1.60.3 +# https://github.com/golangci/golangci-lint/issues/4837 +GOLANGCI_LINT_GOTOOLCHAIN := $(GO_MOD_GOTOOLCHAIN) +# If any pins to specific dependency versions are needed, add them here +GO_GET_PKGS := + +.PHONY: help +help: ## Describe useful make targets + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-30s %s\n", $$1, $$2}' + +.PHONY: all +all: ## Build, test, and lint (default) + $(MAKE) test + $(MAKE) lint + +.PHONY: clean +clean: ## Delete intermediate build artifacts + @# -X only removes untracked files, -d recurses into directories, -f actually removes files/dirs + git clean -Xdf + +.PHONY: test +test: build ## Run unit tests + go test -vet=off -race -cover ./... + +.PHONY: build +build: ## Build all packages + go build ./... + +.PHONY: install +install: ## Install all binaries + go install ./... + +.PHONY: lint +lint: $(BIN)/golangci-lint ## Lint + go vet ./... + GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) golangci-lint run --modules-download-mode=readonly --timeout=3m0s + go run ./internal/cmd/quality-checker + +.PHONY: lintfix +lintfix: $(BIN)/golangci-lint ## Automatically fix some lint errors + GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) golangci-lint run --fix --modules-download-mode=readonly --timeout=3m0s + +.PHONY: upgrade +upgrade: ## Upgrade dependencies + go mod edit -toolchain=$(GO_MOD_GOTOOLCHAIN) + go get -u -t ./... $(GO_GET_PKGS) + go mod tidy -v + +$(BIN)/golangci-lint: Makefile + @mkdir -p $(@D) + GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) diff --git a/go.mod b/go.mod index 8545183..e0d7f9c 100644 --- a/go.mod +++ b/go.mod @@ -1,34 +1,40 @@ module github.com/aep-dev/api-linter -go 1.20 +go 1.21 + +toolchain go1.23.1 require ( - bitbucket.org/creachadair/stringset v0.0.12 - buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2 - cloud.google.com/go/longrunning v0.5.6 + bitbucket.org/creachadair/stringset v0.0.14 + buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240717204542-6b47820e6610.2 + cloud.google.com/go/longrunning v0.6.1 github.com/bmatcuk/doublestar/v4 v4.6.1 github.com/gertd/go-pluralize v0.2.1 github.com/google/go-cmp v0.6.0 - github.com/jhump/protoreflect v1.15.6 + github.com/jhump/protoreflect v1.17.0 github.com/lithammer/dedent v1.1.0 github.com/olekukonko/tablewriter v0.0.5 github.com/spf13/pflag v1.0.5 github.com/stoewer/go-strcase v1.3.0 - google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 - google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa + google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 + google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 google.golang.org/protobuf v1.34.2 gopkg.in/yaml.v2 v2.4.0 ) require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2 // indirect - github.com/bufbuild/protocompile v0.8.0 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 // indirect + github.com/bufbuild/protocompile v0.14.1 // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/mattn/go-runewidth v0.0.9 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect - google.golang.org/grpc v1.62.1 // indirect + github.com/kr/pretty v0.1.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/grpc v1.66.2 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect ) diff --git a/go.sum b/go.sum index 7bd0d5a..2f37e10 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,16 @@ -bitbucket.org/creachadair/stringset v0.0.12 h1:APD8dIoAzGv70a6p1oasPDjPwkp+ajszdgKyWUcNqo0= -bitbucket.org/creachadair/stringset v0.0.12/go.mod h1:KtNk2s0hRO1T0r78lv9Zq/S/Lp0du2zI0Fj5j5Y4LDo= -buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2 h1:0Ka0tKxAfSnJm9sVa7RVtnkTZ8DeTjuNhfHdk0ruLZ8= -buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240329195937-b433450cc52f.2/go.mod h1:7GnupzUM4BaoyPcUUTZZwrcVZvCBNcyn6iR/kddRTuU= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2 h1:Vs037OPnb+uCAQrDAxeGOM8UWvIBhET3hx+ZePssyrQ= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240221180331-f05a6f4403ce.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= -cloud.google.com/go/longrunning v0.5.6 h1:xAe8+0YaWoCKr9t1+aWe+OeQgN/iJK1fEgZSXmjuEaE= -cloud.google.com/go/longrunning v0.5.6/go.mod h1:vUaDrWYOMKRuhiv6JBnn49YxCPz2Ayn9GqyjaBT8/mA= +bitbucket.org/creachadair/stringset v0.0.14 h1:t1ejQyf8utS4GZV/4fM+1gvYucggZkfhb+tMobDxYOE= +bitbucket.org/creachadair/stringset v0.0.14/go.mod h1:Ej8fsr6rQvmeMDf6CCWMWGb14H9mz8kmDgPPTdiVT0w= +buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240717204542-6b47820e6610.2 h1:BweVF7lr8aI/rVFwYhrieMYXEKWfALRIAygphjVTJOg= +buf.build/gen/go/aep/api/protocolbuffers/go v1.34.2-20240717204542-6b47820e6610.2/go.mod h1:7GnupzUM4BaoyPcUUTZZwrcVZvCBNcyn6iR/kddRTuU= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2 h1:SZRVx928rbYZ6hEKUIN+vtGDkl7uotABRWGY4OAg5gM= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.34.2-20240717164558-a6c49f84cc0f.2/go.mod h1:ylS4c28ACSI59oJrOdW4pHS4n0Hw4TgSPHn8rpHl4Yw= +cloud.google.com/go/longrunning v0.6.1 h1:lOLTFxYpr8hcRtcwWir5ITh1PAKUD/sG2lKrTSYjyMc= +cloud.google.com/go/longrunning v0.6.1/go.mod h1:nHISoOZpBcmlwbJmiVk5oDRz0qG/ZxPynEGs1iZ79s0= github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s= -github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94= +github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw= +github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -19,16 +20,26 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/jhump/protoreflect v1.15.6 h1:WMYJbw2Wo+KOWwZFvgY0jMoVHM6i4XIvRs2RcBj5VmI= -github.com/jhump/protoreflect v1.15.6/go.mod h1:jCHoyYQIJnaabEYnbGwyo9hUqfyUMTbJw/tAut5t97E= +github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= +github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= @@ -39,27 +50,29 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s= -google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7/go.mod h1:/3XmxOjePkvmKrHuBy4zNFw7IzxJXtAgdpXi8Ll990U= -google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa h1:Jt1XW5PaLXF1/ePZrznsh/aAUvI7Adfc3LY1dAKlzRs= -google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:K4kfzHtI0kqWA79gecJarFtDn/Mls+GxQcg3Zox91Ac= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1 h1:BulPr26Jqjnd4eYDVe+YvyR7Yc2vJGkO5/0UxD0/jZU= +google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:hL97c3SYopEHblzpxRL4lSs523++l8DYxGM1FQiYmb4= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/.github/quality-checker/main.go b/internal/cmd/quality-checker/main.go similarity index 98% rename from .github/quality-checker/main.go rename to internal/cmd/quality-checker/main.go index 17a3e06..bcb0dc6 100644 --- a/.github/quality-checker/main.go +++ b/internal/cmd/quality-checker/main.go @@ -101,7 +101,7 @@ func main() { // If we got complaints, complain about them. if len(errors) > 0 { for _, e := range errors { - log.Println(fmt.Sprintf("ERROR: %s", e.Error())) + log.Printf("ERROR: %s", e.Error()) } } diff --git a/.github/quality-checker/rule_documented.go b/internal/cmd/quality-checker/rule_documented.go similarity index 100% rename from .github/quality-checker/rule_documented.go rename to internal/cmd/quality-checker/rule_documented.go diff --git a/.github/quality-checker/rule_name.go b/internal/cmd/quality-checker/rule_name.go similarity index 100% rename from .github/quality-checker/rule_name.go rename to internal/cmd/quality-checker/rule_name.go diff --git a/.github/quality-checker/rule_registered.go b/internal/cmd/quality-checker/rule_registered.go similarity index 100% rename from .github/quality-checker/rule_registered.go rename to internal/cmd/quality-checker/rule_registered.go diff --git a/lint/rule_enabled.go b/lint/rule_enabled.go index 46c1846..d6a2e0c 100644 --- a/lint/rule_enabled.go +++ b/lint/rule_enabled.go @@ -67,8 +67,8 @@ var descriptorDisableChecks = []func(d desc.Descriptor) bool{ // augment the set of commentLines. func ruleIsEnabled(rule ProtoRule, d desc.Descriptor, l *dpb.SourceCodeInfo_Location, aliasMap map[string]string, ignoreCommentDisables bool) bool { - if(rule.GetRuleType() == MustRule) { - return true; + if rule.GetRuleType() == MustRule { + return true } // If the rule is disabled because of something on the descriptor itself @@ -134,7 +134,7 @@ func ruleIsDisabledByComments(rule ProtoRule, d desc.Descriptor, l *dpb.SourceCo } func NewRuleType(rt RuleType) *RuleType { - p := new(RuleType); - *p = rt; - return p; -} \ No newline at end of file + p := new(RuleType) + *p = rt + return p +} diff --git a/lint/rule_enabled_test.go b/lint/rule_enabled_test.go index d092742..bca4950 100644 --- a/lint/rule_enabled_test.go +++ b/lint/rule_enabled_test.go @@ -32,7 +32,6 @@ func TestRuleIsEnabled(t *testing.T) { }, } - mustRule := &FileRule{ Name: RuleName("a::b::c"), LintFile: func(fd *desc.FileDescriptor) []Problem { diff --git a/locations/descriptor_locations_test.go b/locations/descriptor_locations_test.go index 7b4a4e7..505e3c5 100644 --- a/locations/descriptor_locations_test.go +++ b/locations/descriptor_locations_test.go @@ -41,7 +41,7 @@ func TestDescriptorName(t *testing.T) { for _, test := range tests { t.Run(test.testName, func(t *testing.T) { if diff := cmp.Diff(DescriptorName(test.d).Span, test.wantSpan); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/locations/field_locations_test.go b/locations/field_locations_test.go index 5bb7c7b..c97af12 100644 --- a/locations/field_locations_test.go +++ b/locations/field_locations_test.go @@ -42,7 +42,7 @@ func TestFieldLocations(t *testing.T) { t.Run(test.name, func(t *testing.T) { l := FieldType(test.field) if diff := cmp.Diff(l.GetSpan(), test.span); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -66,7 +66,7 @@ func TestFieldLabel(t *testing.T) { t.Run(test.name, func(t *testing.T) { l := FieldLabel(test.field) if diff := cmp.Diff(l.GetSpan(), test.span); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -84,7 +84,7 @@ func TestFieldResourceReference(t *testing.T) { loc := FieldResourceReference(f.GetMessageTypes()[0].GetFields()[0]) // resource_reference annotation location is roughly line 4, column 19. if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -99,6 +99,6 @@ func TestFieldOption(t *testing.T) { `) loc := FieldOption(f.GetMessageTypes()[0].GetFields()[0], apb.E_ResourceReference) if diff := cmp.Diff(loc.GetSpan(), []int32{4, 19, 6, 3}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } diff --git a/locations/file_locations_test.go b/locations/file_locations_test.go index 480295a..212354a 100644 --- a/locations/file_locations_test.go +++ b/locations/file_locations_test.go @@ -103,7 +103,7 @@ func TestLocations(t *testing.T) { l = test.idxFx(f, test.idx) } if diff := cmp.Diff(l.Span, test.wantSpan); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -143,7 +143,7 @@ func TestMissingLocations(t *testing.T) { for _, test := range tests { t.Run(test.testName, func(t *testing.T) { if diff := cmp.Diff(test.fx(f).Span, []int32{0, 0, 0}); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/locations/message_locations_test.go b/locations/message_locations_test.go index a23e30c..22ea52e 100644 --- a/locations/message_locations_test.go +++ b/locations/message_locations_test.go @@ -32,6 +32,6 @@ func TestMessageResource(t *testing.T) { `) loc := MessageResource(f.GetMessageTypes()[0]) if diff := cmp.Diff(loc.GetSpan(), []int32{4, 2, 7, 4}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } diff --git a/locations/method_locations_test.go b/locations/method_locations_test.go index 7e67096..1300d26 100644 --- a/locations/method_locations_test.go +++ b/locations/method_locations_test.go @@ -31,7 +31,7 @@ func TestMethodRequestType(t *testing.T) { loc := MethodRequestType(f.GetServices()[0].GetMethods()[0]) // Three character span: line, start column, end column. if diff := cmp.Diff(loc.GetSpan(), []int32{3, 14, 28}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -46,7 +46,7 @@ func TestMethodResponseType(t *testing.T) { loc := MethodResponseType(f.GetServices()[0].GetMethods()[0]) // Three character span: line, start column, end column. if diff := cmp.Diff(loc.GetSpan(), []int32{3, 39, 43}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -66,7 +66,7 @@ func TestMethodHTTPRule(t *testing.T) { loc := MethodHTTPRule(f.GetServices()[0].GetMethods()[0]) // Four character span: start line, start column, end line, end column. if diff := cmp.Diff(loc.GetSpan(), []int32{5, 4, 7, 6}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -86,7 +86,7 @@ func TestMethodOperationInfo(t *testing.T) { loc := MethodOperationInfo(f.GetServices()[0].GetMethods()[0]) // Four character span: start line, start column, end line, end column. if diff := cmp.Diff(loc.GetSpan(), []int32{5, 4, 8, 6}); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -113,7 +113,7 @@ func TestMethodSignature(t *testing.T) { loc := MethodSignature(f.GetServices()[0].GetMethods()[0], test.index) // Four character span: start line, start column, end line, end column. if diff := cmp.Diff(loc.GetSpan(), test.want); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0004/path_never_optional_test.go b/rules/aep0004/path_never_optional_test.go index bf4c981..d26080e 100644 --- a/rules/aep0004/path_never_optional_test.go +++ b/rules/aep0004/path_never_optional_test.go @@ -48,7 +48,7 @@ func TestPathNeverOptional(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(pathNeverOptional.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_annotation_test.go b/rules/aep0004/resource_annotation_test.go index 2c6b8e3..7406875 100644 --- a/rules/aep0004/resource_annotation_test.go +++ b/rules/aep0004/resource_annotation_test.go @@ -34,7 +34,7 @@ func TestResourceAnnotation(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(resourceAnnotation.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) @@ -48,7 +48,7 @@ func TestResourceAnnotation(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(resourceAnnotation.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) @@ -73,7 +73,7 @@ func TestResourceAnnotation(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(resourceAnnotation.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_definition_pattern_test.go b/rules/aep0004/resource_definition_pattern_test.go index 9b23707..c9199c6 100644 --- a/rules/aep0004/resource_definition_pattern_test.go +++ b/rules/aep0004/resource_definition_pattern_test.go @@ -44,7 +44,7 @@ func TestResourceDefinitionPattern(t *testing.T) { `, test) got := resourceDefinitionPatterns.Lint(f) if diff := test.problems.SetDescriptor(f).Diff(got); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_definition_variables_test.go b/rules/aep0004/resource_definition_variables_test.go index 5cf8008..5e76680 100644 --- a/rules/aep0004/resource_definition_variables_test.go +++ b/rules/aep0004/resource_definition_variables_test.go @@ -44,7 +44,7 @@ func TestResourceDefinitionVariables(t *testing.T) { `, test) got := resourceDefinitionVariables.Lint(f) if diff := test.problems.SetDescriptor(f).Diff(got); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_name_components_alternate_test.go b/rules/aep0004/resource_name_components_alternate_test.go index bf98dc3..eee46fe 100644 --- a/rules/aep0004/resource_name_components_alternate_test.go +++ b/rules/aep0004/resource_name_components_alternate_test.go @@ -44,7 +44,7 @@ func TestResourceNameComponentsAlternate(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(resourceNameComponentsAlternate.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_pattern_test.go b/rules/aep0004/resource_pattern_test.go index ce84fd3..64d92d0 100644 --- a/rules/aep0004/resource_pattern_test.go +++ b/rules/aep0004/resource_pattern_test.go @@ -50,7 +50,7 @@ func TestResourcePattern(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(resourcePattern.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0004/resource_variables_test.go b/rules/aep0004/resource_variables_test.go index c27806f..383d88c 100644 --- a/rules/aep0004/resource_variables_test.go +++ b/rules/aep0004/resource_variables_test.go @@ -47,7 +47,7 @@ func TestResourceVariables(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(resourceVariables.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0122/kebab_case_uris_test.go b/rules/aep0122/kebab_case_uris_test.go index 32bed7b..6f66d5f 100644 --- a/rules/aep0122/kebab_case_uris_test.go +++ b/rules/aep0122/kebab_case_uris_test.go @@ -53,7 +53,7 @@ func TestHttpUriField(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] problems := httpURICase.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0122/no_self_links_test.go b/rules/aep0122/no_self_links_test.go index 4b174da..b356e3d 100644 --- a/rules/aep0122/no_self_links_test.go +++ b/rules/aep0122/no_self_links_test.go @@ -43,7 +43,7 @@ func TestNoSelfLinks(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[1] if diff := test.problems.SetDescriptor(field).Diff(noSelfLinks.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0122/path_suffix_test.go b/rules/aep0122/path_suffix_test.go index c641935..21f69a0 100644 --- a/rules/aep0122/path_suffix_test.go +++ b/rules/aep0122/path_suffix_test.go @@ -42,7 +42,7 @@ func TestPathSuffix(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[1] if diff := test.problems.SetDescriptor(field).Diff(pathSuffix.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0122/resource_collection_identifiers_test.go b/rules/aep0122/resource_collection_identifiers_test.go index 1218034..ab24f8f 100644 --- a/rules/aep0122/resource_collection_identifiers_test.go +++ b/rules/aep0122/resource_collection_identifiers_test.go @@ -45,7 +45,7 @@ func TestResourceCollectionIdentifiers(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(resourceCollectionIdentifiers.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0122/resource_id_output_only.go b/rules/aep0122/resource_id_output_only.go index 790f046..d78a56d 100644 --- a/rules/aep0122/resource_id_output_only.go +++ b/rules/aep0122/resource_id_output_only.go @@ -26,7 +26,7 @@ var resourceIdOutputOnly = &lint.FieldRule{ Name: lint.NewRuleName(122, "resource-id-output-only"), OnlyIf: func(f *desc.FieldDescriptor) bool { var idName string - p := f.GetParent().(*desc.MessageDescriptor) + p, _ := f.GetParent().(*desc.MessageDescriptor) // Build an expected ID field name based on the Resource `singular` // field or by parsing the `type`. diff --git a/rules/aep0122/resource_id_output_only_test.go b/rules/aep0122/resource_id_output_only_test.go index b891ad9..a03226f 100644 --- a/rules/aep0122/resource_id_output_only_test.go +++ b/rules/aep0122/resource_id_output_only_test.go @@ -48,7 +48,7 @@ func TestResourceIdOutputOnly(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[1] if diff := test.problems.SetDescriptor(field).Diff(resourceIdOutputOnly.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0122/resource_reference_type_test.go b/rules/aep0122/resource_reference_type_test.go index ecfc1cd..e75b81f 100644 --- a/rules/aep0122/resource_reference_type_test.go +++ b/rules/aep0122/resource_reference_type_test.go @@ -46,7 +46,7 @@ func TestResourceReferenceType(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(resourceReferenceType.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0126/unspecified_test.go b/rules/aep0126/unspecified_test.go index e8fe75a..d59f3f9 100644 --- a/rules/aep0126/unspecified_test.go +++ b/rules/aep0126/unspecified_test.go @@ -48,7 +48,7 @@ func TestUnspecified(t *testing.T) { // Run the lint rule and establish we get the correct problems. problems := unspecified.Lint(f) if diff := test.problems.SetDescriptor(f.GetEnumTypes()[0].GetValues()[0]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -67,7 +67,7 @@ func TestUnspecified(t *testing.T) { // Run the lint rule and establish we get the correct problems. problems := unspecified.Lint(f) if diff := test.problems.SetDescriptor(f.GetEnumTypes()[0].GetValues()[0]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0127/http_annotation_test.go b/rules/aep0127/http_annotation_test.go index 67ff320..b88b57a 100644 --- a/rules/aep0127/http_annotation_test.go +++ b/rules/aep0127/http_annotation_test.go @@ -55,7 +55,7 @@ func TestHasAnnotation(t *testing.T) { `, "{{.Annotation}}", test.annotation), test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(hasAnnotation.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0127/http_template_pattern_test.go b/rules/aep0127/http_template_pattern_test.go index ff7bdbb..0fe0099 100644 --- a/rules/aep0127/http_template_pattern_test.go +++ b/rules/aep0127/http_template_pattern_test.go @@ -79,7 +79,7 @@ func TestHttpTemplatePattern_PatternMatching(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(httpTemplatePattern.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -123,7 +123,7 @@ func TestHttpTemplatePattern_MultiplePatterns(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(httpTemplatePattern.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0127/resource_path_extraction_test.go b/rules/aep0127/resource_path_extraction_test.go index 50497a3..de3efbe 100644 --- a/rules/aep0127/resource_path_extraction_test.go +++ b/rules/aep0127/resource_path_extraction_test.go @@ -47,7 +47,7 @@ func TestResourcePathExtraction(t *testing.T) { method := f.GetServices()[0].GetMethods()[0] problems := resourcePathExtraction.Lint(f) if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0127/uri_leading_slash_test.go b/rules/aep0127/uri_leading_slash_test.go index 7f37b88..4d78c07 100644 --- a/rules/aep0127/uri_leading_slash_test.go +++ b/rules/aep0127/uri_leading_slash_test.go @@ -44,7 +44,7 @@ func TestURILeadingSlash(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(leadingSlash.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0131/method_signature_test.go b/rules/aep0131/method_signature_test.go index 6ba693b..45dd52d 100644 --- a/rules/aep0131/method_signature_test.go +++ b/rules/aep0131/method_signature_test.go @@ -50,7 +50,7 @@ func TestMethodSignature(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/request_message_name_test.go b/rules/aep0131/request_message_name_test.go index 6f0c798..979a72f 100644 --- a/rules/aep0131/request_message_name_test.go +++ b/rules/aep0131/request_message_name_test.go @@ -48,7 +48,7 @@ func TestRequestMessageName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(requestMessageName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/request_path_behavior_test.go b/rules/aep0131/request_path_behavior_test.go index fb68029..934aecb 100644 --- a/rules/aep0131/request_path_behavior_test.go +++ b/rules/aep0131/request_path_behavior_test.go @@ -40,7 +40,7 @@ func TestRequestNameBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestPathBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/request_path_reference_test.go b/rules/aep0131/request_path_reference_test.go index e441735..443324f 100644 --- a/rules/aep0131/request_path_reference_test.go +++ b/rules/aep0131/request_path_reference_test.go @@ -31,7 +31,7 @@ func TestRequestNameReference(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(requestPathReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) t.Run("Absent", func(t *testing.T) { @@ -52,7 +52,7 @@ func TestRequestNameReference(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestPathReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/request_required_fields_test.go b/rules/aep0131/request_required_fields_test.go index 3c34abc..be47cc2 100644 --- a/rules/aep0131/request_required_fields_test.go +++ b/rules/aep0131/request_required_fields_test.go @@ -97,7 +97,7 @@ func TestRequiredFieldTests(t *testing.T) { dbr = f.FindMessage("GetBookRequest").FindFieldByName(test.problematicFieldName) } if diff := test.problems.SetDescriptor(dbr).Diff(requestRequiredFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/request_unknown_fields_test.go b/rules/aep0131/request_unknown_fields_test.go index 6d9aeca..7ba2835 100644 --- a/rules/aep0131/request_unknown_fields_test.go +++ b/rules/aep0131/request_unknown_fields_test.go @@ -64,7 +64,7 @@ func TestUnknownFields(t *testing.T) { wantProblems := test.problems.SetDescriptor(message.FindFieldByName(test.fieldName)) gotProblems := unknownFields.Lint(message.GetFile()) if diff := wantProblems.Diff(gotProblems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0131/synonyms_test.go b/rules/aep0131/synonyms_test.go index 7c29864..f23bf53 100644 --- a/rules/aep0131/synonyms_test.go +++ b/rules/aep0131/synonyms_test.go @@ -42,7 +42,7 @@ func TestSynonyms(t *testing.T) { `, test) m := file.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(synonyms.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0132/method_signature_test.go b/rules/aep0132/method_signature_test.go index bfcac55..5e4d01e 100644 --- a/rules/aep0132/method_signature_test.go +++ b/rules/aep0132/method_signature_test.go @@ -52,7 +52,7 @@ func TestMethodSignature(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -68,7 +68,7 @@ func TestMethodSignature(t *testing.T) { message Book {} `) if diff := (testutils.Problems{}).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_message_name_test.go b/rules/aep0132/request_message_name_test.go index 06f66e1..40977ee 100644 --- a/rules/aep0132/request_message_name_test.go +++ b/rules/aep0132/request_message_name_test.go @@ -45,7 +45,7 @@ func TestRequestMessageName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(requestMessageName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_parent_behavior_test.go b/rules/aep0132/request_parent_behavior_test.go index 27cae76..f5a006b 100644 --- a/rules/aep0132/request_parent_behavior_test.go +++ b/rules/aep0132/request_parent_behavior_test.go @@ -40,7 +40,7 @@ func TestRequestParentBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestParentBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_parent_field_test.go b/rules/aep0132/request_parent_field_test.go index ad49ac9..8498634 100644 --- a/rules/aep0132/request_parent_field_test.go +++ b/rules/aep0132/request_parent_field_test.go @@ -51,7 +51,7 @@ func TestRequestParentField(t *testing.T) { problems := requestParentField.Lint(f) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_parent_reference_test.go b/rules/aep0132/request_parent_reference_test.go index f38e44a..ae796e0 100644 --- a/rules/aep0132/request_parent_reference_test.go +++ b/rules/aep0132/request_parent_reference_test.go @@ -31,7 +31,7 @@ func TestRequestParentReference(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(requestParentReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) t.Run("Absent", func(t *testing.T) { @@ -52,7 +52,7 @@ func TestRequestParentReference(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestParentReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_parent_required_test.go b/rules/aep0132/request_parent_required_test.go index fa013a2..28d6611 100644 --- a/rules/aep0132/request_parent_required_test.go +++ b/rules/aep0132/request_parent_required_test.go @@ -28,7 +28,7 @@ func TestRequestParentRequired(t *testing.T) { `, test) problems := requestParentRequired.Lint(f) if diff := test.problems.SetDescriptor(f.GetMessageTypes()[0]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -59,7 +59,7 @@ func TestRequestParentRequired(t *testing.T) { `, test) problems := requestParentRequired.Lint(f) if diff := (testutils.Problems{}).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_parent_valid_reference.go b/rules/aep0132/request_parent_valid_reference.go index 746cdaa..263eca1 100644 --- a/rules/aep0132/request_parent_valid_reference.go +++ b/rules/aep0132/request_parent_valid_reference.go @@ -33,7 +33,7 @@ var requestParentValidReference = &lint.FieldRule{ }, LintField: func(f *desc.FieldDescriptor) []lint.Problem { p := f.GetParent() - msg := p.(*desc.MessageDescriptor) + msg, _ := p.(*desc.MessageDescriptor) res := utils.GetResourceReference(f).GetType() response := utils.FindMessage(f.GetFile(), strings.Replace(msg.GetName(), "Request", "Response", 1)) diff --git a/rules/aep0132/request_parent_valid_reference_test.go b/rules/aep0132/request_parent_valid_reference_test.go index fefb79b..515219d 100644 --- a/rules/aep0132/request_parent_valid_reference_test.go +++ b/rules/aep0132/request_parent_valid_reference_test.go @@ -53,7 +53,7 @@ func TestRequestParentValidReference(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestParentValidReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0132/request_required_fields_test.go b/rules/aep0132/request_required_fields_test.go index 51a69bd..cf5b845 100644 --- a/rules/aep0132/request_required_fields_test.go +++ b/rules/aep0132/request_required_fields_test.go @@ -101,7 +101,7 @@ func TestRequiredFieldTests(t *testing.T) { dbr = f.FindMessage("ListBooksRequest").FindFieldByName(test.problematicFieldName) } if diff := test.problems.SetDescriptor(dbr).Diff(requestRequiredFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/request_unknown_fields_test.go b/rules/aep0132/request_unknown_fields_test.go index 49f25a3..5012e31 100644 --- a/rules/aep0132/request_unknown_fields_test.go +++ b/rules/aep0132/request_unknown_fields_test.go @@ -69,7 +69,7 @@ func TestUnknownFields(t *testing.T) { // number of problems. problems := unknownFields.Lint(message.GetFile()) if diff := test.problems.SetDescriptor(message.GetFields()[1]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0132/response_unknown_fields_test.go b/rules/aep0132/response_unknown_fields_test.go index f7543b7..3771bde 100644 --- a/rules/aep0132/response_unknown_fields_test.go +++ b/rules/aep0132/response_unknown_fields_test.go @@ -45,7 +45,7 @@ func TestResponseUnknownFields(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[2] if diff := test.problems.SetDescriptor(field).Diff(responseUnknownFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/method_signature_test.go b/rules/aep0133/method_signature_test.go index 8312f6c..f395da4 100644 --- a/rules/aep0133/method_signature_test.go +++ b/rules/aep0133/method_signature_test.go @@ -79,7 +79,7 @@ func TestMethodSignature(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -106,7 +106,7 @@ func TestMethodSignature(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(methodSignature.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_id_field_test.go b/rules/aep0133/request_id_field_test.go index 6ed8484..8450d7b 100644 --- a/rules/aep0133/request_id_field_test.go +++ b/rules/aep0133/request_id_field_test.go @@ -56,7 +56,7 @@ func TestRequestIDField(t *testing.T) { `, test) m := f.FindMessage("CreateBookRequest") if diff := test.problems.SetDescriptor(m).Diff(requestIDField.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_message_name_test.go b/rules/aep0133/request_message_name_test.go index 1f7b9b8..932f384 100644 --- a/rules/aep0133/request_message_name_test.go +++ b/rules/aep0133/request_message_name_test.go @@ -53,7 +53,7 @@ func TestInputName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(inputName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_parent_behavior_test.go b/rules/aep0133/request_parent_behavior_test.go index d2c11e5..cd73e28 100644 --- a/rules/aep0133/request_parent_behavior_test.go +++ b/rules/aep0133/request_parent_behavior_test.go @@ -40,7 +40,7 @@ func TestRequestParentBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestParentBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_parent_field_test.go b/rules/aep0133/request_parent_field_test.go index 17d6c65..0538440 100644 --- a/rules/aep0133/request_parent_field_test.go +++ b/rules/aep0133/request_parent_field_test.go @@ -47,7 +47,7 @@ func TestRequestParentField(t *testing.T) { problems := requestParentField.Lint(f) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_parent_required_test.go b/rules/aep0133/request_parent_required_test.go index 237a12b..ff9c45a 100644 --- a/rules/aep0133/request_parent_required_test.go +++ b/rules/aep0133/request_parent_required_test.go @@ -31,7 +31,7 @@ func TestRequestParentFieldRequired(t *testing.T) { problems := requestParentRequired.Lint(f) message := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(message).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -53,7 +53,7 @@ func TestRequestParentFieldRequired(t *testing.T) { `) problems := requestParentRequired.Lint(f) if diff := (testutils.Problems{}).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_required_fields_test.go b/rules/aep0133/request_required_fields_test.go index 7a3c701..a35d56a 100644 --- a/rules/aep0133/request_required_fields_test.go +++ b/rules/aep0133/request_required_fields_test.go @@ -125,7 +125,7 @@ func TestRequiredFieldTests(t *testing.T) { dbr = f.FindMessage("CreateBookShelfRequest").FindFieldByName(test.problematicFieldName) } if diff := test.problems.SetDescriptor(dbr).Diff(requestRequiredFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_resource_behavior_test.go b/rules/aep0133/request_resource_behavior_test.go index 03c7619..3378ae5 100644 --- a/rules/aep0133/request_resource_behavior_test.go +++ b/rules/aep0133/request_resource_behavior_test.go @@ -43,7 +43,7 @@ func TestRequestResourceBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestResourceBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_resource_field_test.go b/rules/aep0133/request_resource_field_test.go index 4fcc30c..f4fc03c 100644 --- a/rules/aep0133/request_resource_field_test.go +++ b/rules/aep0133/request_resource_field_test.go @@ -81,7 +81,7 @@ func TestResourceField(t *testing.T) { // Run the lint rule, and establish that it returns the correct problems. problems := resourceField.Lint(message.GetFile()) if diff := test.problems.SetDescriptor(d).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/request_unknown_fields_test.go b/rules/aep0133/request_unknown_fields_test.go index 35de6f5..8789cc6 100644 --- a/rules/aep0133/request_unknown_fields_test.go +++ b/rules/aep0133/request_unknown_fields_test.go @@ -125,7 +125,7 @@ func TestUnknownFields(t *testing.T) { // Run the lint rule, and establish that it returns the correct problems. problems := unknownFields.Lint(message.GetFile()) if diff := test.problems.SetDescriptor(problemDesc).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/response_message_name_test.go b/rules/aep0133/response_message_name_test.go index ffc44dc..2b89464 100644 --- a/rules/aep0133/response_message_name_test.go +++ b/rules/aep0133/response_message_name_test.go @@ -63,7 +63,7 @@ func TestOutputMessageName(t *testing.T) { problems := outputName.Lint(file) method := file.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0133/synonyms_test.go b/rules/aep0133/synonyms_test.go index b6ef0fb..5983dc0 100644 --- a/rules/aep0133/synonyms_test.go +++ b/rules/aep0133/synonyms_test.go @@ -41,7 +41,7 @@ func TestSynonyms(t *testing.T) { `, test) m := file.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(synonyms.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/method_signature_test.go b/rules/aep0134/method_signature_test.go index af65e41..a1886be 100644 --- a/rules/aep0134/method_signature_test.go +++ b/rules/aep0134/method_signature_test.go @@ -50,7 +50,7 @@ func TestMethodSignature(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_mask_required_test.go b/rules/aep0134/request_mask_required_test.go index 33121b0..457301c 100644 --- a/rules/aep0134/request_mask_required_test.go +++ b/rules/aep0134/request_mask_required_test.go @@ -42,7 +42,7 @@ func TestRequestMaskFieldRequired(t *testing.T) { message := file.GetMessageTypes()[0] problems := requestMaskRequired.Lint(file) if diff := test.problems.SetDescriptor(message).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_message_name_test.go b/rules/aep0134/request_message_name_test.go index b00abf9..bd8b8fe 100644 --- a/rules/aep0134/request_message_name_test.go +++ b/rules/aep0134/request_message_name_test.go @@ -47,7 +47,7 @@ func TestRequestMessageName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(requestMessageName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_required_fields_test.go b/rules/aep0134/request_required_fields_test.go index d8a6187..48a950a 100644 --- a/rules/aep0134/request_required_fields_test.go +++ b/rules/aep0134/request_required_fields_test.go @@ -115,7 +115,7 @@ func TestRequiredFieldTests(t *testing.T) { dbr = f.FindMessage("UpdateBookShelfRequest").FindFieldByName(test.problematicFieldName) } if diff := test.problems.SetDescriptor(dbr).Diff(requestRequiredFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_resource_field_test.go b/rules/aep0134/request_resource_field_test.go index b89379f..8b6c568 100644 --- a/rules/aep0134/request_resource_field_test.go +++ b/rules/aep0134/request_resource_field_test.go @@ -51,7 +51,7 @@ func TestResourceField(t *testing.T) { // Run the lint rule, and establish that it returns the correct problems. problems := requestResourceField.Lint(file) if diff := test.problems.SetDescriptor(field).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_resource_required_test.go b/rules/aep0134/request_resource_required_test.go index e265c73..06b864c 100644 --- a/rules/aep0134/request_resource_required_test.go +++ b/rules/aep0134/request_resource_required_test.go @@ -33,7 +33,7 @@ func TestRequestResourceFieldRequired(t *testing.T) { message := file.GetMessageTypes()[0] problems := requestResourceRequired.Lint(file) if diff := test.problems.SetDescriptor(message).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/request_unknown_fields_test.go b/rules/aep0134/request_unknown_fields_test.go index 652d09d..116eb4f 100644 --- a/rules/aep0134/request_unknown_fields_test.go +++ b/rules/aep0134/request_unknown_fields_test.go @@ -82,7 +82,7 @@ func TestUnknownFields(t *testing.T) { wantProblems := test.problems.SetDescriptor(message.FindFieldByName(test.fieldName)) gotProblems := unknownFields.Lint(message.GetFile()) if diff := wantProblems.Diff(gotProblems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/response_lro_test.go b/rules/aep0134/response_lro_test.go index 9fa038d..99a4cce 100644 --- a/rules/aep0134/response_lro_test.go +++ b/rules/aep0134/response_lro_test.go @@ -53,7 +53,7 @@ func TestResponseLRO(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(responseLRO.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/response_message_name_test.go b/rules/aep0134/response_message_name_test.go index f736ea3..f01ecb6 100644 --- a/rules/aep0134/response_message_name_test.go +++ b/rules/aep0134/response_message_name_test.go @@ -63,7 +63,7 @@ func TestResponseMessageName(t *testing.T) { problems := responseMessageName.Lint(file) method := file.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0134/synonyms_test.go b/rules/aep0134/synonyms_test.go index 327b38f..2db24a2 100644 --- a/rules/aep0134/synonyms_test.go +++ b/rules/aep0134/synonyms_test.go @@ -42,7 +42,7 @@ func TestSynonyms(t *testing.T) { `, test) m := file.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(synonyms.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/method_signature_test.go b/rules/aep0135/method_signature_test.go index fb861b4..487c5ed 100644 --- a/rules/aep0135/method_signature_test.go +++ b/rules/aep0135/method_signature_test.go @@ -60,7 +60,7 @@ func TestMethodSignature(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(methodSignature.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/request_message_name_test.go b/rules/aep0135/request_message_name_test.go index 2174ad8..daf5f22 100644 --- a/rules/aep0135/request_message_name_test.go +++ b/rules/aep0135/request_message_name_test.go @@ -47,7 +47,7 @@ func TestRequestMessageName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(requestMessageName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/request_path_behavior_test.go b/rules/aep0135/request_path_behavior_test.go index bd9b418..f015e28 100644 --- a/rules/aep0135/request_path_behavior_test.go +++ b/rules/aep0135/request_path_behavior_test.go @@ -40,7 +40,7 @@ func TestRequestNameBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestPathBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/request_path_reference_test.go b/rules/aep0135/request_path_reference_test.go index 6c9afa3..98bd6a5 100644 --- a/rules/aep0135/request_path_reference_test.go +++ b/rules/aep0135/request_path_reference_test.go @@ -31,7 +31,7 @@ func TestRequestNameReference(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(requestPathReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) t.Run("Absent", func(t *testing.T) { @@ -52,7 +52,7 @@ func TestRequestNameReference(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestPathReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/request_required_fields_test.go b/rules/aep0135/request_required_fields_test.go index 2b7dab8..104c350 100644 --- a/rules/aep0135/request_required_fields_test.go +++ b/rules/aep0135/request_required_fields_test.go @@ -88,7 +88,7 @@ func TestRequiredFieldTests(t *testing.T) { dbr = f.FindMessage("DeleteBookRequest").FindFieldByName(test.problematicFieldName) } if diff := test.problems.SetDescriptor(dbr).Diff(requestRequiredFields.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/request_unknown_fields_test.go b/rules/aep0135/request_unknown_fields_test.go index 4bce00e..bc166ac 100644 --- a/rules/aep0135/request_unknown_fields_test.go +++ b/rules/aep0135/request_unknown_fields_test.go @@ -58,7 +58,7 @@ func TestUnknownFields(t *testing.T) { wantProblems := test.problems.SetDescriptor(message.FindFieldByName(test.fieldName)) gotProblems := unknownFields.Lint(message.GetFile()) if diff := wantProblems.Diff(gotProblems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/response_lro_test.go b/rules/aep0135/response_lro_test.go index 9ac9e04..639260e 100644 --- a/rules/aep0135/response_lro_test.go +++ b/rules/aep0135/response_lro_test.go @@ -53,7 +53,7 @@ func TestResponseLRO(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(responseLRO.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0135/response_message_name_test.go b/rules/aep0135/response_message_name_test.go index c24bae1..0ff37ae 100644 --- a/rules/aep0135/response_message_name_test.go +++ b/rules/aep0135/response_message_name_test.go @@ -107,7 +107,7 @@ func TestResponseMessageName(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] problems := responseMessageName.Lint(file) if diff := test.problems[tmplName].SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0136/declarative_standard_methods_only_test.go b/rules/aep0136/declarative_standard_methods_only_test.go index 4927d4c..b5e8a59 100644 --- a/rules/aep0136/declarative_standard_methods_only_test.go +++ b/rules/aep0136/declarative_standard_methods_only_test.go @@ -60,7 +60,7 @@ func TestDeclarativeFriendly(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(standardMethodsOnly.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0136/http_body_test.go b/rules/aep0136/http_body_test.go index acca917..69bc23b 100644 --- a/rules/aep0136/http_body_test.go +++ b/rules/aep0136/http_body_test.go @@ -55,7 +55,7 @@ func TestHttpBody(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] problems := httpBody.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0136/http_method_test.go b/rules/aep0136/http_method_test.go index fdeb081..a25660e 100644 --- a/rules/aep0136/http_method_test.go +++ b/rules/aep0136/http_method_test.go @@ -55,7 +55,7 @@ func TestHttpMethod(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] got := httpMethod.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(got); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0136/prepositions_test.go b/rules/aep0136/prepositions_test.go index 92e3f4f..6375bee 100644 --- a/rules/aep0136/prepositions_test.go +++ b/rules/aep0136/prepositions_test.go @@ -41,7 +41,7 @@ func TestNoPrepositions(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] got := noPrepositions.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(got); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0136/verb_noun_test.go b/rules/aep0136/verb_noun_test.go index 075e0e3..fceb133 100644 --- a/rules/aep0136/verb_noun_test.go +++ b/rules/aep0136/verb_noun_test.go @@ -40,7 +40,7 @@ func TestVerbNoun(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] got := verbNoun.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(got); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0141/count_suffix_test.go b/rules/aep0141/count_suffix_test.go index 39e4eed..5273c36 100644 --- a/rules/aep0141/count_suffix_test.go +++ b/rules/aep0141/count_suffix_test.go @@ -51,7 +51,7 @@ func TestCount(t *testing.T) { }) } if diff := wantProblems.Diff(count.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0141/forbidden_types_test.go b/rules/aep0141/forbidden_types_test.go index bc885cb..dbe9db1 100644 --- a/rules/aep0141/forbidden_types_test.go +++ b/rules/aep0141/forbidden_types_test.go @@ -42,7 +42,7 @@ func TestForbiddenTypes(t *testing.T) { field := file.GetMessageTypes()[0].GetFields()[0] problems := forbiddenTypes.Lint(file) if diff := test.problems.SetDescriptor(field).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0142/time_field_names_test.go b/rules/aep0142/time_field_names_test.go index 0b9330a..74a9c2b 100644 --- a/rules/aep0142/time_field_names_test.go +++ b/rules/aep0142/time_field_names_test.go @@ -47,7 +47,7 @@ func TestFieldName(t *testing.T) { `, test) field := file.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(fieldNames.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0142/time_field_type_test.go b/rules/aep0142/time_field_type_test.go index 2f52b47..83e0817 100644 --- a/rules/aep0142/time_field_type_test.go +++ b/rules/aep0142/time_field_type_test.go @@ -47,7 +47,7 @@ func TestFieldType(t *testing.T) { `, test) field := file.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(fieldType.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0148/human_names_test.go b/rules/aep0148/human_names_test.go index 00c4e7b..67a810c 100644 --- a/rules/aep0148/human_names_test.go +++ b/rules/aep0148/human_names_test.go @@ -38,7 +38,7 @@ func TestHumanNames(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(humanNames.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0148/ip_address_format_test.go b/rules/aep0148/ip_address_format_test.go index 0af5f8c..c0a3bfe 100644 --- a/rules/aep0148/ip_address_format_test.go +++ b/rules/aep0148/ip_address_format_test.go @@ -78,7 +78,7 @@ func TestIpAddressFormat(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(ipAddressFormat.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0148/uid_format_test.go b/rules/aep0148/uid_format_test.go index 7ccac90..58b147c 100644 --- a/rules/aep0148/uid_format_test.go +++ b/rules/aep0148/uid_format_test.go @@ -67,7 +67,7 @@ func TestUidFormat(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(uidFormat.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0151/lro_metadata_reachable_test.go b/rules/aep0151/lro_metadata_reachable_test.go index b043579..a3a3269 100644 --- a/rules/aep0151/lro_metadata_reachable_test.go +++ b/rules/aep0151/lro_metadata_reachable_test.go @@ -56,7 +56,7 @@ func TestLROMetadataReachable(t *testing.T) { problems := lroMetadataReachable.Lint(f) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -95,7 +95,7 @@ func TestLROMetadataReachable(t *testing.T) { problems := lroMetadataReachable.Lint(files["test.proto"]) method := files["test.proto"].GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0151/lro_metadata_type_test.go b/rules/aep0151/lro_metadata_type_test.go index d0d2d24..35ccbeb 100644 --- a/rules/aep0151/lro_metadata_type_test.go +++ b/rules/aep0151/lro_metadata_type_test.go @@ -50,7 +50,7 @@ func TestLROMetadata(t *testing.T) { problems := lroMetadata.Lint(f) d := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(d).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0151/lro_response_type_test.go b/rules/aep0151/lro_response_type_test.go index a54554e..d690e46 100644 --- a/rules/aep0151/lro_response_type_test.go +++ b/rules/aep0151/lro_response_type_test.go @@ -51,7 +51,7 @@ func TestLROResponse(t *testing.T) { problems := lroResponse.Lint(f) d := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(d).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0151/operation_info_test.go b/rules/aep0151/operation_info_test.go index d6eef37..32fc2dc 100644 --- a/rules/aep0151/operation_info_test.go +++ b/rules/aep0151/operation_info_test.go @@ -34,7 +34,7 @@ func TestAnnotationExistsValid(t *testing.T) { message WriteBookRequest {} `) if diff := (testutils.Problems{}).Diff(lroAnnotationExists.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } @@ -51,6 +51,6 @@ func TestAnnotationExistsInvalid(t *testing.T) { Message: "operation_info annotation", }} if diff := want.Diff(lroAnnotationExists.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } diff --git a/rules/aep0151/response_unary_test.go b/rules/aep0151/response_unary_test.go index 99c4503..35f4f9a 100644 --- a/rules/aep0151/response_unary_test.go +++ b/rules/aep0151/response_unary_test.go @@ -42,7 +42,7 @@ func TestResponseUnary(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(responseUnary.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0155/request_id_type.go b/rules/aep0155/request_id_type.go index 0f7a25c..178c315 100644 --- a/rules/aep0155/request_id_type.go +++ b/rules/aep0155/request_id_type.go @@ -21,18 +21,18 @@ import ( ) var requestIdType = &lint.FieldRule{ - Name: lint.NewRuleName(155, "request-id-type"), + Name: lint.NewRuleName(155, "request-id-type"), RuleType: lint.NewRuleType(lint.MustRule), OnlyIf: func(fd *desc.FieldDescriptor) bool { return fd.GetName() == "request_id" }, LintField: func(fd *desc.FieldDescriptor) []lint.Problem { - if(fd.GetType() != descriptorpb.FieldDescriptorProto_TYPE_MESSAGE || fd.GetMessageType().GetFullyQualifiedName() != "aep.api.IdempotencyKey") { + if fd.GetType() != descriptorpb.FieldDescriptorProto_TYPE_MESSAGE || fd.GetMessageType().GetFullyQualifiedName() != "aep.api.IdempotencyKey" { return []lint.Problem{{ Message: "The `request_id` field should have type `aep.api.IdempotencyKey`", Descriptor: fd, }} - } + } return nil }, diff --git a/rules/aep0155/request_id_type_test.go b/rules/aep0155/request_id_type_test.go index 9816563..4f40923 100644 --- a/rules/aep0155/request_id_type_test.go +++ b/rules/aep0155/request_id_type_test.go @@ -23,12 +23,12 @@ import ( func TestRequestIdFormat(t *testing.T) { for _, test := range []struct { name, FieldName, Type string - problems testutils.Problems + problems testutils.Problems }{ { - name: "ValidRequestIdFormat", - FieldName: "request_id", - Type: "aep.api.IdempotencyKey", + name: "ValidRequestIdFormat", + FieldName: "request_id", + Type: "aep.api.IdempotencyKey", }, { name: "SkipNonRequestId", @@ -52,7 +52,7 @@ func TestRequestIdFormat(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestIdType.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0156/forbidden_methods_test.go b/rules/aep0156/forbidden_methods_test.go index b2aef39..09cb095 100644 --- a/rules/aep0156/forbidden_methods_test.go +++ b/rules/aep0156/forbidden_methods_test.go @@ -50,7 +50,7 @@ func TestForbiddenMethods(t *testing.T) { method := f.GetServices()[0].GetMethods()[0] problems := forbiddenMethods.Lint(f) if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0158/response_next_page_token_field_test.go b/rules/aep0158/response_next_page_token_field_test.go index 6820054..2d75919 100644 --- a/rules/aep0158/response_next_page_token_field_test.go +++ b/rules/aep0158/response_next_page_token_field_test.go @@ -87,7 +87,7 @@ func TestResponsePaginationNextPageToken(t *testing.T) { // Run the lint rule, and establish that it returns the correct problems. problems := responsePaginationNextPageToken.Lint(message.GetFile()) if diff := test.problems.SetDescriptor(problemDesc).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0158/response_repeated_field.go b/rules/aep0158/response_repeated_field.go index 7818ca9..ace9028 100644 --- a/rules/aep0158/response_repeated_field.go +++ b/rules/aep0158/response_repeated_field.go @@ -27,8 +27,8 @@ var responseRepeatedFirstField = &lint.MessageRule{ }, LintMessage: func(m *desc.MessageDescriptor) []lint.Problem { for _, f := range m.GetFields() { - if(f.IsRepeated()) { - return nil; + if f.IsRepeated() { + return nil } } diff --git a/rules/aep0158/response_repeated_field_test.go b/rules/aep0158/response_repeated_field_test.go index 3ae6665..43e5fd6 100644 --- a/rules/aep0158/response_repeated_field_test.go +++ b/rules/aep0158/response_repeated_field_test.go @@ -48,7 +48,7 @@ func TestResponseRepeatedFirstField(t *testing.T) { // Run the lint rule and establish we get the correct problems. problems := responseRepeatedFirstField.Lint(f) if diff := test.problems.SetDescriptor(f.GetMessageTypes()[1]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0158/response_unary_test.go b/rules/aep0158/response_unary_test.go index 84e3231..9a78ddb 100644 --- a/rules/aep0158/response_unary_test.go +++ b/rules/aep0158/response_unary_test.go @@ -47,7 +47,7 @@ func TestResponseUnary(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(responseUnary.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0159/hardcoded_hyphen_test.go b/rules/aep0159/hardcoded_hyphen_test.go index b02230d..b12c530 100644 --- a/rules/aep0159/hardcoded_hyphen_test.go +++ b/rules/aep0159/hardcoded_hyphen_test.go @@ -43,7 +43,7 @@ func TestHardcodedHyphen(t *testing.T) { `, test) method := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(method).Diff(hardcodedHyphen.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } } } diff --git a/rules/aep0164/http_uri_suffix_test.go b/rules/aep0164/http_uri_suffix_test.go index 5fcac53..722c3d3 100644 --- a/rules/aep0164/http_uri_suffix_test.go +++ b/rules/aep0164/http_uri_suffix_test.go @@ -52,7 +52,7 @@ func TestHttpUriSuffix(t *testing.T) { // Run the method, ensure we get what we expect. problems := httpURISuffix.Lint(file) if diff := test.problems.SetDescriptor(file.GetServices()[0].GetMethods()[0]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/request_message_name_test.go b/rules/aep0164/request_message_name_test.go index c22de6c..9a1d2f3 100644 --- a/rules/aep0164/request_message_name_test.go +++ b/rules/aep0164/request_message_name_test.go @@ -47,7 +47,7 @@ func TestRequestMessageName(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(requestMessageName.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/request_name_behavior_test.go b/rules/aep0164/request_name_behavior_test.go index 77c05f8..34e4229 100644 --- a/rules/aep0164/request_name_behavior_test.go +++ b/rules/aep0164/request_name_behavior_test.go @@ -42,7 +42,7 @@ func TestRequestNameBehavior(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestNameBehavior.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/request_name_reference_test.go b/rules/aep0164/request_name_reference_test.go index 175d1d3..d99c793 100644 --- a/rules/aep0164/request_name_reference_test.go +++ b/rules/aep0164/request_name_reference_test.go @@ -31,7 +31,7 @@ func TestRequestNameReference(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(requestNameReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) t.Run("Absent", func(t *testing.T) { @@ -52,7 +52,7 @@ func TestRequestNameReference(t *testing.T) { `, test) field := f.GetMessageTypes()[0].GetFields()[0] if diff := test.problems.SetDescriptor(field).Diff(requestNameReference.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/request_unknown_fields_test.go b/rules/aep0164/request_unknown_fields_test.go index 57188d6..7d34967 100644 --- a/rules/aep0164/request_unknown_fields_test.go +++ b/rules/aep0164/request_unknown_fields_test.go @@ -56,7 +56,7 @@ func TestRequestUnknownFields(t *testing.T) { wantProblems := test.problems.SetDescriptor(message.FindFieldByName(test.fieldName)) gotProblems := requestUnknownFields.Lint(message.GetFile()) if diff := wantProblems.Diff(gotProblems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/response_lro_test.go b/rules/aep0164/response_lro_test.go index c3460fe..c4c1649 100644 --- a/rules/aep0164/response_lro_test.go +++ b/rules/aep0164/response_lro_test.go @@ -50,7 +50,7 @@ func TestResponseLRO(t *testing.T) { `, test) m := f.GetServices()[0].GetMethods()[0] if diff := test.problems.SetDescriptor(m).Diff(responseLRO.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0164/response_message_name_test.go b/rules/aep0164/response_message_name_test.go index 2c9c6c1..df2ec4c 100644 --- a/rules/aep0164/response_message_name_test.go +++ b/rules/aep0164/response_message_name_test.go @@ -73,7 +73,7 @@ func TestResponseMessageName(t *testing.T) { method := file.GetServices()[0].GetMethods()[0] problems := responseMessageName.Lint(file) if diff := test.problems.SetDescriptor(method).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0191/file_layout_test.go b/rules/aep0191/file_layout_test.go index bcdc6ae..fbd36a4 100644 --- a/rules/aep0191/file_layout_test.go +++ b/rules/aep0191/file_layout_test.go @@ -42,7 +42,7 @@ func TestFileLayout(t *testing.T) { `) want := testutils.Problems{{Descriptor: f.GetServices()[0]}} if diff := want.Diff(fileLayout.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) @@ -55,7 +55,7 @@ func TestFileLayout(t *testing.T) { `) want := testutils.Problems{{Descriptor: f.GetEnumTypes()[0]}} if diff := want.Diff(fileLayout.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) diff --git a/rules/aep0191/filenames_test.go b/rules/aep0191/filenames_test.go index 411a4ab..c4cdb04 100644 --- a/rules/aep0191/filenames_test.go +++ b/rules/aep0191/filenames_test.go @@ -51,7 +51,7 @@ func TestFilename(t *testing.T) { t.Fatalf("Failed to build file.") } if diff := test.problems.SetDescriptor(f).Diff(filename.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0191/proto_version_test.go b/rules/aep0191/proto_version_test.go index 5b39661..fcc6ab9 100644 --- a/rules/aep0191/proto_version_test.go +++ b/rules/aep0191/proto_version_test.go @@ -43,7 +43,7 @@ func TestSyntax(t *testing.T) { // Lint the file, and ensure we got the expected problems. if diff := test.problems.SetDescriptor(f).Diff(syntax.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0192/absolute_links_test.go b/rules/aep0192/absolute_links_test.go index 34f26a7..cca730a 100644 --- a/rules/aep0192/absolute_links_test.go +++ b/rules/aep0192/absolute_links_test.go @@ -38,7 +38,7 @@ func TestAbsoluteLinks(t *testing.T) { m := f.GetMessageTypes()[0] problems := absoluteLinks.Lint(f) if diff := test.problems.SetDescriptor(m).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0192/no_html_test.go b/rules/aep0192/no_html_test.go index d973d7c..65a19b9 100644 --- a/rules/aep0192/no_html_test.go +++ b/rules/aep0192/no_html_test.go @@ -47,7 +47,7 @@ func TestNoHTML(t *testing.T) { `, "{{.Comment}}", test.comment)) message := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(message).Diff(noHTML.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0192/no_markdown_headings_test.go b/rules/aep0192/no_markdown_headings_test.go index 245785f..dff28cd 100644 --- a/rules/aep0192/no_markdown_headings_test.go +++ b/rules/aep0192/no_markdown_headings_test.go @@ -44,7 +44,7 @@ func TestNoMarkdownHeadings(t *testing.T) { `, struct{ Comment string }{cmt}) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(noMarkdownHeadings.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0192/no_markdown_tables_test.go b/rules/aep0192/no_markdown_tables_test.go index f0bbfba..3cdc000 100644 --- a/rules/aep0192/no_markdown_tables_test.go +++ b/rules/aep0192/no_markdown_tables_test.go @@ -43,7 +43,7 @@ func TestNoMarkdownTables(t *testing.T) { `, test) m := f.GetMessageTypes()[0] if diff := test.problems.SetDescriptor(m).Diff(noMarkdownTables.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0192/only_leading_comments_test.go b/rules/aep0192/only_leading_comments_test.go index 41b542f..9d74ba8 100644 --- a/rules/aep0192/only_leading_comments_test.go +++ b/rules/aep0192/only_leading_comments_test.go @@ -85,7 +85,7 @@ func TestOnlyLeadingComments(t *testing.T) { `, test) problems := onlyLeadingComments.Lint(file) if diff := test.problems.SetDescriptor(file.GetMessageTypes()[0]).Diff(problems); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0216/nesting.go b/rules/aep0216/nesting.go index e4c5096..5d55e9e 100644 --- a/rules/aep0216/nesting.go +++ b/rules/aep0216/nesting.go @@ -23,7 +23,7 @@ import ( ) var nesting = &lint.EnumRule{ - Name: lint.NewRuleName(216, "nesting"), + Name: lint.NewRuleName(216, "nesting"), RuleType: lint.NewRuleType(lint.ShouldRule), OnlyIf: func(e *desc.EnumDescriptor) bool { return strings.HasSuffix(e.GetName(), "State") && e.GetName() != "State" diff --git a/rules/aep0216/nesting_test.go b/rules/aep0216/nesting_test.go index 1d52a98..ca2c109 100644 --- a/rules/aep0216/nesting_test.go +++ b/rules/aep0216/nesting_test.go @@ -30,7 +30,7 @@ func TestNesting(t *testing.T) { } `) if diff := (testutils.Problems{}).Diff(nesting.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) t.Run("NotNested", func(t *testing.T) { @@ -56,7 +56,7 @@ func TestNesting(t *testing.T) { `, test) e := f.GetEnumTypes()[0] if diff := test.problems.SetDescriptor(e).Diff(nesting.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0216/state_field_output_only.go b/rules/aep0216/state_field_output_only.go index 87b6b8b..69e8eaa 100644 --- a/rules/aep0216/state_field_output_only.go +++ b/rules/aep0216/state_field_output_only.go @@ -24,7 +24,7 @@ import ( ) var stateFieldOutputOnly = &lint.FieldRule{ - Name: lint.NewRuleName(216, "state-field-output-only"), + Name: lint.NewRuleName(216, "state-field-output-only"), RuleType: lint.NewRuleType(lint.MustRule), OnlyIf: func(f *desc.FieldDescriptor) bool { // We care about the name of the State enum type. diff --git a/rules/aep0216/state_field_output_only_test.go b/rules/aep0216/state_field_output_only_test.go index 806367f..53ef90f 100644 --- a/rules/aep0216/state_field_output_only_test.go +++ b/rules/aep0216/state_field_output_only_test.go @@ -76,7 +76,7 @@ func TestStateFieldOutputOnly(t *testing.T) { field := f.GetMessageTypes()[0].GetFields()[1] if diff := test.problems.SetDescriptor(field).Diff(stateFieldOutputOnly.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0216/synonyms.go b/rules/aep0216/synonyms.go index ff2104d..0974825 100644 --- a/rules/aep0216/synonyms.go +++ b/rules/aep0216/synonyms.go @@ -23,7 +23,7 @@ import ( ) var synonyms = &lint.EnumRule{ - Name: lint.NewRuleName(216, "synonyms"), + Name: lint.NewRuleName(216, "synonyms"), RuleType: lint.NewRuleType(lint.ShouldRule), LintEnum: func(e *desc.EnumDescriptor) []lint.Problem { if strings.HasSuffix(e.GetName(), "Status") { diff --git a/rules/aep0216/synonyms_test.go b/rules/aep0216/synonyms_test.go index 733738e..ebe9c26 100644 --- a/rules/aep0216/synonyms_test.go +++ b/rules/aep0216/synonyms_test.go @@ -39,7 +39,7 @@ func TestSynonyms(t *testing.T) { `, test) e := f.GetEnumTypes()[0] if diff := test.problems.SetDescriptor(e).Diff(synonyms.Lint(f)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/aep0216/value_synonyms.go b/rules/aep0216/value_synonyms.go index c624547..5dbe8c7 100644 --- a/rules/aep0216/value_synonyms.go +++ b/rules/aep0216/value_synonyms.go @@ -24,7 +24,7 @@ import ( ) var valueSynonyms = &lint.EnumValueRule{ - Name: lint.NewRuleName(216, "value-synonyms"), + Name: lint.NewRuleName(216, "value-synonyms"), RuleType: lint.NewRuleType(lint.ShouldRule), OnlyIf: func(v *desc.EnumValueDescriptor) bool { return strings.HasSuffix(v.GetEnum().GetName(), "State") diff --git a/rules/aep0216/value_synonyms_test.go b/rules/aep0216/value_synonyms_test.go index 4a7eccc..cb4e98a 100644 --- a/rules/aep0216/value_synonyms_test.go +++ b/rules/aep0216/value_synonyms_test.go @@ -46,7 +46,7 @@ func TestValueSynonyms(t *testing.T) { `, test) ev := file.GetEnumTypes()[0].GetValues()[1] if diff := test.problems.SetDescriptor(ev).Diff(valueSynonyms.Lint(file)); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/internal/utils/casing.go b/rules/internal/utils/casing.go index 43f25b1..8d24a12 100644 --- a/rules/internal/utils/casing.go +++ b/rules/internal/utils/casing.go @@ -37,7 +37,6 @@ func toCamelCase(s string, makeNextUpper bool, makeNextLower bool) string { } else if isUpper(r) { if makeNextLower { r = r | ' ' // make lowercase - makeNextLower = false } asLower = append(asLower, r) } else if isNumber(r) { diff --git a/rules/internal/utils/extension_test.go b/rules/internal/utils/extension_test.go index 34b3c25..1451d30 100644 --- a/rules/internal/utils/extension_test.go +++ b/rules/internal/utils/extension_test.go @@ -51,7 +51,7 @@ func TestGetFieldBehavior(t *testing.T) { t.Run(test.fieldName, func(t *testing.T) { f := msg.FindFieldByName(test.fieldName) if diff := cmp.Diff(GetFieldBehavior(f), test.fieldBehaviors); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -85,7 +85,7 @@ func TestGetMethodSignatures(t *testing.T) { `, test) method := f.GetServices()[0].GetMethods()[0] if diff := cmp.Diff(GetMethodSignatures(method), test.want); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } diff --git a/rules/internal/utils/http.go b/rules/internal/utils/http.go index 450e108..f3db766 100644 --- a/rules/internal/utils/http.go +++ b/rules/internal/utils/http.go @@ -25,7 +25,7 @@ import ( // HasHTTPRules returns true when the given method descriptor is annotated with // a google.api.http option. func HasHTTPRules(m *desc.MethodDescriptor) bool { - got := proto.GetExtension(m.GetMethodOptions(), apb.E_Http).(*apb.HttpRule) + got, _ := proto.GetExtension(m.GetMethodOptions(), apb.E_Http).(*apb.HttpRule) return got != nil } @@ -43,7 +43,7 @@ func GetHTTPRules(m *desc.MethodDescriptor) []*HTTPRule { // Get the "primary" rule (the direct google.api.http annotation). if x := proto.GetExtension(opts, apb.E_Http); x != nil { - httpRule := x.(*apb.HttpRule) + httpRule, _ := x.(*apb.HttpRule) if parsedRule := parseRule(httpRule); parsedRule != nil { rules = append(rules, parsedRule) diff --git a/rules/internal/utils/http_test.go b/rules/internal/utils/http_test.go index 6224461..7232984 100644 --- a/rules/internal/utils/http_test.go +++ b/rules/internal/utils/http_test.go @@ -122,7 +122,7 @@ func TestGetPlainURI(t *testing.T) { t.Run(test.name, func(t *testing.T) { rule := &HTTPRule{URI: test.uri} if diff := cmp.Diff(rule.GetPlainURI(), test.plainURI); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) } @@ -143,7 +143,7 @@ func TestGetVariables(t *testing.T) { t.Run(test.name, func(t *testing.T) { rule := &HTTPRule{URI: test.uri} if diff := cmp.Diff(rule.GetVariables(), test.vars); diff != "" { - t.Errorf(diff) + t.Error(diff) } }) }