Skip to content

Linting code base with 1.6 panics while 1.5.1 worked #1217

Closed
@ChristianWieck

Description

@ChristianWieck

Describe the bug
When linting our code base with 1.6 a panic is raised. Linting the same code base with 1.5.1 worked without any problems.

To Reproduce
Steps to reproduce the behavior:

  1. I updated revive go install github.com/mgechev/revive@latest
  2. I run it with the following flags & configuration file:
revive -config revive_config.toml -formatter friendly -set_exit_status ./...
TOML
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0

# Configuration of the `cyclomatic` rule. Here we specify that
# the rule should fail if it detects code with higher complexity than 10.
[rule.cyclomatic]
arguments = [15]

# [rule.add-constant]
# arguments = [
#     { maxLitCount = "3", allowStrs = "\"\"", allowInts = "0,1,2", allowFloats = "0.0,0.,1.0,1.,2.0,2.", ignoreFuncs = "os\\.*,fmt\\.Println,make,Test\\.*,Benchmark\\.*" },
# ]
[rule.atomic] # Prevent misuse of atomic.Value
[rule.banned-characters] # Prevents the use of certain characters in identifiers
arguments = ["Ω", "Σ", "σ"]
[rule.bare-return] # Prevents the use of naked returns
[rule.blank-imports]
[rule.bool-literal-in-expr]
[rule.comment-spacings]
[rule.confusing-naming]
[rule.confusing-results]
[rule.constant-logical-expr]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.datarace]
[rule.deep-exit]
[rule.defer]
[rule.dot-imports]
[rule.duplicated-imports]
[rule.early-return]
[rule.empty-block]
[rule.empty-lines]
[rule.enforce-map-style]
arguments = ["make"]
[rule.enforce-repeated-arg-type-style]
arguments = []
[rule.enforce-slice-style]
arguments = ["make"]
[rule.error-naming]
[rule.error-return]
[rule.error-strings]
[rule.errorf]
# [rule.exported]
[rule.function-result-limit]
arguments = [3]
[rule.get-return]
[rule.identical-branches]
[rule.if-return]
[rule.increment-decrement]
[rule.indent-error-flow]
[rule.line-length-limit]
arguments = [100]
[rule.modifies-parameter]
[rule.modifies-value-receiver]
[rule.nested-structs]
[rule.optimize-operands-order]
[rule.range]
[rule.receiver-naming]
[rule.redefines-builtin-id]
[rule.string-of-int]
[rule.superfluous-else]
[rule.time-equal]
[rule.time-naming]
[rule.unchecked-type-assertion]
[rule.unconditional-recursion]
[rule.unexported-naming]
[rule.unexported-return]
[rule.unnecessary-stmt]
[rule.unreachable-code]
[rule.unused-parameter]
[rule.unused-receiver]
[rule.use-any]
[rules.use-errors-new]
[rules.useless-break]
[rule.var-declaration]
[rule.var-naming]
[rule.waitgroup-by-value]

Expected behavior
Liniting shouldn't panic as with 1.5.1

Logs
Stacktrace

panic: not supported type *ast.IndexExpr

goroutine 42 [running]:
github.com/mgechev/revive/internal/astutils.getFieldTypeName({0x965038?, 0xc000558360?})
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/internal/astutils/ast_utils.go:75 +0x145
github.com/mgechev/revive/internal/astutils.getTypeNames(0x30?)
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/internal/astutils/ast_utils.go:52 +0xac
github.com/mgechev/revive/internal/astutils.FuncSignatureIs(0xc0004ca720, {0x8af5de?, 0xc0000c1938?}, {0xc0004adaf0, 0x2, 0x46d198?}, {0xc0004adae8, 0x0, 0xc0004adb50?})
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/internal/astutils/ast_utils.go:19 +0x8d
github.com/mgechev/revive/lint.getSortableMethodFlagForFunction(0xc0004ca720)
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/lint/package.go:213 +0x165
github.com/mgechev/revive/lint.(*Package).scanSortable(0xc000696000)
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/lint/package.go:173 +0x2fa
github.com/mgechev/revive/lint.(*Package).lint(0xc000696000, {0xc0000ed688, 0x39, 0x47}, {0x0, 0x3fe999999999999a, {0xc000038d2a, 0x7}, 0x0, 0xc0001d7d70, ...}, ...)
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/lint/package.go:186 +0x47
github.com/mgechev/revive/lint.(*Linter).lintPackage(0xc0001f9c20, {0xc0001f9b50, 0x1, 0x0?}, 0xc000397db0, {0xc0000ed688, 0x39, 0x47}, {0x0, 0x3fe999999999999a, ...}, ...)
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/lint/linter.go:158 +0x35b
github.com/mgechev/revive/lint.(*Linter).Lint.func1()
        /home/cw/go/pkg/mod/github.com/mgechev/[email protected]/lint/linter.go:109 +0xa5
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /home/cw/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
        /home/cw/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96

Desktop (please complete the following information):

  • OS: WSL-2 and Ubuntu 22.04
  • Go: 1.23.4

Additional context
Unfortunatly I'm unable to share the code which causes the error as it's company intern. If you have any concrete questions, I might be able to provide extracts from it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions