Skip to content

Commit

Permalink
address lint warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Fitzgerald <[email protected]>
  • Loading branch information
joefitzgerald committed Nov 17, 2023
1 parent 5200360 commit de30453
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run:
skip-dirs:
- fixtures
12 changes: 6 additions & 6 deletions generated_fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func testFakes(t *testing.T, when spec.G, it spec.S) {
it("records the arguments it was called with", func() {
Expect(fake.DoThingsCallCount()).To(Equal(0))

fake.DoThings("stuff", 5)
_, _ = fake.DoThings("stuff", 5)

Expect(fake.DoThingsCallCount()).To(Equal(1))
arg1, arg2 := fake.DoThingsArgsForCall(0)
Expand Down Expand Up @@ -147,7 +147,7 @@ func testFakes(t *testing.T, when spec.G, it spec.S) {
Expect(len(fake.Invocations()["DoASlice"])).To(Equal(0))
Expect(len(fake.Invocations()["DoAnArray"])).To(Equal(0))

fake.DoThings("hello", 0)
_, _ = fake.DoThings("hello", 0)
Expect(len(fake.Invocations()["DoThings"])).To(Equal(1))
Expect(fake.Invocations()["DoThings"][0][0]).To(Equal("hello"))
Expect(fake.Invocations()["DoThings"][0][1]).To(Equal(uint64(0)))
Expand Down Expand Up @@ -190,7 +190,7 @@ func testFakes(t *testing.T, when spec.G, it spec.S) {

go fake.DoNothing()
<-start1
go fake.DoThings("abc", 1)
go func() { _, _ = fake.DoThings("abc", 1) }()
<-start2
})

Expand All @@ -211,7 +211,7 @@ func testFakes(t *testing.T, when spec.G, it spec.S) {
when("when methods are called concurrently", func() {
it.Before(func() {
go fake.DoNothing()
go fake.DoThings("", 0)
go func() { _, _ = fake.DoThings("", 0) }()
})

it("records the call count without race conditions", func() {
Expand Down Expand Up @@ -297,9 +297,9 @@ func testFakes(t *testing.T, when spec.G, it spec.S) {

it("succeeds and does not cause a data race", func() {
go fake.DoThingsReturns(1, nil)
go fake.DoThings("1", 1)
go func() { _, _ = fake.DoThings("1", 1) }()
go fake.DoThingsReturns(1, nil)
go fake.DoThings("1", 1)
go func() { _, _ = fake.DoThings("1", 1) }()
})
})
}
Expand Down
7 changes: 6 additions & 1 deletion generator/interface_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ package generator
import (
"strings"
"text/template"

"golang.org/x/text/cases"
"golang.org/x/text/language"
)

var title = cases.Title(language.Und, cases.NoLower)

var interfaceFuncs = template.FuncMap{
"ToLower": strings.ToLower,
"UnExport": unexport,
"Replace": strings.Replace,
"IsExported": isExported,
"Title": strings.Title,
"Title": title.String,
}

const interfaceTemplate string = `{{.Header}}// Code generated by counterfeiter. DO NOT EDIT.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/maxbrunsfeld/counterfeiter/v6
require (
github.com/onsi/gomega v1.30.0
github.com/sclevine/spec v1.4.0
golang.org/x/text v0.14.0
golang.org/x/tools v0.15.0
)

Expand All @@ -11,7 +12,6 @@ require (
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
12 changes: 10 additions & 2 deletions integration/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package integration_test

import (
"io"
"io/ioutil"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -69,10 +69,18 @@ func dcopy(srcdir, destdir string, info os.FileInfo) error {
return err
}

contents, err := ioutil.ReadDir(srcdir)
entries, err := os.ReadDir(srcdir)
if err != nil {
return err
}
contents := make([]fs.FileInfo, 0, len(entries))
for _, entry := range entries {
info, err := entry.Info()
if err != nil {
return err
}
contents = append(contents, info)
}

for _, content := range contents {
cs, cd := filepath.Join(srcdir, content.Name()), filepath.Join(destdir, content.Name())
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func printCode(code []byte, outputPath string, printToStdOut bool) error {
fmt.Println(string(formattedCode))
return nil
}
os.MkdirAll(filepath.Dir(outputPath), 0777)
_ = os.MkdirAll(filepath.Dir(outputPath), 0777)
file, err := os.Create(outputPath)
if err != nil {
return fmt.Errorf("Couldn't create fake file - %v", err)
Expand Down

0 comments on commit de30453

Please sign in to comment.