Skip to content

Conversation

alexandear
Copy link
Collaborator

This PR fixes a panic when running revive with the following configuration:

[rule.var-naming]
arguments = [[], [], [{ extra-bad-package-names = ["helpers", 123] }]]

Before:

./revive -config revive.toml ./...
panic: interface conversion: interface {} is int64, not string

goroutine 1 [running]:
github.com/mgechev/revive/rule.(*VarNamingRule).Configure(0x1053e2ec0, {0x140001d37d0, 0x3, 0xa?})
        /Users/alexandear/src/github.com/mgechev/revive/rule/var_naming.go:94 +0x554
github.com/mgechev/revive/config.GetLintingRules(0x140001cdab0, {0x10540a7e0, 0x0, 0x8?})
        /Users/alexandear/src/github.com/mgechev/revive/config/config.go:158 +0x3c8
github.com/mgechev/revive/revivelib.New(0x140001cdab0, 0x0, 0x0, {0x0, 0x0, 0x140000021c0?})
        /Users/alexandear/src/github.com/mgechev/revive/revivelib/core.go:56 +0x240
github.com/mgechev/revive/cli.RunRevive({0x0, 0x0, 0x0})
        /Users/alexandear/src/github.com/mgechev/revive/cli/main.go:55 +0x8c
main.main()
        /Users/alexandear/src/github.com/mgechev/revive/main.go:7 +0x28

After:

./revive -config revive.toml ./...
initializing revive - getting lint rules: cannot configure rule: "var-naming": invalid third argument to the var-naming rule: expected element 1 of extraBadPackageNames to be a string, but got type int64

Follows #1404

Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

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

Thanks for fixing, I was surprised to see the previous PR was removing the check on string slice,by assuming a slice of any would be OK

@mgechev mgechev merged commit 456cbd0 into mgechev:master Jun 20, 2025
8 checks passed
@alexandear alexandear deleted the var-naming-possible-panic branch June 20, 2025 11:11
@alexandear alexandear mentioned this pull request Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants