Skip to content

Commit

Permalink
chore(lint): A few fixes for new linter warnings preventing 3.11 from…
Browse files Browse the repository at this point in the history
… building (#2082)

* chore(lint): A few fixes for new linter warnings preventing 3.11 from building

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

* ci(fix): Remove obsolete references to cc-test-reporter

Signed-off-by: Dave Henderson <dhenderson@gmail.com>

---------

Signed-off-by: Dave Henderson <dhenderson@gmail.com>
  • Loading branch information
hairyhenderson authored May 27, 2024
1 parent 6e709cf commit c133ad0
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 35 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,7 @@ jobs:
name: gomplate
path: bin/gomplate
- name: make test
run: |
[ -n "$CC_TEST_REPORTER_ID" ] && cc-test-reporter before-build
make test
EXIT_CODE=$?
if [ -n "$CC_TEST_REPORTER_ID" ]; then
# workaround from https://github.com/codeclimate/test-reporter/issues/378
export PREFIX=$(go list -m)
cc-test-reporter after-build -t gocov -p $PREFIX --exit-code $EXIT_CODE
fi
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: make test
- run: make integration
windows-build:
runs-on: windows-latest
Expand Down
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
linters-settings:
govet:
check-shadowing: true
enable-all: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 10
dupl:
Expand All @@ -15,7 +12,6 @@ linters-settings:
lll:
line-length: 140
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand Down
8 changes: 4 additions & 4 deletions data/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ escaped: "\"\/\\\b\f\n\r\t\u221e"
`))

obj := make(map[string]interface{})
_, err := unmarshalObj(obj, "SOMETHING", func(in []byte, out interface{}) error {
_, err := unmarshalObj(obj, "SOMETHING", func(_ []byte, _ interface{}) error {
return errors.New("fail")
})
assert.EqualError(t, err, "Unable to unmarshal object SOMETHING: fail")
Expand Down Expand Up @@ -139,20 +139,20 @@ this shouldn't be reached
actual)

obj := make([]interface{}, 1)
_, err = unmarshalArray(obj, "SOMETHING", func(in []byte, out interface{}) error {
_, err = unmarshalArray(obj, "SOMETHING", func(_ []byte, _ interface{}) error {
return errors.New("fail")
})
assert.EqualError(t, err, "Unable to unmarshal array SOMETHING: fail")
}

func TestMarshalObj(t *testing.T) {
expected := "foo"
actual, err := marshalObj(nil, func(in interface{}) ([]byte, error) {
actual, err := marshalObj(nil, func(_ interface{}) ([]byte, error) {
return []byte("foo"), nil
})
assert.NoError(t, err)
assert.Equal(t, expected, actual)
_, err = marshalObj(nil, func(in interface{}) ([]byte, error) {
_, err = marshalObj(nil, func(_ interface{}) ([]byte, error) {
return nil, errors.New("fail")
})
assert.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion data/datasource_http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func setupHTTP(code int, mimetype string, body string) (*httptest.Server, *http.

client := &http.Client{
Transport: &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
Proxy: func(_ *http.Request) (*url.URL, error) {
return url.Parse(server.URL)
},
},
Expand Down
2 changes: 1 addition & 1 deletion funcs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (f *FileFuncs) ReadDir(path interface{}) ([]string, error) {
// Walk -
func (f *FileFuncs) Walk(path interface{}) ([]string, error) {
files := make([]string, 0)
err := afero.Walk(f.fs, conv.ToString(path), func(subpath string, finfo os.FileInfo, err error) error {
err := afero.Walk(f.fs, conv.ToString(path), func(subpath string, _ os.FileInfo, err error) error {
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hairyhenderson/gomplate/v3

go 1.19
go 1.21

require (
github.com/Masterminds/goutils v1.1.1
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func createLogger(format string, out io.Writer) zerolog.Logger {
stdlogger = stdlogger.Output(zerolog.ConsoleWriter{
Out: out,
NoColor: !useColour,
FormatLevel: func(i interface{}) string { return "" },
FormatLevel: func(_ interface{}) string { return "" },
})
case "logfmt":
w := zerolog.ConsoleWriter{
Expand All @@ -78,8 +78,8 @@ func createLogger(format string, out io.Writer) zerolog.Logger {
w := zerolog.ConsoleWriter{
Out: out,
NoColor: true,
FormatLevel: func(i interface{}) string { return "" },
FormatTimestamp: func(i interface{}) string { return "" },
FormatLevel: func(_ interface{}) string { return "" },
FormatTimestamp: func(_ interface{}) string { return "" },
}
l = l.Output(w)
stdlogger = stdlogger.Output(w)
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func mirrorHandler(w http.ResponseWriter, r *http.Request) {
}

func typeHandler(t, body string) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", t)
w.Write([]byte(body))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/integration/test_ec2_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func certificateGenerate() (priv *rsa.PrivateKey, derBytes []byte, err error) {
}

func pkcsHandler(priv *rsa.PrivateKey, derBytes []byte) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
cert, err := x509.ParseCertificate(derBytes)
if err != nil {
log.Fatalf("Cannot decode certificate: %s", err)
Expand Down
5 changes: 0 additions & 5 deletions random/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import (
"math"
"math/rand"
"regexp"
"time"
"unicode"
)

func init() {
rand.Seed(time.Now().UnixNano())
}

// Default set, matches "[a-zA-Z0-9_.-]"
const defaultSet = "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"

Expand Down
4 changes: 2 additions & 2 deletions vault/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (

// MockServer -
func MockServer(code int, body string) (*httptest.Server, *Vault) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(code)
fmt.Fprintln(w, body)
}))

tr := &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
Proxy: func(_ *http.Request) (*url.URL, error) {
return url.Parse(server.URL)
},
}
Expand Down

0 comments on commit c133ad0

Please sign in to comment.