Skip to content

Commit

Permalink
build(deps): bump github.com/maratori/testpackage from 1.0.1 to 1.1.0 (
Browse files Browse the repository at this point in the history
…golangci#2945)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
2 people authored and sivchari committed Jun 28, 2022
1 parent 3a0f646 commit 8de59a3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -155,6 +155,7 @@ require (
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/sivchari/nosnakecase v1.0.1
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
8 changes: 2 additions & 6 deletions go.sum

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

19 changes: 19 additions & 0 deletions pkg/golinters/nosnakecase.go
@@ -0,0 +1,19 @@
package golinters

import (
"github.com/sivchari/nosnakecase"
"golang.org/x/tools/go/analysis"

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

func NewNoSnakeCase() *goanalysis.Linter {
a := nosnakecase.Analyzer

return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeSyntax)
}
5 changes: 5 additions & 0 deletions pkg/lint/lintersdb/manager.go
Expand Up @@ -631,6 +631,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle).
WithURL("https://github.com/firefart/nonamedreturns"),

linter.NewConfig(golinters.NewNoSnakeCase()).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sivchari/nosnakecase"),

linter.NewConfig(golinters.NewNoSprintfHostPort()).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle).
Expand Down
18 changes: 18 additions & 0 deletions test/testdata/nosnakecase.go
@@ -0,0 +1,18 @@
// args: -Enosnakecase
package testdata

func a_() { // ERROR "a_ is used under score. You should use mixedCap or MixedCap."
}

func b(a_a int) { // ERROR "a_a is used under score. You should use mixedCap or MixedCap."
}

func c() (c_c int) { // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
c_c = 1 // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
return c_c // It's never detected, because `c_c` is already detected.
}

func d() {
var d_d int // ERROR "d_d is used under score. You should use mixedCap or MixedCap."
_ = d_d // It's never detected, because `_` is meaningful in Go and `d_d` is already detected.
}

0 comments on commit 8de59a3

Please sign in to comment.