Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Mar 19, 2024
1 parent bef67bb commit c3ed652
Show file tree
Hide file tree
Showing 26 changed files with 109 additions and 76 deletions.
9 changes: 6 additions & 3 deletions cmd/fileexperts/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ func TestFileExperts_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -172,8 +173,9 @@ func TestFileExperts_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -205,8 +207,9 @@ func TestFileExperts_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
13 changes: 5 additions & 8 deletions cmd/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestSendHeartbeats_WithFiltering_Exclude(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)

numCalls++
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestSendHeartbeats_ExtraHeartbeats_Sanitize(t *testing.T) {
numCalls int
)

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
// send response
w.WriteHeader(http.StatusCreated)

Expand Down Expand Up @@ -724,10 +724,9 @@ func TestSendHeartbeats_ErrAuth_UnsetAPIKey(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusCreated)
})

Expand Down Expand Up @@ -760,10 +759,9 @@ func TestSendHeartbeats_ErrBackoff(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -824,10 +822,9 @@ func TestSendHeartbeats_ErrBackoff_Verbose(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/params/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,8 @@ func TestLoad_API_APIKeyInvalid(t *testing.T) {
require.Error(t, err)

var errauth api.ErrAuth
assert.ErrorAs(t, err, &errauth)

assert.ErrorAs(t, err, &errauth)
assert.EqualError(t, errauth, "invalid api key format")
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewRootCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "wakatime-cli",
Short: "Command line interface used by all WakaTime text editor plugins.",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {

Check warning on line 28 in cmd/root.go

View check run for this annotation

Codecov / codecov/patch

cmd/root.go#L28

Added line #L28 was not covered by tests
Run(cmd, v)
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/run_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
func TestRunCmd(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.Success, nil
})

Expand All @@ -35,7 +35,7 @@ func TestRunCmd(t *testing.T) {
func TestRunCmd_Err(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestRunCmd_ErrOfflineEnqueue(t *testing.T) {
v.Set("key", "00000000-0000-4000-8000-000000000000")
v.Set("plugin", "vim")

ret := runCmd(v, true, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, true, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down
18 changes: 9 additions & 9 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestRunCmd_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -76,7 +76,7 @@ func TestRunCmd_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -149,7 +149,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -198,7 +198,7 @@ func TestRunCmd_SendDiagnostics_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestRunCmd_SendDiagnostics_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestRunCmd_SendDiagnostics_NoLogs_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestRunCmd_SendDiagnostics_WakaError(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, offline.ErrOpenDB{Err: errors.New("fail")}
}
Expand Down Expand Up @@ -630,7 +630,7 @@ func TestRunCmdWithOfflineSync(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 0, nil
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/today/today_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func TestToday_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -104,8 +105,9 @@ func TestToday_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -137,8 +139,9 @@ func TestToday_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
9 changes: 6 additions & 3 deletions cmd/todaygoal/todaygoal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func TestGoal_ErrApi(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -111,8 +112,9 @@ func TestGoal_ErrAuth(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -146,8 +148,9 @@ func TestGoal_ErrBadRequest(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
8 changes: 4 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func TestSendHeartbeats_ErrAuth_InvalidAPIKEY(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -702,7 +702,7 @@ func TestOfflineCount(t *testing.T) {
apiURL, router, close := setupTestServer()
defer close()

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
_, err := io.Copy(w, strings.NewReader("500 error test"))
require.NoError(t, err)
Expand Down Expand Up @@ -781,7 +781,7 @@ func TestPrintOfflineHeartbeats(t *testing.T) {
apiURL, router, close := setupTestServer()
defer close()

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
_, err := io.Copy(w, strings.NewReader("500 error test"))
require.NoError(t, err)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ func setupTestServer() (string, *http.ServeMux, func()) {
router := http.NewServeMux()
srv := httptest.NewServer(router)

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusCreated)
})

Expand Down
9 changes: 6 additions & 3 deletions pkg/api/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ func TestClient_FileExperts_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand All @@ -152,8 +153,9 @@ func TestClient_FileExperts_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand All @@ -180,8 +182,9 @@ func TestClient_FileExperts_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
11 changes: 7 additions & 4 deletions pkg/api/goal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestClient_GoalWithTimeout(t *testing.T) {
defer close(called)

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(_ http.ResponseWriter, _ *http.Request) {
<-block
called <- struct{}{}
})
Expand Down Expand Up @@ -88,8 +88,9 @@ func TestClient_Goal_Err(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand All @@ -109,8 +110,9 @@ func TestClient_Goal_ErrAuth(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand All @@ -131,8 +133,9 @@ func TestClient_Goal_ErrBadRequest(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
Loading

0 comments on commit c3ed652

Please sign in to comment.