This ticket is about adding the unparam lint check to the repository. The way to go about it would be to add
diff --git a/.golangci.yml b/.golangci.yml
index 71c041aa5..5a8769a0a 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -27,6 +27,7 @@ linters:
- unused
- varcheck
- misspell
+ - unparam
# TODO: enable this later
# - errcheck
in the .golangci.yml file.
And then fix all issues that arise until make golangci-lint passes with no errors.
Please assign it to me.
Should I just ignore the errors using blank identifier _
or rm unused params from function signatures and rm the arguments?
For instance:
func (s SqlChannelStore) get(id string, master bool, allowFromCache bool) (*model.Channel, error) {}
Here allowFromCache
is unused.
Case 1:
func (s SqlChannelStore) get(id string, master bool, _ bool) (*model.Channel, error) {}
s.get(id, false, allowFromCache)
Case 2:
func (s SqlChannelStore) get(id string, master bool) (*model.Channel, error) {}
s.get(id, false)
Yes, please use _ where it's necessary to maintain the function signature. In this case, ChannelStore is an interface, so we need to do that.
Yes, please use _ where it's necessary to maintain the function signature. In this case, ChannelStore is an interface, so we need to do that.
In case of methods which doesn't have to satisfy an interface?
Go ahead and remove them. But leave out the model package. We can take a look at it case-by-case in the PR.
Clarification required.
app/server_test.go:263:67: `checkEndpoint` - `expectedStatus` always receives `http.StatusNotFound` (`404`) (unparam)
func checkEndpoint(t *testing.T, client *http.Client, url string, expectedStatus int) error {
Either we need to create a test case with any other expectedStatus
except http.StatusNotFound
or rm the expectedStatus
from function signature.
Similar case:
app/helper_test.go:45:99: `setupTestHelper` - `configSet` always receives `nil` (unparam)
func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer bool, tb testing.TB, configSet func(*model.Config)) *TestHelper {
You can remove them.