Skip to content

Commit

Permalink
unused: remove exported-is-used option (#4890)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Jul 31, 2024
1 parent 5536bb5 commit 78a738f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
5 changes: 0 additions & 5 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3233,11 +3233,6 @@
"type": "boolean",
"default": false
},
"exported-is-used": {
"description": "",
"type": "boolean",
"default": true
},
"exported-fields-are-used": {
"description": "",
"type": "boolean",
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ type UnparamSettings struct {
type UnusedSettings struct {
FieldWritesAreUses bool `mapstructure:"field-writes-are-uses"`
PostStatementsAreReads bool `mapstructure:"post-statements-are-reads"`
ExportedIsUsed bool `mapstructure:"exported-is-used"`
ExportedIsUsed bool `mapstructure:"exported-is-used"` // Deprecated
ExportedFieldsAreUsed bool `mapstructure:"exported-fields-are-used"`
ParametersAreUsed bool `mapstructure:"parameters-are-used"`
LocalVariablesAreUsed bool `mapstructure:"local-variables-are-used"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ func (l *Loader) handleLinterOptionDeprecations() {
l.log.Warnf("The configuration option `linters.stylecheck.go` is deprecated, please use global `run.go`.")
}

// Deprecated since v1.60.0
if !l.cfg.LintersSettings.Unused.ExportedIsUsed {
l.log.Warnf("The configuration option `linters.unused.exported-is-used` is deprecated.")
}

// Deprecated since v1.58.0
if l.cfg.LintersSettings.SlogLint.ContextOnly {
l.log.Warnf("The configuration option `linters.sloglint.context-only` is deprecated, please use `linters.sloglint.context`.")
Expand Down
12 changes: 7 additions & 5 deletions pkg/golinters/unused/unused.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ func getUnusedResults(pass *analysis.Pass, settings *config.UnusedSettings) unus
opts := unused.Options{
FieldWritesAreUses: settings.FieldWritesAreUses,
PostStatementsAreReads: settings.PostStatementsAreReads,
ExportedIsUsed: settings.ExportedIsUsed,
ExportedFieldsAreUsed: settings.ExportedFieldsAreUsed,
ParametersAreUsed: settings.ParametersAreUsed,
LocalVariablesAreUsed: settings.LocalVariablesAreUsed,
GeneratedIsUsed: settings.GeneratedIsUsed,
// Related to https://github.com/golangci/golangci-lint/issues/4218
// https://github.com/dominikh/go-tools/issues/1474#issuecomment-1850760813
ExportedIsUsed: true,
ExportedFieldsAreUsed: settings.ExportedFieldsAreUsed,
ParametersAreUsed: settings.ParametersAreUsed,
LocalVariablesAreUsed: settings.LocalVariablesAreUsed,
GeneratedIsUsed: settings.GeneratedIsUsed,
}

// ref: https://github.com/dominikh/go-tools/blob/4ec1f474ca6c0feb8e10a8fcca4ab95f5b5b9881/internal/cmd/unused/unused.go#L68
Expand Down

0 comments on commit 78a738f

Please sign in to comment.