Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Mar 29, 2024
1 parent dd106ec commit 420571a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 13 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ linters-settings:
- stringsCompare
- switchTrue
- syncMapLoadAndDelete
- timeCmpSimplify
- timeExprSimplify
- tooManyResultsChecker
- truncateCmp
Expand Down
4 changes: 2 additions & 2 deletions editor/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func defaultEnvShell() []string {
func defaultEnvEditor(envs []string) ([]string, bool) {
var editor string
for _, env := range envs {
if len(env) > 0 {
if env != "" {
editor = os.Getenv(env)
}
if len(editor) > 0 {
if editor != "" {
break
}
}
Expand Down
3 changes: 2 additions & 1 deletion http/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package http

import (
"bytes"
"errors"
"fmt"
"io"
"math"
Expand Down Expand Up @@ -213,7 +214,7 @@ func (impl *defaultAgentImplementation) SendGetRequest(client *http.Client, url
func (a *Agent) readResponseToByteArray(response *http.Response) ([]byte, error) {
var b bytes.Buffer
if err := a.readResponse(response, &b); err != nil {
return nil, fmt.Errorf("reading")
return nil, errors.New("reading")
}
return b.Bytes(), nil
}
Expand Down
6 changes: 3 additions & 3 deletions http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func TestGetURLResponseSuccess(t *testing.T) {
// Given
server := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
func(w http.ResponseWriter, _ *http.Request) {
_, err := io.WriteString(w, "")
require.Nil(t, err)
}))
Expand All @@ -51,7 +51,7 @@ func TestGetURLResponseSuccessTrimmed(t *testing.T) {
// Given
const expected = " some test "
server := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
func(w http.ResponseWriter, _ *http.Request) {
_, err := io.WriteString(w, expected)
require.Nil(t, err)
}))
Expand All @@ -68,7 +68,7 @@ func TestGetURLResponseSuccessTrimmed(t *testing.T) {
func TestGetURLResponseFailedStatus(t *testing.T) {
// Given
server := httptest.NewServer(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusBadRequest)
}))
defer server.Close()
Expand Down
2 changes: 1 addition & 1 deletion log/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewFilenameHook() *FileNameHook {
return &FileNameHook{
field: "file",
skipPrefix: []string{"log/", "logrus/", "logrus@"},
Formatter: func(file, function string, line int) string {
Formatter: func(file, _ string, line int) string {
return fmt.Sprintf("%s:%d", file, line)
},
}
Expand Down
2 changes: 1 addition & 1 deletion mage/golangci-lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func testGo(verbose bool, tags string, pkgs ...string) error {
func VerifyGoMod() error {
minGoVersion := env.Default("MIN_GO_VERSION", defaultMinGoVersion)
if err := shx.RunV(
"go", "mod", "tidy", fmt.Sprintf("-compat=%s", minGoVersion),
"go", "mod", "tidy", "-compat="+minGoVersion,
); err != nil {
return fmt.Errorf("running go mod tidy: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion tar/tar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestExtract(t *testing.T) {
}
require.Nil(t, filepath.Walk(
baseTmpDir,
func(filePath string, fileInfo os.FileInfo, err error) error {
func(_ string, fileInfo os.FileInfo, _ error) error {
require.Equal(t, res[0], fileInfo.Name())
if res[0] == "link" {
require.True(t, fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink)
Expand Down
3 changes: 1 addition & 2 deletions util/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package util

import (
"errors"
"fmt"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -496,7 +495,7 @@ func TestStripSensitiveData(t *testing.T) {
for _, tc := range testCases {
testBytes := []byte(tc.text)
if tc.mustChange {
require.NotEqual(t, StripSensitiveData(testBytes), testBytes, fmt.Sprintf("Failed sanitizing %s", tc.text))
require.NotEqual(t, StripSensitiveData(testBytes), testBytes, "Failed sanitizing "+tc.text)
} else {
require.ElementsMatch(t, StripSensitiveData(testBytes), testBytes)
}
Expand Down
2 changes: 1 addition & 1 deletion version/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func version(fontName string) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Prints the version",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
v := GetVersionInfo()
v.Name = cmd.Root().Name()
v.Description = cmd.Root().Short
Expand Down

0 comments on commit 420571a

Please sign in to comment.