Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,11 @@ linters:
# Default: false
skip-single-param: true

ineffassign:
# Check escaping variables of type error, may cause false positives.
# Default: false
check-escaping-errors: true

interfacebloat:
# The maximum number of methods allowed for an interface.
# Default: 10
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/golangci/revgrep v0.8.0
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e
github.com/gordonklaus/ineffassign v0.1.0
github.com/gordonklaus/ineffassign v0.2.0
github.com/gostaticanalysis/forcetypeassert v0.2.0
github.com/gostaticanalysis/nilerr v0.1.1
github.com/hashicorp/go-version v1.7.0
Expand Down
5 changes: 2 additions & 3 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,17 @@
}
}
},
"ineffassignSettings": {
"type": "object",
"additionalProperties": false,
"properties": {
"check-escaping-errors": {
"description": "Check escaping variables of type error, may cause false positives.",
"type": "boolean",
"default": false
}
}
},
"ireturnSettings": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -4567,6 +4578,9 @@
"inamedparam": {
"$ref": "#/definitions/settings/definitions/inamedparamSettings"
},
"ineffassign": {
"$ref": "#/definitions/settings/definitions/ineffassignSettings"
},
"ireturn": {
"$ref": "#/definitions/settings/definitions/ireturnSettings"
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ type LintersSettings struct {
Iface IfaceSettings `mapstructure:"iface"`
ImportAs ImportAsSettings `mapstructure:"importas"`
Inamedparam INamedParamSettings `mapstructure:"inamedparam"`
Ineffassign IneffassignSettings `mapstructure:"ineffassign"`
InterfaceBloat InterfaceBloatSettings `mapstructure:"interfacebloat"`
Ireturn IreturnSettings `mapstructure:"ireturn"`
Lll LllSettings `mapstructure:"lll"`
Expand Down Expand Up @@ -644,6 +645,10 @@ type INamedParamSettings struct {
SkipSingleParam bool `mapstructure:"skip-single-param"`
}

type IneffassignSettings struct {
CheckEscapingErrors bool `mapstructure:"check-escaping-errors"`
}

type InterfaceBloatSettings struct {
Max int `mapstructure:"max"`
}
Expand Down
13 changes: 11 additions & 2 deletions pkg/golinters/ineffassign/ineffassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ package ineffassign
import (
"github.com/gordonklaus/ineffassign/pkg/ineffassign"

"github.com/golangci/golangci-lint/v2/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
)

func New() *goanalysis.Linter {
func New(settings *config.IneffassignSettings) *goanalysis.Linter {
var cfg map[string]any

if settings != nil {
cfg = map[string]any{
"check-escaping-errors": settings.CheckEscapingErrors,
}
}

return goanalysis.
NewLinterFromAnalyzer(ineffassign.Analyzer).
WithDesc("Detects when assignments to existing variables are not used").
WithConfig(cfg).
WithLoadMode(goanalysis.LoadModeSyntax)
}
2 changes: 1 addition & 1 deletion pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v1.55.0").
WithURL("https://github.com/macabu/inamedparam"),

linter.NewConfig(ineffassign.New()).
linter.NewConfig(ineffassign.New(&cfg.Linters.Settings.Ineffassign)).
WithGroups(config.GroupStandard).
WithSince("v1.0.0").
WithURL("https://github.com/gordonklaus/ineffassign"),
Expand Down
3 changes: 2 additions & 1 deletion scripts/website/expand_templates/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bytes"
"fmt"
"log"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -248,7 +249,7 @@ func (e *ExampleSnippetsExtractor) getSettingSections(node, nextNode *yaml.Node)
settings, ok := allNodes[lc.Name]
if !ok {
if hasSettings(lc.Name) {
return nil, fmt.Errorf("can't find %s settings in .golangci.reference.yml", lc.Name)
log.Printf("can't find %s settings in .golangci.reference.yml", lc.Name)
}

continue
Expand Down
Loading