Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to avoid undersore in var names #834

Merged
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
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ linters:
- prealloc
- predeclared
- reassign
- revive
- testifylint
linters-settings:
revive:
enable-all-rules: false
rules:
- name: 'var-naming'
staticcheck:
checks:
- all
Expand All @@ -34,3 +39,8 @@ linters-settings:
- empty
- expected-actual
- len
issues:
exclude-rules:
- linters:
- revive
text: "var-naming: don't use an underscore in package name"
16 changes: 8 additions & 8 deletions cmd/mockery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ func TestNewRootCmd(t *testing.T) {
func Test_initConfig(t *testing.T) {
tests := []struct {
name string
base_path string
basePath string
configPath string
}{
{
name: "test config at base directory",
base_path: "1/2/3/4",
basePath: "1/2/3/4",
configPath: "1/2/3/4/.mockery.yaml",
},
{
name: "test config at upper directory",
base_path: "1/2/3/4",
basePath: "1/2/3/4",
configPath: "1/.mockery.yaml",
},
{
name: "no config file found",
base_path: "1/2/3/4",
name: "no config file found",
basePath: "1/2/3/4",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tmpDir := pathlib.NewPath(t.TempDir())
baseDir := tmpDir.Join(strings.Split(tt.base_path, "/")...)
baseDir := tmpDir.Join(strings.Split(tt.basePath, "/")...)
require.NoError(t, baseDir.MkdirAll())

configPath := pathlib.NewPath("")
Expand Down Expand Up @@ -164,15 +164,15 @@ packages:
goModPath := pathlib.NewPath(tmpDir).Join("go.mod")
err := goModPath.WriteFile([]byte(`
module github.com/testuser/testpackage

go 1.20`))
require.NoError(t, err)

interfacePath := pathlib.NewPath(tmpDir).Join("internal", "foopkg", "interface.go")
require.NoError(t, interfacePath.Parent().MkdirAll())
require.NoError(t, interfacePath.WriteFile([]byte(`
package foopkg

type FooInterface interface {
Foo()
Bar()
Expand Down
2 changes: 1 addition & 1 deletion pkg/fixtures/requester_unexported.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package test

type requester_unexported interface {
type requesterUnexported interface {
Get()
}
2 changes: 1 addition & 1 deletion pkg/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (s *GeneratorSuite) TestGeneratorNoNothing() {
}

func (s *GeneratorSuite) TestGeneratorUnexported() {
s.checkGeneration("requester_unexported.go", "requester_unexported", true, "", "")
s.checkGeneration("requester_unexported.go", "requesterUnexported", true, "", "")
}

func (s *GeneratorSuite) TestGeneratorPrologue() {
Expand Down
5 changes: 3 additions & 2 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const (
LogKeyPath = "path"
LogKeyQualifiedName = "qualified-name"
LogKeyPackageName = "package-name"
_defaultSemVer = "v0.0.0-dev"

defaultSemVer = "v0.0.0-dev"
)

// SemVer is the version of mockery at build time.
Expand All @@ -38,7 +39,7 @@ func GetSemverInfo() string {
if ok && version.Main.Version != "(devel)" && version.Main.Version != "" {
return version.Main.Version
}
return _defaultSemVer
return defaultSemVer
}

func getMinorSemver(semver string) string {
Expand Down
Loading