Skip to content
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

chore(linter): add 6 more linteres #3333

Merged
merged 9 commits into from
Apr 29, 2024
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
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ run:

linters:
enable:
- bidichk
- bodyclose
# - depguard as of v1.54.2, the default config throws errors on our repo
- dogsled
Expand All @@ -12,6 +13,8 @@ linters:
# - funlen
# - gochecknoglobals
# - gochecknoinits
- exportloopref
- gocheckcompilerdirectives
- goconst
- gocritic
# - gocyclo
Expand All @@ -27,13 +30,15 @@ linters:
- ineffassign
# - interfacer
- lll
- loggercheck
- misspell
# - maligned
- nakedret
- nilerr
- nilnil
- nolintlint
- prealloc
- protogetter
# - scopelint - deprecated since v1.39. exportloopref will be used instead
- exportloopref
- staticcheck
Expand All @@ -45,6 +50,8 @@ linters:
# - whitespace
# - wsl
# - gocognit
- wastedassign
- whitespace
- nolintlint
- asciicheck

Expand Down
1 change: 0 additions & 1 deletion api/docgen/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ func ExampleValue(t, parent reflect.Type) (interface{}, error) {
case reflect.Interface:
return struct{}{}, nil
}

return nil, fmt.Errorf("failed to retrieve example value for type: %s on parent '%s')", t, parent)
}

Expand Down
10 changes: 4 additions & 6 deletions api/docgen/openrpc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Package docgen generates an OpenRPC spec for the Celestia Node. It has been inspired by and
// adapted from Filecoin's Lotus API implementation.

//nolint:revive
package docgen

import (
Expand Down Expand Up @@ -163,7 +161,7 @@ func NewOpenRPCDocument(comments, permissions Comments) *go_openrpc_reflect.Docu
}

// remove the default implementation from the method descriptions
appReflector.FnGetMethodDescription = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) {
appReflector.FnGetMethodDescription = func(_ reflect.Value, m reflect.Method, _ *ast.FuncDecl) (string, error) {
if v, ok := permissions[m.Name]; ok {
return "Auth level: " + v, nil
}
Expand All @@ -172,14 +170,14 @@ func NewOpenRPCDocument(comments, permissions Comments) *go_openrpc_reflect.Docu

appReflector.FnGetMethodName = func(
moduleName string,
r reflect.Value,
_ reflect.Value,
m reflect.Method,
funcDecl *ast.FuncDecl,
_ *ast.FuncDecl,
) (string, error) {
return moduleName + "." + m.Name, nil
}

appReflector.FnGetMethodSummary = func(r reflect.Value, m reflect.Method, funcDecl *ast.FuncDecl) (string, error) {
appReflector.FnGetMethodSummary = func(_ reflect.Value, m reflect.Method, _ *ast.FuncDecl) (string, error) {
if v, ok := comments[extractPackageNameFromAPIMethod(m)+m.Name]; ok {
return v, nil
}
Expand Down
1 change: 0 additions & 1 deletion blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (p Proof) equal(input Proof) error {
if !bytes.Equal(proof.LeafHash(), input[i].LeafHash()) {
return ErrInvalidProof
}

}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cel-shed/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var p2pCmd = &cobra.Command{
var p2pNewKeyCmd = &cobra.Command{
Use: "new-key",
Short: "Generate and print new Ed25519 private key for p2p networking",
RunE: func(cmd *cobra.Command, _ []string) error { //nolint:revive
RunE: func(_ *cobra.Command, _ []string) error {
privkey, _, err := crypto.GenerateEd25519Key(rand.Reader)
if err != nil {
return err
Expand All @@ -42,7 +42,7 @@ var p2pNewKeyCmd = &cobra.Command{
var p2pPeerIDCmd = &cobra.Command{
Use: "peer-id",
Short: "Get peer-id out of public or private Ed25519 key",
RunE: func(cmd *cobra.Command, args []string) error { //nolint:revive
RunE: func(_ *cobra.Command, args []string) error {
decKey, err := hex.DecodeString(args[0])
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion das/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@ func (o *checkOrder) addInterval(start, end uint64) *checkOrder {
return o
}
start--

}
return o
}
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/fraud/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ func (breaker *ServiceBreaker[S, H]) awaitProof() {
}

if err := breaker.Stop(breaker.ctx); err != nil && !errors.Is(err, context.Canceled) {
log.Errorw("stopping service: %s", err.Error())
log.Errorw("stopping service", "err", err.Error())
}
}
2 changes: 1 addition & 1 deletion share/eds/retriever_no_race_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// go:build !race
//go:build !race

package eds

Expand Down
2 changes: 1 addition & 1 deletion share/getters/shrex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func addToNamespace(namespace share.Namespace, val int) (share.Namespace, error)
// Perform addition byte by byte
var carry int
for i := len(namespace) - 1; i >= 0; i-- {
sum := 0
var sum int
if val > 0 {
sum = int(namespace[i]) + int(result[i]) + carry
} else {
Expand Down
2 changes: 1 addition & 1 deletion share/p2p/discovery/discovery_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// go:build !race
//go:build !race

package discovery

Expand Down
1 change: 0 additions & 1 deletion share/p2p/peers/timedqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func TestTimedQueue(t *testing.T) {
case <-popCh:
case <-time.After(ttl):
t.Fatal("first item is not released")

}
require.Equal(t, queue.len(), 1)

Expand Down
6 changes: 3 additions & 3 deletions state/core_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*B
Prove: true,
}
opts := rpcclient.ABCIQueryOptions{
Height: abciReq.Height,
Prove: abciReq.Prove,
Height: abciReq.GetHeight(),
Prove: abciReq.GetProve(),
}
result, err := ca.rpcCli.ABCIQueryWithOptions(ctx, abciReq.Path, abciReq.Data, opts)
result, err := ca.rpcCli.ABCIQueryWithOptions(ctx, abciReq.GetPath(), abciReq.GetData(), opts)
if err != nil {
return nil, err
}
Expand Down
Loading