summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-06-20 12:02:49 +0200
committerGitHub <noreply@github.com>2022-06-20 12:02:49 +0200
commitcb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (patch)
tree938af0f442baf79cebd114692aff5ad6af37f987 /integrations
parent3289abcefc563d6ea16c1dbd19680b874a58a6d3 (diff)
downloadgitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.tar.gz
gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.zip
Add more linters to improve code readability (#19989)
Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability - nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length. - unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions - wastedassign - https://github.com/sanposhiho/wastedassign - wastedassign finds wasted assignment statements. - notlintlint - Reports ill-formed or insufficient nolint directives - stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_issue_stopwatch_test.go2
-rw-r--r--integrations/api_packages_container_test.go4
-rw-r--r--integrations/editor_test.go6
-rw-r--r--integrations/git_test.go6
-rw-r--r--integrations/integration_test.go2
-rw-r--r--integrations/nonascii_branches_test.go2
-rw-r--r--integrations/oauth_test.go4
-rw-r--r--integrations/repo_fork_test.go2
-rw-r--r--integrations/repo_generate_test.go2
-rw-r--r--integrations/user_test.go2
10 files changed, 16 insertions, 16 deletions
diff --git a/integrations/api_issue_stopwatch_test.go b/integrations/api_issue_stopwatch_test.go
index 0d06447181..b4e5f90543 100644
--- a/integrations/api_issue_stopwatch_test.go
+++ b/integrations/api_issue_stopwatch_test.go
@@ -38,7 +38,7 @@ func TestAPIListStopWatches(t *testing.T) {
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
- assert.Greater(t, int64(apiWatches[0].Seconds), int64(0))
+ assert.Greater(t, apiWatches[0].Seconds, int64(0))
}
}
diff --git a/integrations/api_packages_container_test.go b/integrations/api_packages_container_test.go
index 2b5be9dd4c..1ed80dfd02 100644
--- a/integrations/api_packages_container_test.go
+++ b/integrations/api_packages_container_test.go
@@ -88,7 +88,7 @@ func TestPackageContainer(t *testing.T) {
req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL))
addTokenAuthHeader(req, anonymousToken)
- resp = MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
})
t.Run("User", func(t *testing.T) {
@@ -112,7 +112,7 @@ func TestPackageContainer(t *testing.T) {
req = NewRequest(t, "GET", fmt.Sprintf("%sv2", setting.AppURL))
addTokenAuthHeader(req, userToken)
- resp = MakeRequest(t, req, http.StatusOK)
+ MakeRequest(t, req, http.StatusOK)
})
})
diff --git a/integrations/editor_test.go b/integrations/editor_test.go
index 3ed0e510c4..c6c5ab2f61 100644
--- a/integrations/editor_test.go
+++ b/integrations/editor_test.go
@@ -82,7 +82,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
"_csrf": csrf,
"protected": "off",
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Check if master branch has been locked successfully
flashCookie = session.GetCookie("macaron_flash")
assert.NotNil(t, flashCookie)
@@ -109,7 +109,7 @@ func testEditFile(t *testing.T, session *TestSession, user, repo, branch, filePa
"commit_choice": "direct",
},
)
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
@@ -139,7 +139,7 @@ func testEditFileToNewBranch(t *testing.T, session *TestSession, user, repo, bra
"new_branch_name": targetBranch,
},
)
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Verify the change
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
diff --git a/integrations/git_test.go b/integrations/git_test.go
index a3ba7b7aa9..d6bd673822 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -150,7 +150,7 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
defer PrintCurrentTest(t)()
little, big = commitAndPushTest(t, dstPath, "data-file-")
})
- return
+ return little, big
}
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
@@ -191,7 +191,7 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin
lockTest(t, dstPath)
})
})
- return
+ return littleLFS, bigLFS
}
func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string) {
@@ -210,7 +210,7 @@ func commitAndPushTest(t *testing.T, dstPath, prefix string) (little, big string
big = doCommitAndPush(t, bigSize, dstPath, prefix)
})
})
- return
+ return little, big
}
func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS string) {
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index b0004927f7..8a43de7c45 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -438,7 +438,7 @@ func getTokenForLoggedInUser(t testing.TB, session *TestSession) string {
"_csrf": doc.GetCSRF(),
"name": fmt.Sprintf("api-testing-token-%d", tokenCounter),
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
req = NewRequest(t, "GET", "/user/settings/applications")
resp = session.MakeRequest(t, req, http.StatusOK)
htmlDoc := NewHTMLParser(t, resp.Body)
diff --git a/integrations/nonascii_branches_test.go b/integrations/nonascii_branches_test.go
index 5ab7b8526a..038ada8ca2 100644
--- a/integrations/nonascii_branches_test.go
+++ b/integrations/nonascii_branches_test.go
@@ -26,7 +26,7 @@ func testSrcRouteRedirect(t *testing.T, session *TestSession, user, repo, route,
// Perform redirect
req = NewRequest(t, "GET", location)
- resp = session.MakeRequest(t, req, expectedStatus)
+ session.MakeRequest(t, req, expectedStatus)
}
func setDefaultBranch(t *testing.T, session *TestSession, user, repo, branch string) {
diff --git a/integrations/oauth_test.go b/integrations/oauth_test.go
index 678dfbae2d..c16bb4e24c 100644
--- a/integrations/oauth_test.go
+++ b/integrations/oauth_test.go
@@ -197,7 +197,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
})
req.Header.Add("Authorization", "Basic ZGE3ZGEzYmEtOWExMy00MTY3LTg1NmYtMzg5OWRlMGIwMTM4OmJsYWJsYQ==")
- resp = MakeRequest(t, req, http.StatusBadRequest)
+ MakeRequest(t, req, http.StatusBadRequest)
// missing header
req = NewRequestWithValues(t, "POST", "/login/oauth/access_token", map[string]string{
@@ -206,7 +206,7 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
"code": "authcode",
"code_verifier": "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt", // test PKCE additionally
})
- resp = MakeRequest(t, req, http.StatusBadRequest)
+ MakeRequest(t, req, http.StatusBadRequest)
}
func TestRefreshTokenInvalidation(t *testing.T) {
diff --git a/integrations/repo_fork_test.go b/integrations/repo_fork_test.go
index d701850f14..5f28e66ac8 100644
--- a/integrations/repo_fork_test.go
+++ b/integrations/repo_fork_test.go
@@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
"uid": fmt.Sprintf("%d", forkOwner.ID),
"repo_name": forkRepoName,
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Step4: check the existence of the forked repo
req = NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
diff --git a/integrations/repo_generate_test.go b/integrations/repo_generate_test.go
index 4fbbb56c50..0123932a74 100644
--- a/integrations/repo_generate_test.go
+++ b/integrations/repo_generate_test.go
@@ -46,7 +46,7 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateOwnerName, tem
"repo_name": generateRepoName,
"git_content": "true",
})
- resp = session.MakeRequest(t, req, http.StatusSeeOther)
+ session.MakeRequest(t, req, http.StatusSeeOther)
// Step4: check the existence of the generated repo
req = NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
diff --git a/integrations/user_test.go b/integrations/user_test.go
index 6a3d30472d..41127a4e40 100644
--- a/integrations/user_test.go
+++ b/integrations/user_test.go
@@ -245,6 +245,6 @@ func TestListStopWatches(t *testing.T) {
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
- assert.Greater(t, int64(apiWatches[0].Seconds), int64(0))
+ assert.Greater(t, apiWatches[0].Seconds, int64(0))
}
}