Skip to content

refactor: Fix revive.unnecessary-format lint issues #3629

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

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
2 changes: 1 addition & 1 deletion .custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v2.1.6
version: v2.2.2
plugins:
- module: "github.com/google/go-github/v68/tools/sliceofpointers"
path: ./tools/sliceofpointers
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ linters:
- name: time-naming
- name: unexported-naming
- name: unexported-return
- name: unnecessary-format
- name: unreachable-code
- name: unused-parameter
- name: use-any
Expand Down
2 changes: 1 addition & 1 deletion example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func main() {
log.Fatalf("Unable to get/create the commit reference: %s\n", err)
}
if ref == nil {
log.Fatalf("No error where returned but the reference is nil")
log.Fatal("No error where returned but the reference is nil")
}

tree, err := getTree(ref)
Expand Down
2 changes: 1 addition & 1 deletion example/verifyartifact/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func runVerification(sev *verify.SignedEntityVerifier, pb *verify.PolicyBuilder,
return err
}

fmt.Fprintf(os.Stderr, "Verification successful!\n")
fmt.Fprint(os.Stderr, "Verification successful!\n")

marshaled, err := json.MarshalIndent(res, "", " ")
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestActionsService_ListArtifacts_notFound(t *testing.T) {
ctx := context.Background()
artifacts, resp, err := client.Actions.ListArtifacts(ctx, "o", "r", nil)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.ListArtifacts return status %d, want %d", got, want)
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestActionsService_ListWorkflowRunArtifacts_notFound(t *testing.T) {
ctx := context.Background()
artifacts, resp, err := client.Actions.ListWorkflowRunArtifacts(ctx, "o", "r", 1, nil)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.ListWorkflowRunArtifacts return status %d, want %d", got, want)
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestActionsService_GetArtifact_notFound(t *testing.T) {
ctx := context.Background()
artifact, resp, err := client.Actions.GetArtifact(ctx, "o", "r", 1)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.GetArtifact return status %d, want %d", got, want)
Expand Down Expand Up @@ -510,7 +510,7 @@ func TestActionsService_DownloadArtifact_unexpectedCode(t *testing.T) {
ctx := context.Background()
url, resp, err := client.Actions.DownloadArtifact(ctx, "o", "r", 1, 1)
if err == nil {
t.Fatalf("Actions.DownloadArtifact should return error on unexpected code")
t.Fatal("Actions.DownloadArtifact should return error on unexpected code")
}
if !strings.Contains(err.Error(), "unexpected status code") {
t.Error("Actions.DownloadArtifact should return unexpected status code")
Expand Down Expand Up @@ -580,7 +580,7 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
ctx := context.Background()
resp, err := client.Actions.DeleteArtifact(ctx, "o", "r", 1)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.DeleteArtifact return status %d, want %d", got, want)
Expand Down
14 changes: 7 additions & 7 deletions github/actions_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestActionsService_ListCaches_notFound(t *testing.T) {
ctx := context.Background()
caches, resp, err := client.Actions.ListCaches(ctx, "o", "r", nil)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.ListCaches return status %d, want %d", got, want)
Expand Down Expand Up @@ -151,7 +151,7 @@ func TestActionsService_DeleteCachesByKey_notFound(t *testing.T) {
ctx := context.Background()
resp, err := client.Actions.DeleteCachesByKey(ctx, "o", "r", "1", Ptr("main"))
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.DeleteCachesByKey return status %d, want %d", got, want)
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestActionsService_DeleteCachesByID_notFound(t *testing.T) {
ctx := context.Background()
resp, err := client.Actions.DeleteCachesByID(ctx, "o", "r", 1)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.DeleteCachesByID return status %d, want %d", got, want)
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestActionsService_GetCacheUsageForRepo_notFound(t *testing.T) {
ctx := context.Background()
caches, resp, err := client.Actions.GetCacheUsageForRepo(ctx, "o", "r")
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.GetCacheUsageForRepo return status %d, want %d", got, want)
Expand Down Expand Up @@ -364,7 +364,7 @@ func TestActionsService_ListCacheUsageByRepoForOrg_notFound(t *testing.T) {
ctx := context.Background()
caches, resp, err := client.Actions.ListCacheUsageByRepoForOrg(ctx, "o", nil)
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.ListCacheUsageByRepoForOrg return status %d, want %d", got, want)
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestActionsService_GetCacheUsageForOrg_notFound(t *testing.T) {
ctx := context.Background()
caches, resp, err := client.Actions.GetTotalCacheUsageForOrg(ctx, "o")
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.GetTotalCacheUsageForOrg return status %d, want %d", got, want)
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestActionsService_GetCacheUsageForEnterprise_notFound(t *testing.T) {
ctx := context.Background()
caches, resp, err := client.Actions.GetTotalCacheUsageForEnterprise(ctx, "o")
if err == nil {
t.Errorf("Expected HTTP 404 response")
t.Error("Expected HTTP 404 response")
}
if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
t.Errorf("Actions.GetTotalCacheUsageForEnterprise return status %d, want %d", got, want)
Expand Down
4 changes: 2 additions & 2 deletions github/actions_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestPublicKey_UnmarshalJSON(t *testing.T) {
pk := PublicKey{}
err := json.Unmarshal(tt.data, &pk)
if err == nil && tt.wantErr {
t.Errorf("PublicKey.UnmarshalJSON returned nil instead of an error")
t.Error("PublicKey.UnmarshalJSON returned nil instead of an error")
}
if err != nil && !tt.wantErr {
t.Errorf("PublicKey.UnmarshalJSON returned an unexpected error: %+v", err)
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestActionsService_ListSelectedReposForOrgSecret(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
Expand Down
2 changes: 1 addition & 1 deletion github/actions_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func TestActionsService_ListSelectedReposForOrgVariable(t *testing.T) {

mux.HandleFunc("/orgs/o/actions/variables/NAME/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
Expand Down
2 changes: 1 addition & 1 deletion github/actions_workflow_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func TestActionsService_GetWorkflowJobLogs_unexpectedCode(t *testing.T) {
ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowJobLogs(ctx, "o", "r", 399444496, 1)
if err == nil {
t.Fatalf("Actions.GetWorkflowJobLogs should return error on unexpected code")
t.Fatal("Actions.GetWorkflowJobLogs should return error on unexpected code")
}
if !strings.Contains(err.Error(), "unexpected status code") {
t.Error("Actions.GetWorkflowJobLogs should return unexpected status code")
Expand Down
4 changes: 2 additions & 2 deletions github/actions_workflow_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func TestActionsService_GetWorkflowRunAttemptLogs_unexpectedCode(t *testing.T) {
ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunAttemptLogs(ctx, "o", "r", 399444496, 2, 1)
if err == nil {
t.Fatalf("Actions.GetWorkflowRunAttemptLogs should return error on unexpected code")
t.Fatal("Actions.GetWorkflowRunAttemptLogs should return error on unexpected code")
}
if !strings.Contains(err.Error(), "unexpected status code") {
t.Error("Actions.GetWorkflowRunAttemptLogs should return unexpected status code")
Expand Down Expand Up @@ -680,7 +680,7 @@ func TestActionsService_GetWorkflowRunLogs_unexpectedCode(t *testing.T) {
ctx := context.Background()
url, resp, err := client.Actions.GetWorkflowRunLogs(ctx, "o", "r", 399444496, 1)
if err == nil {
t.Fatalf("Actions.GetWorkflowRunLogs should return error on unexpected code")
t.Fatal("Actions.GetWorkflowRunLogs should return error on unexpected code")
}
if !strings.Contains(err.Error(), "unexpected status code") {
t.Error("Actions.GetWorkflowRunLogs should return unexpected status code")
Expand Down
2 changes: 1 addition & 1 deletion github/activity_watching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestActivityService_GetRepositorySubscription_error(t *testing.T) {
ctx := context.Background()
_, _, err := client.Activity.GetRepositorySubscription(ctx, "o", "r")
if err == nil {
t.Errorf("Expected HTTP 400 response")
t.Error("Expected HTTP 400 response")
}
}

Expand Down
4 changes: 2 additions & 2 deletions github/codespaces_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) {
handleFunc: func(mux *http.ServeMux) {
mux.HandleFunc("/user/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})
},
call: func(ctx context.Context, client *Client) (*SelectedReposList, *Response, error) {
Expand All @@ -510,7 +510,7 @@ func TestCodespacesService_ListSelectedReposForSecret(t *testing.T) {
handleFunc: func(mux *http.ServeMux) {
mux.HandleFunc("/orgs/o/codespaces/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})
},
call: func(ctx context.Context, client *Client) (*SelectedReposList, *Response, error) {
Expand Down
8 changes: 4 additions & 4 deletions github/copilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) {
t.Parallel()
err := json.Unmarshal([]byte(tc.data), seatDetails)
if err == nil && tc.wantErr {
t.Errorf("CopilotSeatDetails.UnmarshalJSON returned nil instead of an error")
t.Error("CopilotSeatDetails.UnmarshalJSON returned nil instead of an error")
}
if err != nil && !tc.wantErr {
t.Errorf("CopilotSeatDetails.UnmarshalJSON returned an unexpected error: %v", err)
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestCopilotService_GetSeatDetailsUser(t *testing.T) {
if got, ok := seatDetails.GetUser(); ok && !cmp.Equal(got, want) {
t.Errorf("CopilotSeatDetails.GetTeam returned %+v, want %+v", got, want)
} else if !ok {
t.Errorf("CopilotSeatDetails.GetUser returned false, expected true")
t.Error("CopilotSeatDetails.GetUser returned false, expected true")
}

data = `{
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestCopilotService_GetSeatDetailsTeam(t *testing.T) {
if got, ok := seatDetails.GetTeam(); ok && !cmp.Equal(got, want) {
t.Errorf("CopilotSeatDetails.GetTeam returned %+v, want %+v", got, want)
} else if !ok {
t.Errorf("CopilotSeatDetails.GetTeam returned false, expected true")
t.Error("CopilotSeatDetails.GetTeam returned false, expected true")
}

data = `{
Expand Down Expand Up @@ -263,7 +263,7 @@ func TestCopilotService_GetSeatDetailsOrganization(t *testing.T) {
if got, ok := seatDetails.GetOrganization(); ok && !cmp.Equal(got, want) {
t.Errorf("CopilotSeatDetails.GetOrganization returned %+v, want %+v", got, want)
} else if !ok {
t.Errorf("CopilotSeatDetails.GetOrganization returned false, expected true")
t.Error("CopilotSeatDetails.GetOrganization returned false, expected true")
}

data = `{
Expand Down
2 changes: 1 addition & 1 deletion github/dependabot_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestDependabotService_ListSelectedReposForOrgSecret(t *testing.T) {

mux.HandleFunc("/orgs/o/dependabot/secrets/NAME/repositories", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{"total_count":1,"repositories":[{"id":1}]}`)
fmt.Fprint(w, `{"total_count":1,"repositories":[{"id":1}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
Expand Down
10 changes: 5 additions & 5 deletions github/enterprise_network_configurations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestEnterpriseService_ListEnterpriseNetworkConfigurations(t *testing.T) {
mux.HandleFunc(" /enterprises/e/network-configurations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"page": "3", "per_page": "2"})
fmt.Fprintf(w, `{
fmt.Fprint(w, `{
"total_count": 2,
"network_configurations": [
{
Expand Down Expand Up @@ -101,7 +101,7 @@ func TestEnterpriseService_CreateEnterpriseNetworkConfiguration(t *testing.T) {

mux.HandleFunc("/enterprises/e/network-configurations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
fmt.Fprintf(w, `{
fmt.Fprint(w, `{
"id": "123456789ABCDEF",
"name": "configuration one",
"compute_service": "actions",
Expand Down Expand Up @@ -195,7 +195,7 @@ func TestEnterpriseService_GetEnterpriseNetworkConfiguration(t *testing.T) {

mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{
fmt.Fprint(w, `{
"id": "123456789ABCDEF",
"name": "configuration one",
"compute_service": "actions",
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestEnterpriseService_UpdateEnterpriseNetworkConfiguration(t *testing.T) {

mux.HandleFunc("/enterprises/e/network-configurations/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
fmt.Fprintf(w, `{
fmt.Fprint(w, `{
"id": "123456789ABCDEF",
"name": "updated configuration one",
"compute_service": "none",
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestEnterpriseService_GetEnterpriseNetworkSettingsResource(t *testing.T) {

mux.HandleFunc("/enterprises/e/network-settings/123456789ABCDEF", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprintf(w, `{
fmt.Fprint(w, `{
"id": "220F78DACB92BBFBC5E6F22DE1CCF52309D",
"network_configuration_id": "934E208B3EE0BD60CF5F752C426BFB53562",
"name": "my_network_settings",
Expand Down
2 changes: 1 addition & 1 deletion github/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestPayload_Panic(t *testing.T) {
t.Parallel()
defer func() {
if r := recover(); r == nil {
t.Errorf("Payload did not panic but should have")
t.Error("Payload did not panic but should have")
}
}()

Expand Down
Loading
Loading