Skip to content
Open
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
2 changes: 2 additions & 0 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ linters:
- interfacebloat
- intrange
- iotamixing
- iotyper
- ireturn
- lll
- loggercheck
Expand Down Expand Up @@ -192,6 +193,7 @@ linters:
- interfacebloat
- intrange
- iotamixing
- iotyper
- ireturn
- lll
- loggercheck
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/Antonboom/nilnil v1.1.1
github.com/Antonboom/testifylint v1.6.4
github.com/BurntSushi/toml v1.5.0
github.com/CyberAgent/iotyper-lint v0.0.0-20251126071057-12b4d357612a
github.com/Djarvur/go-err113 v0.1.1
github.com/MirrexOne/unqueryvet v1.3.0
github.com/OpenPeeDeeP/depguard/v2 v2.2.1
Expand Down Expand Up @@ -218,7 +219,7 @@ require (
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/exp/typeparams v0.0.0-20251023183803-a4bb9ffd2546 // indirect
golang.org/x/text v0.30.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
google.golang.org/protobuf v1.36.8 // indirect
Expand Down
19 changes: 12 additions & 7 deletions go.sum

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

13 changes: 13 additions & 0 deletions pkg/golinters/iotyper/iotyper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package iotyper

import (
"github.com/CyberAgent/iotyper-lint"

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

func New() *goanalysis.Linter {
return goanalysis.
NewLinterFromAnalyzer(iotyper.Analyzer).
WithLoadMode(goanalysis.LoadModeSyntax)
}
11 changes: 11 additions & 0 deletions pkg/golinters/iotyper/iotyper_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package iotyper

import (
"testing"

"github.com/golangci/golangci-lint/v2/test/testshared/integration"
)

func TestFromTestdata(t *testing.T) {
integration.RunTestdata(t)
}
45 changes: 45 additions & 0 deletions pkg/golinters/iotyper/testdata/iotyper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//golangcitest:args -Eiotyper
package testdata

// Basic iota without type
const (
BasicWithoutType = iota // want "iota used without type specification"
)

// Single-line const declarations
const SingleLineWithoutType = iota // want "iota used without type specification"
const SingleLineWithType int = iota // OK: has type

// Multiple constants with inherited iota
const (
FirstInGroup = iota // want "iota used without type specification"
SecondInGroup // No warning: inherits iota value but doesn't use iota directly
ThirdInGroup // No warning: same as above
)

// Non-iota constants (no warnings expected)
const (
PlainNumber = 42
PlainString = "hello"
PlainBool = true
)

// iota in expressions
const (
IotaPlusOne = iota + 1 // want "iota used without type specification"
IotaShifted = 1 << iota // want "iota used without type specification"
IotaMultiple = iota * 2 // want "iota used without type specification"
)

// iota with explicit type
const (
WithTypeInt int = iota // OK: explicit int type
WithTypeIntAgain int = iota // OK: explicit int type
)

// Mixed type specifications
const (
MixedWithType int = iota // OK: has type
MixedWithoutType = iota // want "iota used without type specification"
MixedAgainWithType int = iota // OK: has type
)
5 changes: 5 additions & 0 deletions pkg/lint/lintersdb/builder_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import (
"github.com/golangci/golangci-lint/v2/pkg/golinters/interfacebloat"
"github.com/golangci/golangci-lint/v2/pkg/golinters/intrange"
"github.com/golangci/golangci-lint/v2/pkg/golinters/iotamixing"
"github.com/golangci/golangci-lint/v2/pkg/golinters/iotyper"
"github.com/golangci/golangci-lint/v2/pkg/golinters/ireturn"
"github.com/golangci/golangci-lint/v2/pkg/golinters/lll"
"github.com/golangci/golangci-lint/v2/pkg/golinters/loggercheck"
Expand Down Expand Up @@ -457,6 +458,10 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
WithSince("v2.5.0").
WithURL("https://github.com/AdminBenni/iota-mixing"),

linter.NewConfig(iotyper.New()).
WithSince("v2.7.0").
WithURL("https://github.com/CyberAgent/iotyper-lint"),

linter.NewConfig(ireturn.New(&cfg.Linters.Settings.Ireturn)).
WithSince("v1.43.0").
WithLoadForGoAnalysis().
Expand Down