Skip to content

enforce nolint scope #34851

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

TheFox0x7
Copy link
Contributor

enable nolintlint scope requirement
add comments to new directives so it's more obvious why they are in place


I can also toggle the mandatory comments on if that's something of interest.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 24, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations modifies/internal labels Jun 24, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 24, 2025
Copy link
Member

@silverwind silverwind left a comment

Choose a reason for hiding this comment

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

Nice work. Resolve comments above before merge.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 25, 2025
@@ -10,9 +10,9 @@ import (
)

func TestCleanUploadFileName(t *testing.T) {
assert.Empty(t, CleanGitTreePath(""))
assert.Empty(t, CleanGitTreePath("."))
assert.Equal(t, "", CleanGitTreePath("")) //nolint:testifylint // for readability and alignment
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, adding comments make it harder to read ...

I can help to rewrite the code to something like

for testCase := range cases {
    assert.Equal(....)
}

(if you don't mind)

Then we can get rid of the "nolint" tricks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go ahead, the maintainer edit thing is checked :)

Copy link
Member

@silverwind silverwind Jun 25, 2025

Choose a reason for hiding this comment

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

Yes, eliminating nolints is better. I think something ought to be done about the migration packages too. Maybe just a config in .golangci.yml that disables revive for those files, but it's a pretty broad disable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are fixable with a rename. I don't suppose that's breaking as migrations are internal and I'd be surprised if something in our code relied on package name. It's more of an issue of what name should there be.
There's also not much benefit in that and the _ rule could be suppressed globally (to cover oauth_* as well) or for migrations only.
See text based rules which I think would work for this

Copy link
Member

@silverwind silverwind Jun 25, 2025

Choose a reason for hiding this comment

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

Which specific revive rule is being triggered by these underscores? Maybe we can disable the rule itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

var-naming: don't use an underscore in package name

Copy link
Member

@silverwind silverwind Jun 25, 2025

Choose a reason for hiding this comment

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

I'd vote for disabling var-naming completely. This is the kind of rule I don't want to have because it's stylistic. Focus of linting should be primary in finding bugs, not style issues.

Copy link
Member

@silverwind silverwind Jun 25, 2025

Choose a reason for hiding this comment

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

Alternatively, just disabling package name checks should also work:

linters:
  settings:
    revive:
      rules:
        - name: var-naming
          arguments:
            - skip-package-name-checks: true

Copy link
Member

Choose a reason for hiding this comment

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

Maybe better overall to disable var-naming completely. @TheFox0x7 would you like to do it in this PR or we merge this and do it in another.

@wxiaoguang
Copy link
Contributor

Made some changes:

  • rewrite TestCleanUploadFileName, no "nolint" now
  • shorten some comments since we have used "nolint" then "it shouldn't be an issue"
    • "underscore in migration packages isn't a large issue" -> "version underscore"
    • " export stutter, not a large issue" -> " export stutter"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/internal modifies/migrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants