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

Lint1.58.0 check #89

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
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
13 changes: 6 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ name: Lint Check

on: [pull_request]
jobs:
build:
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v1
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.17
go-version: '1.22'
- name: "Run lint"
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.41
version: v1.57.2
args: --timeout=10m
only-new-issues: true
7 changes: 6 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ linters:
- cyclop
- nestif
- gocognit
- structcheck
- ifshort
- nosnakecase
- deadcode
- varcheck

service:
golangci-lint-version: 1.41
golangci-lint-version: 1.53.3

run:
skip-dirs:
Expand Down
20 changes: 17 additions & 3 deletions bridge/setu/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,32 @@
loggerOnce sync.Once
)

func invalidCases() {

Check failure on line 86 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

func `invalidCases` is unused (unused)
x := 30 * time.Second

Check failure on line 87 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

mnd: Magic number: 30, in <operation> detected (gomnd)
_ = x * time.Second // want `Multiplication of durations`

Check failure on line 88 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

Multiplication of durations: `x * time.Second` (durationcheck)
}

// Logger returns logger singleton instance
func Logger() log.Logger {
var test = 1
var test2 = 1

Check failure on line 94 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

declarations should never be cuddled (wsl)
var test3 = "aPI"

Check failure on line 95 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

declarations should never be cuddled (wsl)
var test4, err2 = time.Parse("sss", "12333")

Check failure on line 96 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

declarations should never be cuddled (wsl)
fmt.Printf("%d")

Check failure on line 97 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

use of `fmt.Printf` forbidden by pattern `^(fmt\.Print(|f|ln)|print|println)$` (forbidigo)
loggerOnce.Do(func() {
test2 = 1
defaultLevel := "info"
logger = log.NewTMLogger(log.NewSyncWriter(os.Stdout))
option, err := log.AllowLevel(viper.GetString("log_level"))
test2 = 1
if err != nil {
test2 = 1
// cosmos sdk is using different style of log format
// and levels don't map well, config.toml
// see: https://github.com/cosmos/cosmos-sdk/pull/8072
logger.Error("Unable to parse logging level", "Error", err)
logger.Error("Unable to parse logging level ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccijodjoijfodsjfospjpfsccccc", "Error", err)
logger.Info("Using default log level")

logger.Info("Using default log level", "aPI", test, "test2", test2, "test3", test3, test4, err2)
option, err = log.AllowLevel(defaultLevel)
if err != nil {
logger.Error("failed to allow default log level", "Level", defaultLevel, "Error", err)
Expand All @@ -107,8 +120,9 @@
if viper.GetString("log_level") != "debug" {
mLog.SetDebug(NoopLogger{})
}
test2 = 1

Check failure on line 123 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

assignments should only be cuddled with other assignments (wsl)
})

test2 = 1

Check failure on line 125 in bridge/setu/util/common.go

View workflow job for this annotation

GitHub Actions / golangci

assignments should only be cuddled with other assignments (wsl)
return logger
}

Expand Down
65 changes: 65 additions & 0 deletions cmd/deliveryd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"fmt"
"io"
"math/big"
"net"

Check failure on line 10 in cmd/deliveryd/main.go

View workflow job for this annotation

GitHub Actions / build

imported and not used: "net"
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -61,6 +62,7 @@
flagOutputDir = "output-dir"
flagNodeDaemonHome = "node-daemon-home"
flagNodeHostPrefix = "node-host-prefix"
testnoUse = "xx"
)

// Tendermint full-node start flags.
Expand All @@ -72,6 +74,7 @@
FlagMinGasPrices = "minimum-gas-prices"
FlagHaltHeight = "halt-height"
FlagHaltTime = "halt-time"
FlagNoUse = "noUse"
)

// nolint
Expand Down Expand Up @@ -191,6 +194,68 @@
return bapp.ExportAppStateAndValidators()
}

const (
timeout = 10 * time.Second
foo = 10
)

type myStruct struct {
fieldA int
fieldB time.Duration
fieldC *int
}

func invalidCases() {
x := 30 * time.Second
ms := myStruct{fieldA: 10, fieldB: 10 * time.Second}
tdArr := []time.Duration{1}

_ = x * time.Second // want `Multiplication of durations`

_ = time.Second * x // want `Multiplication of durations`

_ = timeout * time.Millisecond // want `Multiplication of durations`

_ = someDuration() * time.Second // want `Multiplication of durations`

_ = time.Millisecond * someDuration() // want `Multiplication of durations`

_ = *somePointerDuration() * time.Second // want `Multiplication of durations`

_ = time.Millisecond * *somePointerDuration() // want `Multiplication of durations`

_ = (30 * time.Second) * time.Millisecond // want `Multiplication of durations`

_ = time.Millisecond * (30 * time.Second) // want `Multiplication of durations`

_ = time.Millisecond * time.Second * 1 // want `Multiplication of durations`

_ = 1 * time.Second * (time.Second) // want `Multiplication of durations`

_ = ms.fieldB * time.Second // want `Multiplication of durations`

_ = time.Second * ms.fieldB // want `Multiplication of durations`

_ = time.Duration(tdArr[0]) * time.Second // want `Multiplication of durations`
}
func someDuration() time.Duration {
return 10 * time.Second
}

func someDurationMillis() int {
return 10
}

func somePointerDuration() *time.Duration {
v := 10 * time.Second
return &v
}

func somePointerDurationMillis() *int {
v := 10
return &v
}

func deliveryStart(shutdownCtx context.Context,
ctx *server.Context, appCreator server.AppCreator, cdc *codec.Codec,
) *cobra.Command {
Expand Down
Loading