diff --git a/.golangci.yml b/.golangci.yml
index 9620dcaa35..9e64d71b59 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -15,6 +15,7 @@ linters:
     - misspell
     - gocritic
     - bidichk
+    - ineffassign
   enable-all: false
   disable-all: true
   fast: false
diff --git a/cmd/hook.go b/cmd/hook.go
index fb43add8d4..6b8d89500a 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -293,7 +293,6 @@ Gitea or set your environment appropriately.`, "")
 		}
 	} else if lastline > 0 {
 		fmt.Fprintf(out, "\n")
-		lastline = 0
 	}
 
 	fmt.Fprintf(out, "Checked %d references in total\n", total)
diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go
index aade251902..03c876aa62 100644
--- a/contrib/environment-to-ini/environment-to-ini.go
+++ b/contrib/environment-to-ini/environment-to-ini.go
@@ -224,7 +224,6 @@ func DecodeSectionKey(encoded string) (string, string) {
 	if !inKey {
 		if splitter := strings.Index(remaining, "__"); splitter > -1 {
 			section += remaining[:splitter]
-			inKey = true
 			key += remaining[splitter+2:]
 		} else {
 			section += remaining
diff --git a/integrations/api_comment_test.go b/integrations/api_comment_test.go
index 6f8c5a85bd..cf26fa0e16 100644
--- a/integrations/api_comment_test.go
+++ b/integrations/api_comment_test.go
@@ -119,9 +119,9 @@ func TestAPIGetComment(t *testing.T) {
 	session := loginUser(t, repoOwner.Name)
 	token := getTokenForLoggedInUser(t, session)
 	req := NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d", repoOwner.Name, repo.Name, comment.ID)
-	resp := session.MakeRequest(t, req, http.StatusOK)
+	session.MakeRequest(t, req, http.StatusOK)
 	req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/issues/comments/%d?token=%s", repoOwner.Name, repo.Name, comment.ID, token)
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	resp := session.MakeRequest(t, req, http.StatusOK)
 
 	var apiComment api.Comment
 	DecodeJSON(t, resp, &apiComment)
diff --git a/integrations/api_issue_label_test.go b/integrations/api_issue_label_test.go
index 58e09c818e..9e569c85a2 100644
--- a/integrations/api_issue_label_test.go
+++ b/integrations/api_issue_label_test.go
@@ -83,7 +83,7 @@ func TestAPIModifyLabels(t *testing.T) {
 
 	//DeleteLabel
 	req = NewRequest(t, "DELETE", singleURLStr)
-	resp = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 }
 
@@ -203,6 +203,6 @@ func TestAPIModifyOrgLabels(t *testing.T) {
 
 	//DeleteLabel
 	req = NewRequest(t, "DELETE", singleURLStr)
-	resp = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 }
diff --git a/integrations/api_issue_milestone_test.go b/integrations/api_issue_milestone_test.go
index 233d8ef33c..1ac3fb2ed8 100644
--- a/integrations/api_issue_milestone_test.go
+++ b/integrations/api_issue_milestone_test.go
@@ -74,5 +74,5 @@ func TestAPIIssuesMilestone(t *testing.T) {
 	assert.Equal(t, int64(2), apiMilestones[0].ID)
 
 	req = NewRequest(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%d?token=%s", owner.Name, repo.Name, apiMilestone.ID, token))
-	resp = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 }
diff --git a/integrations/api_issue_reaction_test.go b/integrations/api_issue_reaction_test.go
index 4591f8fa8c..7b3632ca67 100644
--- a/integrations/api_issue_reaction_test.go
+++ b/integrations/api_issue_reaction_test.go
@@ -36,24 +36,24 @@ func TestAPIIssuesReactions(t *testing.T) {
 	req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
 		Reaction: "wrong",
 	})
-	resp := session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	//Delete not allowed reaction
 	req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
 		Reaction: "zzz",
 	})
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	session.MakeRequest(t, req, http.StatusOK)
 
 	//Add allowed reaction
 	req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
 		Reaction: "rocket",
 	})
-	resp = session.MakeRequest(t, req, http.StatusCreated)
+	resp := session.MakeRequest(t, req, http.StatusCreated)
 	var apiNewReaction api.Reaction
 	DecodeJSON(t, resp, &apiNewReaction)
 
 	//Add existing reaction
-	resp = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	//Get end result of reaction list of issue #1
 	req = NewRequestf(t, "GET", urlStr)
@@ -96,24 +96,24 @@ func TestAPICommentReactions(t *testing.T) {
 	req := NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
 		Reaction: "wrong",
 	})
-	resp := session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	//Delete none existing reaction
 	req = NewRequestWithJSON(t, "DELETE", urlStr, &api.EditReactionOption{
 		Reaction: "eyes",
 	})
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	session.MakeRequest(t, req, http.StatusOK)
 
 	//Add allowed reaction
 	req = NewRequestWithJSON(t, "POST", urlStr, &api.EditReactionOption{
 		Reaction: "+1",
 	})
-	resp = session.MakeRequest(t, req, http.StatusCreated)
+	resp := session.MakeRequest(t, req, http.StatusCreated)
 	var apiNewReaction api.Reaction
 	DecodeJSON(t, resp, &apiNewReaction)
 
 	//Add existing reaction
-	resp = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	//Get end result of reaction list of issue #1
 	req = NewRequestf(t, "GET", urlStr)
diff --git a/integrations/api_notification_test.go b/integrations/api_notification_test.go
index 1c62ee5abf..24d17173ac 100644
--- a/integrations/api_notification_test.go
+++ b/integrations/api_notification_test.go
@@ -66,7 +66,7 @@ func TestAPINotification(t *testing.T) {
 	// -- GET /notifications/threads/{id} --
 	// get forbidden
 	req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", 1, token))
-	resp = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	// get own
 	req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
@@ -100,7 +100,7 @@ func TestAPINotification(t *testing.T) {
 
 	lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
 	req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
-	resp = session.MakeRequest(t, req, http.StatusResetContent)
+	session.MakeRequest(t, req, http.StatusResetContent)
 
 	req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?status-types=unread&token=%s", token))
 	resp = session.MakeRequest(t, req, http.StatusOK)
@@ -109,7 +109,7 @@ func TestAPINotification(t *testing.T) {
 
 	// -- PATCH /notifications/threads/{id} --
 	req = NewRequest(t, "PATCH", fmt.Sprintf("/api/v1/notifications/threads/%d?token=%s", thread5.ID, token))
-	resp = session.MakeRequest(t, req, http.StatusResetContent)
+	session.MakeRequest(t, req, http.StatusResetContent)
 
 	assert.Equal(t, models.NotificationStatusUnread, thread5.Status)
 	thread5 = unittest.AssertExistsAndLoadBean(t, &models.Notification{ID: 5}).(*models.Notification)
diff --git a/integrations/api_pull_review_test.go b/integrations/api_pull_review_test.go
index ace2c89e80..50b9454084 100644
--- a/integrations/api_pull_review_test.go
+++ b/integrations/api_pull_review_test.go
@@ -140,7 +140,7 @@ func TestAPIPullReview(t *testing.T) {
 	assert.EqualValues(t, "COMMENT", review.State)
 	assert.EqualValues(t, 0, review.CodeCommentsCount)
 	req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, review.ID, token)
-	resp = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 	// test CreatePullReview Comment without body but with comments
 	req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews?token=%s", repo.OwnerName, repo.Name, pullIssue.Index, token), &api.CreatePullReviewOptions{
diff --git a/integrations/api_repo_edit_test.go b/integrations/api_repo_edit_test.go
index 404e8e912f..f862afa2c3 100644
--- a/integrations/api_repo_edit_test.go
+++ b/integrations/api_repo_edit_test.go
@@ -145,7 +145,6 @@ func TestAPIRepoEdit(t *testing.T) {
 		// Get user2's token
 		session := loginUser(t, user2.Name)
 		token2 := getTokenForLoggedInUser(t, session)
-		session = emptyTestSession(t)
 		// Get user4's token
 		session = loginUser(t, user4.Name)
 		token4 := getTokenForLoggedInUser(t, session)
@@ -223,15 +222,15 @@ func TestAPIRepoEdit(t *testing.T) {
 		// Do some tests with invalid URL for external tracker and wiki
 		repoEditOption.ExternalTracker.ExternalTrackerURL = "htp://www.somewebsite.com"
 		req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
-		resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+		session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 		repoEditOption.ExternalTracker.ExternalTrackerURL = "http://www.somewebsite.com"
 		repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user/{repo}?issue={index}"
 		req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
-		resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+		session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 		repoEditOption.ExternalTracker.ExternalTrackerFormat = "http://www.somewebsite.com/{user}/{repo}?issue={index}"
 		repoEditOption.ExternalWiki.ExternalWikiURL = "htp://www.somewebsite.com"
 		req = NewRequestWithJSON(t, "PATCH", url, &repoEditOption)
-		resp = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+		session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 
 		//Test small repo change through API with issue and wiki option not set; They shall not be touched.
 		*repoEditOption.Description = "small change"
diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go
index dd703a99bb..07ddbbbfe6 100644
--- a/integrations/api_repo_file_create_test.go
+++ b/integrations/api_repo_file_create_test.go
@@ -149,7 +149,6 @@ func TestAPICreateFile(t *testing.T) {
 		// Get user2's token
 		session := loginUser(t, user2.Name)
 		token2 := getTokenForLoggedInUser(t, session)
-		session = emptyTestSession(t)
 		// Get user4's token
 		session = loginUser(t, user4.Name)
 		token4 := getTokenForLoggedInUser(t, session)
diff --git a/integrations/api_repo_file_delete_test.go b/integrations/api_repo_file_delete_test.go
index e9877d08c2..93da12700d 100644
--- a/integrations/api_repo_file_delete_test.go
+++ b/integrations/api_repo_file_delete_test.go
@@ -49,7 +49,6 @@ func TestAPIDeleteFile(t *testing.T) {
 		// Get user2's token
 		session := loginUser(t, user2.Name)
 		token2 := getTokenForLoggedInUser(t, session)
-		session = emptyTestSession(t)
 		// Get user4's token
 		session = loginUser(t, user4.Name)
 		token4 := getTokenForLoggedInUser(t, session)
@@ -111,7 +110,7 @@ func TestAPIDeleteFile(t *testing.T) {
 		deleteFileOptions.SHA = "badsha"
 		url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
 		req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions)
-		resp = session.MakeRequest(t, req, http.StatusBadRequest)
+		session.MakeRequest(t, req, http.StatusBadRequest)
 
 		// Test creating a file in repo16 by user4 who does not have write access
 		fileID++
diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go
index ba1f309f14..fb554efe7a 100644
--- a/integrations/api_repo_file_update_test.go
+++ b/integrations/api_repo_file_update_test.go
@@ -115,7 +115,6 @@ func TestAPIUpdateFile(t *testing.T) {
 		// Get user2's token
 		session := loginUser(t, user2.Name)
 		token2 := getTokenForLoggedInUser(t, session)
-		session = emptyTestSession(t)
 		// Get user4's token
 		session = loginUser(t, user4.Name)
 		token4 := getTokenForLoggedInUser(t, session)
diff --git a/integrations/api_repo_get_contents_list_test.go b/integrations/api_repo_get_contents_list_test.go
index 823a72c726..abcfc1fd82 100644
--- a/integrations/api_repo_get_contents_list_test.go
+++ b/integrations/api_repo_get_contents_list_test.go
@@ -64,7 +64,6 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
 	// Get user2's token
 	session := loginUser(t, user2.Name)
 	token2 := getTokenForLoggedInUser(t, session)
-	session = emptyTestSession(t)
 	// Get user4's token
 	session = loginUser(t, user4.Name)
 	token4 := getTokenForLoggedInUser(t, session)
@@ -139,7 +138,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
 	// Test file contents a file with a bad ref
 	ref = "badref"
 	req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
-	resp = session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// Test accessing private ref with user token that does not have access - should fail
 	req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
diff --git a/integrations/api_repo_get_contents_test.go b/integrations/api_repo_get_contents_test.go
index 67ec02b7b0..00fef78b88 100644
--- a/integrations/api_repo_get_contents_test.go
+++ b/integrations/api_repo_get_contents_test.go
@@ -65,7 +65,6 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
 	// Get user2's token
 	session := loginUser(t, user2.Name)
 	token2 := getTokenForLoggedInUser(t, session)
-	session = emptyTestSession(t)
 	// Get user4's token
 	session = loginUser(t, user4.Name)
 	token4 := getTokenForLoggedInUser(t, session)
@@ -141,7 +140,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
 	// Test file contents a file with a bad ref
 	ref = "badref"
 	req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
-	resp = session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// Test accessing private ref with user token that does not have access - should fail
 	req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)
diff --git a/integrations/api_repo_tags_test.go b/integrations/api_repo_tags_test.go
index 59eaedcbdf..79a2880bcf 100644
--- a/integrations/api_repo_tags_test.go
+++ b/integrations/api_repo_tags_test.go
@@ -62,10 +62,10 @@ func TestAPIRepoTags(t *testing.T) {
 
 	// delete tag
 	delReq := NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/tags/%s?token=%s", user.Name, repoName, newTag.Name, token)
-	resp = session.MakeRequest(t, delReq, http.StatusNoContent)
+	session.MakeRequest(t, delReq, http.StatusNoContent)
 
 	// check if it's gone
-	resp = session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 }
 
 func createNewTagUsingAPI(t *testing.T, session *TestSession, token string, ownerName, repoName, name, target, msg string) *api.Tag {
diff --git a/integrations/api_repo_teams_test.go b/integrations/api_repo_teams_test.go
index 56836fcee3..59025e0e53 100644
--- a/integrations/api_repo_teams_test.go
+++ b/integrations/api_repo_teams_test.go
@@ -54,12 +54,12 @@ func TestAPIRepoTeams(t *testing.T) {
 
 	url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "NonExistingTeam", token)
 	req = NewRequest(t, "GET", url)
-	res = session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// AddTeam with user4
 	url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
 	req = NewRequest(t, "PUT", url)
-	res = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 	// AddTeam with user2
 	user = unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
@@ -67,12 +67,12 @@ func TestAPIRepoTeams(t *testing.T) {
 	token = getTokenForLoggedInUser(t, session)
 	url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
 	req = NewRequest(t, "PUT", url)
-	res = session.MakeRequest(t, req, http.StatusNoContent)
-	res = session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
+	session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
 
 	// DeleteTeam
 	url = fmt.Sprintf("/api/v1/repos/%s/teams/%s?token=%s", publicOrgRepo.FullName(), "team1", token)
 	req = NewRequest(t, "DELETE", url)
-	res = session.MakeRequest(t, req, http.StatusNoContent)
-	res = session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
+	session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusUnprocessableEntity) // test duplicate request
 }
diff --git a/integrations/api_repo_topic_test.go b/integrations/api_repo_topic_test.go
index 6035dd3d52..05f025d946 100644
--- a/integrations/api_repo_topic_test.go
+++ b/integrations/api_repo_topic_test.go
@@ -75,15 +75,15 @@ func TestAPIRepoTopic(t *testing.T) {
 
 	// Test delete a topic
 	req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
-	res = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 	// Test add an existing topic
 	req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Golang", token2)
-	res = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 	// Test add a topic
 	req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "topicName3", token2)
-	res = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 
 	// Test read topics using token
 	req = NewRequest(t, "GET", url)
@@ -96,7 +96,7 @@ func TestAPIRepoTopic(t *testing.T) {
 	req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
 		Topics: newTopics,
 	})
-	res = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 	req = NewRequest(t, "GET", url)
 	res = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, res, &topics)
@@ -107,7 +107,7 @@ func TestAPIRepoTopic(t *testing.T) {
 	req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
 		Topics: newTopics,
 	})
-	res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+	session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 	req = NewRequest(t, "GET", url)
 	res = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, res, &topics)
@@ -118,7 +118,7 @@ func TestAPIRepoTopic(t *testing.T) {
 	req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
 		Topics: newTopics,
 	})
-	res = session.MakeRequest(t, req, http.StatusNoContent)
+	session.MakeRequest(t, req, http.StatusNoContent)
 	req = NewRequest(t, "GET", url)
 	res = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, res, &topics)
@@ -129,15 +129,15 @@ func TestAPIRepoTopic(t *testing.T) {
 	req = NewRequestWithJSON(t, "PUT", url, &api.RepoTopicOptions{
 		Topics: newTopics,
 	})
-	res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+	session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 
 	// Test add a topic when there is already maximum
 	req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "t26", token2)
-	res = session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+	session.MakeRequest(t, req, http.StatusUnprocessableEntity)
 
 	// Test delete a topic that repo doesn't have
 	req = NewRequestf(t, "DELETE", "/api/v1/repos/%s/%s/topics/%s?token=%s", user2.Name, repo2.Name, "Topicname1", token2)
-	res = session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// Get user4's token
 	session = loginUser(t, user4.Name)
@@ -153,6 +153,6 @@ func TestAPIRepoTopic(t *testing.T) {
 
 	// Test add a topic to repo with write access (requires repo admin access)
 	req = NewRequestf(t, "PUT", "/api/v1/repos/%s/%s/topics/%s?token=%s", user3.Name, repo3.Name, "topicName", token4)
-	res = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 }
diff --git a/integrations/api_team_test.go b/integrations/api_team_test.go
index 141c887e13..26d6c884b4 100644
--- a/integrations/api_team_test.go
+++ b/integrations/api_team_test.go
@@ -160,6 +160,6 @@ func TestAPITeamSearch(t *testing.T) {
 	csrf = GetCSRF(t, session, "/"+org.Name)
 	req = NewRequestf(t, "GET", "/api/v1/orgs/%s/teams/search?q=%s", org.Name, "team")
 	req.Header.Add("X-Csrf-Token", csrf)
-	resp = session.MakeRequest(t, req, http.StatusForbidden)
+	session.MakeRequest(t, req, http.StatusForbidden)
 
 }
diff --git a/integrations/api_user_orgs_test.go b/integrations/api_user_orgs_test.go
index d52ac980b9..5bc5df118f 100644
--- a/integrations/api_user_orgs_test.go
+++ b/integrations/api_user_orgs_test.go
@@ -72,13 +72,13 @@ func TestMyOrgs(t *testing.T) {
 
 	session := emptyTestSession(t)
 	req := NewRequest(t, "GET", "/api/v1/user/orgs")
-	resp := session.MakeRequest(t, req, http.StatusUnauthorized)
+	session.MakeRequest(t, req, http.StatusUnauthorized)
 
 	normalUsername := "user2"
 	session = loginUser(t, normalUsername)
 	token := getTokenForLoggedInUser(t, session)
 	req = NewRequest(t, "GET", "/api/v1/user/orgs?token="+token)
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	resp := session.MakeRequest(t, req, http.StatusOK)
 	var orgs []*api.Organization
 	DecodeJSON(t, resp, &orgs)
 	user3 := unittest.AssertExistsAndLoadBean(t, &models.User{Name: "user3"}).(*models.User)
diff --git a/integrations/eventsource_test.go b/integrations/eventsource_test.go
index eb08c004a8..6c4c87b3d1 100644
--- a/integrations/eventsource_test.go
+++ b/integrations/eventsource_test.go
@@ -69,7 +69,7 @@ func TestEventSourceManagerRun(t *testing.T) {
 
 	lastReadAt := "2000-01-01T00%3A50%3A01%2B00%3A00" //946687801 <- only Notification 4 is in this filter ...
 	req = NewRequest(t, "PUT", fmt.Sprintf("/api/v1/repos/%s/%s/notifications?last_read_at=%s&token=%s", user2.Name, repo1.Name, lastReadAt, token))
-	resp = session.MakeRequest(t, req, http.StatusResetContent)
+	session.MakeRequest(t, req, http.StatusResetContent)
 
 	req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/notifications?token=%s&status-types=unread", token))
 	resp = session.MakeRequest(t, req, http.StatusOK)
diff --git a/integrations/issue_test.go b/integrations/issue_test.go
index 56cddcb063..ae274749a2 100644
--- a/integrations/issue_test.go
+++ b/integrations/issue_test.go
@@ -287,7 +287,7 @@ func TestIssueCrossReference(t *testing.T) {
 	unittest.AssertExistsAndLoadBean(t, comment)
 
 	// Ref from a different repository
-	issueRefURL, issueRef = testIssueWithBean(t, "user12", 10, "TitleXRef", fmt.Sprintf("Description ref user2/repo1#%d", issueBase.Index))
+	_, issueRef = testIssueWithBean(t, "user12", 10, "TitleXRef", fmt.Sprintf("Description ref user2/repo1#%d", issueBase.Index))
 	unittest.AssertExistsAndLoadBean(t, &models.Comment{
 		IssueID:      issueBase.ID,
 		RefRepoID:    10,
diff --git a/integrations/pull_status_test.go b/integrations/pull_status_test.go
index 7c6f3d44c5..f818643005 100644
--- a/integrations/pull_status_test.go
+++ b/integrations/pull_status_test.go
@@ -33,12 +33,12 @@ func TestPullCreate_CommitStatus(t *testing.T) {
 
 		req = NewRequest(t, "GET", "/user1/repo1/pulls")
 		resp := session.MakeRequest(t, req, http.StatusOK)
-		doc := NewHTMLParser(t, resp.Body)
+		NewHTMLParser(t, resp.Body)
 
 		// Request repository commits page
 		req = NewRequest(t, "GET", "/user1/repo1/pulls/1/commits")
 		resp = session.MakeRequest(t, req, http.StatusOK)
-		doc = NewHTMLParser(t, resp.Body)
+		doc := NewHTMLParser(t, resp.Body)
 
 		// Get first commit URL
 		commitURL, exists := doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href")
diff --git a/integrations/repo_fork_test.go b/integrations/repo_fork_test.go
index 22b2169e2f..0f23aa5e87 100644
--- a/integrations/repo_fork_test.go
+++ b/integrations/repo_fork_test.go
@@ -21,11 +21,11 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
 
 	// Step0: check the existence of the to-fork repo
 	req := NewRequestf(t, "GET", "/%s/%s", forkOwnerName, forkRepoName)
-	resp := session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// Step1: go to the main page of repo
 	req = NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	resp := session.MakeRequest(t, req, http.StatusOK)
 
 	// Step2: click the fork button
 	htmlDoc := NewHTMLParser(t, resp.Body)
diff --git a/integrations/repo_generate_test.go b/integrations/repo_generate_test.go
index d1e28c2f08..66819656f9 100644
--- a/integrations/repo_generate_test.go
+++ b/integrations/repo_generate_test.go
@@ -21,11 +21,11 @@ func testRepoGenerate(t *testing.T, session *TestSession, templateOwnerName, tem
 
 	// Step0: check the existence of the generated repo
 	req := NewRequestf(t, "GET", "/%s/%s", generateOwnerName, generateRepoName)
-	resp := session.MakeRequest(t, req, http.StatusNotFound)
+	session.MakeRequest(t, req, http.StatusNotFound)
 
 	// Step1: go to the main page of template repo
 	req = NewRequestf(t, "GET", "/%s/%s", templateOwnerName, templateRepoName)
-	resp = session.MakeRequest(t, req, http.StatusOK)
+	resp := session.MakeRequest(t, req, http.StatusOK)
 
 	// Step2: click the "Use this template" button
 	htmlDoc := NewHTMLParser(t, resp.Body)
diff --git a/models/issue_assignees_test.go b/models/issue_assignees_test.go
index d1ce000de6..b604f13bd5 100644
--- a/models/issue_assignees_test.go
+++ b/models/issue_assignees_test.go
@@ -72,7 +72,7 @@ func TestMakeIDsFromAPIAssigneesToAdd(t *testing.T) {
 	assert.NoError(t, err)
 	assert.Equal(t, []int64{}, IDs)
 
-	IDs, err = MakeIDsFromAPIAssigneesToAdd("", []string{"none_existing_user"})
+	_, err = MakeIDsFromAPIAssigneesToAdd("", []string{"none_existing_user"})
 	assert.Error(t, err)
 
 	IDs, err = MakeIDsFromAPIAssigneesToAdd("user1", []string{"user1"})
diff --git a/models/topic_test.go b/models/topic_test.go
index a38ed64940..0219bdded5 100644
--- a/models/topic_test.go
+++ b/models/topic_test.go
@@ -16,7 +16,6 @@ import (
 func TestAddTopic(t *testing.T) {
 	totalNrOfTopics := 6
 	repo1NrOfTopics := 3
-	repo2NrOfTopics := 2
 
 	assert.NoError(t, unittest.PrepareTestDatabase())
 
@@ -38,7 +37,7 @@ func TestAddTopic(t *testing.T) {
 	assert.Len(t, topics, repo1NrOfTopics)
 
 	assert.NoError(t, SaveTopics(2, "golang"))
-	repo2NrOfTopics = 1
+	repo2NrOfTopics := 1
 	topics, _, err = FindTopics(&FindTopicOptions{})
 	assert.NoError(t, err)
 	assert.Len(t, topics, totalNrOfTopics)
diff --git a/models/user_email_test.go b/models/user_email_test.go
index bde0778b64..bed6a18867 100644
--- a/models/user_email_test.go
+++ b/models/user_email_test.go
@@ -111,14 +111,14 @@ func TestListEmails(t *testing.T) {
 
 	// Must find only primary addresses (i.e. from the `user` table)
 	opts = &SearchEmailOptions{IsPrimary: util.OptionalBoolTrue}
-	emails, count, err = SearchEmails(opts)
+	emails, _, err = SearchEmails(opts)
 	assert.NoError(t, err)
 	assert.True(t, contains(func(s *SearchEmailResult) bool { return s.IsPrimary }))
 	assert.False(t, contains(func(s *SearchEmailResult) bool { return !s.IsPrimary }))
 
 	// Must find only inactive addresses (i.e. not validated)
 	opts = &SearchEmailOptions{IsActivated: util.OptionalBoolFalse}
-	emails, count, err = SearchEmails(opts)
+	emails, _, err = SearchEmails(opts)
 	assert.NoError(t, err)
 	assert.True(t, contains(func(s *SearchEmailResult) bool { return !s.IsActivated }))
 	assert.False(t, contains(func(s *SearchEmailResult) bool { return s.IsActivated }))
diff --git a/modules/gitgraph/graph_test.go b/modules/gitgraph/graph_test.go
index c2726a731a..c805ff4647 100644
--- a/modules/gitgraph/graph_test.go
+++ b/modules/gitgraph/graph_test.go
@@ -55,11 +55,10 @@ func BenchmarkParseGlyphs(b *testing.B) {
 	parser.Reset()
 	tgBytes := []byte(testglyphs)
 	tg := tgBytes
-	idx := bytes.Index(tg, []byte("\n"))
 	for i := 0; i < b.N; i++ {
 		parser.Reset()
 		tg = tgBytes
-		idx = bytes.Index(tg, []byte("\n"))
+		idx := bytes.Index(tg, []byte("\n"))
 		for idx > 0 {
 			parser.ParseGlyphs(tg[:idx])
 			tg = tg[idx+1:]
diff --git a/modules/nosql/manager_leveldb.go b/modules/nosql/manager_leveldb.go
index 769d5002d0..eeb0cf74d9 100644
--- a/modules/nosql/manager_leveldb.go
+++ b/modules/nosql/manager_leveldb.go
@@ -48,13 +48,12 @@ func (m *Manager) GetLevelDB(connection string) (*leveldb.DB, error) {
 
 		return db.db, nil
 	}
-	dataDir := connection
 	uri := ToLevelDBURI(connection)
 	db = &levelDBHolder{
 		name: []string{connection, uri.String()},
 	}
 
-	dataDir = path.Join(uri.Host, uri.Path)
+	dataDir := path.Join(uri.Host, uri.Path)
 	opts := &opt.Options{}
 	for k, v := range uri.Query() {
 		switch replacer.Replace(strings.ToLower(k)) {
diff --git a/modules/web/middleware/binding.go b/modules/web/middleware/binding.go
index cbdb29b812..9b0b1d7784 100644
--- a/modules/web/middleware/binding.go
+++ b/modules/web/middleware/binding.go
@@ -93,11 +93,9 @@ func Validate(errs binding.Errors, data map[string]interface{}, f Form, l transl
 	AssignForm(f, data)
 
 	typ := reflect.TypeOf(f)
-	val := reflect.ValueOf(f)
 
 	if typ.Kind() == reflect.Ptr {
 		typ = typ.Elem()
-		val = val.Elem()
 	}
 
 	if field, ok := typ.FieldByName(errs[0].FieldNames[0]); ok {
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index 2fc72f0620..28ffac4dd3 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -91,7 +91,6 @@ func TeamsAction(ctx *context.Context) {
 			return
 		}
 		err = ctx.Org.Team.RemoveMember(uid)
-		page = "team"
 		if err != nil {
 			if models.IsErrLastOrgOwner(err) {
 				ctx.Flash.Error(ctx.Tr("form.last_org_owner"))