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

unused: remove exported-is-used option #4890

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Conversation

ldez
Copy link
Member

@ldez ldez commented Jul 31, 2024

Fixes #4218

@ldez ldez added bug Something isn't working linter: update Update the linter implementation inside golangci-lint labels Jul 31, 2024
@ldez ldez added this to the next milestone Jul 31, 2024
@ldez ldez force-pushed the fix/remove-option branch from 91c6b17 to e923c3a Compare July 31, 2024 15:10
Copy link
Member

@bombsimon bombsimon left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -90,7 +90,7 @@ func getUnusedResults(pass *analysis.Pass, settings *config.UnusedSettings) unus
opts := unused.Options{
FieldWritesAreUses: settings.FieldWritesAreUses,
PostStatementsAreReads: settings.PostStatementsAreReads,
ExportedIsUsed: settings.ExportedIsUsed,
ExportedIsUsed: 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 you said befor that you want golangci-lint to have its own default but since this stems from a bug where we're deviating from upstream, are you considering using the value from the DefaultConfig in unused?

I know it probably doesn't make any difference now but it serves some kind of documentation purpose and will follow any changes made upstream.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this context, we are forced to override the value to be sure that this value is always true.
I will not use unused.DefaultOptions.ExportedIsUsed because it can be mutated by unused itself (because it's a global variable), or the default value can be changed by unused (this is a problem for us).
I added a comment to reference the issue.

@ldez ldez changed the title fix: remove exported-is-used option (unused) unused: remove exported-is-used option Jul 31, 2024
@ldez ldez force-pushed the fix/remove-option branch from ab05194 to 234cf8d Compare July 31, 2024 23:04
@ldez ldez merged commit 78a738f into golangci:master Jul 31, 2024
16 checks passed
@ldez ldez deleted the fix/remove-option branch July 31, 2024 23:34
@ldez ldez modified the milestones: next, v1.60 Aug 14, 2024
uudashr pushed a commit to uudashr/golangci-lint that referenced this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linter: update Update the linter implementation inside golangci-lint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unused doesn't work with "exported-is-used" and "exported-fields-are-used" linter settings
2 participants