grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

Add godoc linter

Open dfawley opened this issue 1 year ago • 17 comments

Since removing golint, we've had numerous occasions of missing docstrings. This seems like the consensus replacement for golint: https://github.com/mgechev/revive -- we should set it up to at least check the docstrings.

EDIT:

  • [x] add the Revive inter in quite mode: https://github.com/grpc/grpc-go/pull/7472**

  • [x] Enforce Revive Linter: #7589

  • [ ] fix below existing lint issues and enable the disabled rule

#7575 fixes

  • [ ] 83 exported

#7574 fixes

  • [x] 8 package-comments

#7552 fixes

  • [ ] 15 redefines-builtin-id

#7528 fixes

  • [x] 6 var-declaration
  • [x] 3 indent-error-flow
  • [x] 1 increment-decrement
  • [x] 1 superfluous-else

#7577 #7580 fixes

  • [x] 546 unused-parameter
  • [x] 28 var-naming (Ignore reflection/test/grpc_testing_not_regenerate/)
  • [x] 1 context-as-argument (Ignore reflection/test/grpc_testing_not_regenerate/)

dfawley avatar Jul 26 '24 16:07 dfawley

Before we enforce revive, we need to fix existing lint issues caught in #7472 as part of vet check.

Its fine to change several files in a single PR if they all fix one type of issue or are otherwise related. However, be reasonable and try to keep the PRs small enough to make it not take a long time to review and avoid merge conflicts.

purnesh42H avatar Aug 02 '24 16:08 purnesh42H

@purnesh42H Please assign me this issue.

janardhanvissa avatar Aug 09 '24 09:08 janardhanvissa

@purnesh42H Right now, In the tests (vet) I'm getting like don't use an underscore in package name https://revive.run/r#var-naming. It's not expecting underscore but by default as it's generating from the proto file like ("google.golang.org/grpc/reflection/test/grpc_testing_not_regenerate"). So, what need to do for further. Please suggest.

janardhanvissa avatar Aug 12 '24 06:08 janardhanvissa

@purnesh42H Fixed some of the godoc-linter issues. Please review and let me know if any changes are required. Please find the PR below. https://github.com/grpc/grpc-go/pull/7501

janardhanvissa avatar Aug 12 '24 14:08 janardhanvissa

@purnesh42H Fixed linter issues for superfluous-else, increment-decrement, indent-error-flow, var-declaration. Please review the changes.

https://github.com/janardhanvissa/grpc-go/pull/1

janardhanvissa avatar Aug 14 '24 09:08 janardhanvissa

@purnesh42H Fixed below godoc linter issues. Please find the PRs below. Please let me know if any changes are required.

15 redefines-builtin-id
8 package-comments
8 empty-block
6 var-declaration
3 indent-error-flow
2 increment-decrement
1 superfluous-else

https://github.com/janardhanvissa/grpc-go/pull/1 https://github.com/janardhanvissa/grpc-go/pull/2 https://github.com/janardhanvissa/grpc-go/pull/3

janardhanvissa avatar Aug 16 '24 09:08 janardhanvissa

@purnesh42H Fixed linter issues for superfluous-else, increment-decrement, indent-error-flow, var-declaration. Please review the changes.

janardhanvissa#1

Thanks. LGTM. Please open the. PR in main repo.

purnesh42H avatar Aug 16 '24 19:08 purnesh42H

@purnesh42H Fixed below godoc linter issues and raised a PR to main repo.

6 var-declaration 3 indent-error-flow 2 increment-decrement 1 superfluous-else

janardhanvissa avatar Aug 18 '24 07:08 janardhanvissa

@purnesh42H Fixed below godoc revive linter issues and raised a PR to main repo. Please find the PR below.

https://github.com/grpc/grpc-go/pull/7532

  • 15 redefines-builtin-id
  • 8 package-comments
  • 8 empty-block

janardhanvissa avatar Aug 19 '24 11:08 janardhanvissa

@purnesh42H Fixed below godoc revive linter issues and raised a PR to main repo. Please find the PR below.

https://github.com/grpc/grpc-go/pull/7550

  • 8 package-comments

janardhanvissa avatar Aug 22 '24 10:08 janardhanvissa

@purnesh42H Fixed below godoc revive linter issues and raised a PR to main repo. Please find the PR below.

https://github.com/grpc/grpc-go/pull/7552

  • 8 empty-block
  • 15 redefines-builtin-id

janardhanvissa avatar Aug 22 '24 19:08 janardhanvissa

@purnesh42H Facing issue in context-as-argument(context.Context) should be the first parameter. Please have a look at the readme file (reflection/test/grpc_testing_not_regenerate/README.md), as the testv3.go is generated from the older version of v3. So, once we are updating and tried to generate the proto and this testv3 we are facing undefined function or var in other dependencies. It points to some external dependency with testv3 so any change in testv3 will have an impact which is not in our scope. Because it's imported from another repo. Suggest what we need to do to resolve this issue. If we are going to regenerate the testv3.proto file we need to delete the testv3.go and then regenerate. Then it will impact other dependency files like dynamic.go

janardhanvissa avatar Aug 26 '24 06:08 janardhanvissa

@purnesh42H Raised a separate PRs in forked branch. Please review the changes. Please find the PRs below.

https://github.com/janardhanvissa/grpc-go/pull/6 https://github.com/janardhanvissa/grpc-go/pull/7

janardhanvissa avatar Aug 29 '24 08:08 janardhanvissa

#7577 fixes:

546 unused-parameter (ignored)

and renamed the check again

cc: @purnesh42H

arvindbr8 avatar Aug 30 '24 17:08 arvindbr8

@janardhanvissa can you do these since we include unused-parameter now

gcp/observability/logging_test.go:592:20: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:592:41: parameter 'in' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:653:28: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:653:49: parameter 'config' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:676:20: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:676:41: parameter 'in' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:790:28: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:790:49: parameter 'config' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:825:20: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:825:41: parameter 'in' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:828:20: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:828:41: parameter 'in' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1128:28: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1128:49: parameter 'config' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1152:20: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1152:41: parameter 'in' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1252:28: parameter 'ctx' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter
gcp/observability/logging_test.go:1252:49: parameter 'config' seems to be unused, consider removing or renaming it as _ https://revive.run/r#unused-parameter

purnesh42H avatar Aug 30 '24 20:08 purnesh42H

@purnesh42H Fixed above mentioned unused parameter linter issues and pushed the changes.

janardhanvissa avatar Aug 31 '24 03:08 janardhanvissa

Adding this here for context:

https://github.com/grpc/grpc-go/pull/7552#issuecomment-2327328750

Based on the discussion, we have sufficient cases where having an empty block is justifiable, so it's reasonable to include an "empty-block" check within the revive tool.

arvindbr8 avatar Sep 03 '24 20:09 arvindbr8