Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vet: enforce revive linter #7589

Merged
merged 8 commits into from
Sep 6, 2024

Conversation

purnesh42H
Copy link
Contributor

@purnesh42H purnesh42H commented Sep 4, 2024

Addresses: #7444

Enforce the revive linter with a configuration that enables only the rules that are already fixed, while keeping the rules that are yet to be fixed disabled. We will enable the remaining rules as we address and resolve them.

Recommended lint rules by revive (cover default golint rules) except empty-block

RELEASE NOTES: None

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.86%. Comparing base (c6ad07f) to head (528364b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7589      +/-   ##
==========================================
- Coverage   81.94%   81.86%   -0.08%     
==========================================
  Files         361      361              
  Lines       27813    27813              
==========================================
- Hits        22790    22768      -22     
- Misses       3832     3851      +19     
- Partials     1191     1194       +3     

see 18 files with indirect coverage changes

Comment on lines 25 to 28
# Disabled rules
[rule.empty-block]
Disabled = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have enough effective usages of empty-block, imo we should not bother about it at all.

Suggested change
# Disabled rules
[rule.empty-block]
Disabled = true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead can we add explicit disable for the fixes that are in flight. That way we can rebase this change, and remove that check as we fix them. Seems cleaner to me. That way we can avoid having to see all the linter error annotations on PRs

wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea. i modified to disable the rules that are yet to merged. Let me know if that looks good

scripts/revive.toml Show resolved Hide resolved
scripts/vet.sh Outdated
@@ -178,7 +178,7 @@ done

# Collection of revive linter analysis checks
REV_OUT="$(mktemp)"
revive -set_exit_status=1 -exclude "reflection/test/grpc_testing_not_regenerate/" -formatter plain ./... >"${REV_OUT}" || true
revive -set_exit_status=1 -exclude "reflection/test/grpc_testing_not_regenerate/" -formatter plain -config "$(dirname "$0")/revive.toml" ./... >"${REV_OUT}" || true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely combine lines 180-184 to be something like:

Suggested change
revive -set_exit_status=1 -exclude "reflection/test/grpc_testing_not_regenerate/" -formatter plain -config "$(dirname "$0")/revive.toml" ./... >"${REV_OUT}" || true
revive \
-set_exit_status=1 \
-exclude "reflection/test/grpc_testing_not_regenerate/" \
-exclude "**/*.pb.go" \
-config "$(dirname "$0")/revive.toml" \
./...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@arvindbr8 arvindbr8 assigned purnesh42H and unassigned arvindbr8 Sep 4, 2024
@purnesh42H purnesh42H changed the title vet: enable recommended lint rules and disable empty-block using revive config vet: enforce revive linter Sep 5, 2024
@purnesh42H purnesh42H requested a review from arvindbr8 September 5, 2024 05:13
@purnesh42H purnesh42H assigned arvindbr8 and unassigned purnesh42H Sep 5, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert these changes from this pr and add it to #7575

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

scripts/revive.toml Show resolved Hide resolved
@purnesh42H purnesh42H force-pushed the skip-revive-empty-block branch from 3f90caf to dad9ef0 Compare September 6, 2024 15:30
rpc_util.go Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed to comment on this file in the last pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too :)

@purnesh42H purnesh42H force-pushed the skip-revive-empty-block branch from dad9ef0 to ba338c1 Compare September 6, 2024 15:36
Copy link
Member

@arvindbr8 arvindbr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, i last comment

[rule.exported]
Disabled = true # TODO: Enable after existing issues are fixed
[rule.redefines-builtin-id]
Disabled = true # TODO: Enable after existing issues are fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@purnesh42H purnesh42H force-pushed the skip-revive-empty-block branch from 88f4e34 to 9f7d269 Compare September 6, 2024 15:41
@purnesh42H purnesh42H added Type: Meta Github repo, process, etc Area: Tooling Includes anything related to Go builds, modules etc and includes Releases & Github Workflows. labels Sep 6, 2024
@purnesh42H purnesh42H added this to the 1.67 Release milestone Sep 6, 2024
@purnesh42H purnesh42H assigned purnesh42H and unassigned arvindbr8 and dfawley Sep 6, 2024
@purnesh42H purnesh42H merged commit 5666049 into grpc:master Sep 6, 2024
14 checks passed
@purnesh42H purnesh42H mentioned this pull request Sep 14, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Tooling Includes anything related to Go builds, modules etc and includes Releases & Github Workflows. Type: Meta Github repo, process, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants