From c3bd94e841e433cb00a5e56fb296299979058b1e Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Fri, 4 Nov 2022 22:43:45 +0400 Subject: [PATCH 01/16] updated --- .github/workflows/lint.yml | 14 +- .golangci.yml | 456 ++++++++++++++++++++++++++++++++++++- Makefile | 9 +- 3 files changed, 472 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 58b2e8b..5a70e38 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,8 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: jobs: - golangci_lint: + lint: + name: Linters runs-on: ubuntu-latest steps: - name: Install Go @@ -23,3 +24,14 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 + with: + # Specify a version instead of 'latest' + # because of something wrong with 1.48.0 + version: v1.50.1 + args: + --config=./.golangci.yml + + - name: staticcheck + uses: dominikh/staticcheck-action@v1.2.0 + with: + version: "2022.1.1" \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index b21c936..5c53692 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ # This file configures github.com/golangci/golangci-lint. run: + go: '1.18' timeout: 3m tests: true # default is true. Enables skipping of directories: @@ -8,14 +9,13 @@ run: skip-dirs-use-default: true service: - golangci-lint-version: 1.47.3 + golangci-lint-version: 1.50.1 linters: disable-all: true enable: - whitespace # Tool for detection of leading and trailing whitespace - wsl # Forces you to use empty lines - - wastedassign # Finds wasted assignment statements - unconvert # Unnecessary type conversions - tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes - thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers @@ -37,15 +37,467 @@ linters: - dupl # Code clone detection - errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13 + - ineffassign # Detects when assignments to existing variables are not used + - bodyclose # checks whether HTTP response body is closed successfully + - contextcheck # check the function whether use a non-inherited context + - decorder # check declaration order and count of types, constants, variables and functions + - exhaustive # check exhaustiveness of enum switch statements and map literals + - exportloopref # checks for pointers to enclosing loop variables + - gocognit + - gomoddirectives + - nestif # Reports deeply nested if statements + - nilerr # Finds the code that returns nil even if it checks that the error is not nil. + - nilnil # Checks that there is no simultaneous return of nil error and an invalid value. + - noctx # noctx finds sending http request without context.Context + - paralleltest + - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 + - nlreturn + - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases + - gosimple # Linter for Go source code that specializes in simplifying code + - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string + - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code + - unused # Checks Go code for unused constants, variables, functions and types + - containedctx # containedctx is a linter that detects struct contained context.Context field + - cyclop # checks function and package cyclomatic complexity + - durationcheck # check for two durations multiplied together + - errchkjson + - gochecknoglobals # check that no global variables exist + - goerr113 # Golang linter to check the errors handling expressions + - gomnd # An analyzer to detect magic numbers. + - ireturn # Accept Interfaces, Return Concrete Types + - nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. + - promlinter # Check Prometheus metrics naming via promlint + - reassign # Checks that package variables are not reassigned + - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. + - usestdlibvars # A linter that detect the possibility to use variables/constants from the Go standard library. + + # is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649 + #- wastedassign # wastedassign finds wasted assignment statements. linters-settings: gofmt: simplify: true + goconst: min-len: 3 min-occurrences: 3 + numbers: true + + goimports: + local-prefixes: github.com/0xPolygon/go-ibft + + nestif: + min-complexity: 3 + + prealloc: + for-loops: true + + gocritic: + # Which checks should be enabled; can't be combined with 'disabled-checks'; + # See https://go-critic.github.io/overview#checks-overview + # To check which checks are enabled run `GL_DEBUG=gocritic ./build/bin/golangci-lint run` + # By default list of stable checks is used. + enabled-checks: + - badLock + - filepathJoin + - sortSlice + - sprintfQuotedString + - syncMapLoadAndDelete + - weakCond + - boolExprSimplify + - httpNoBody + - ioutilDeprecated + - nestingReduce + - preferFilepathJoin + - redundantSprint + - stringConcatSimplify + - timeExprSimplify + - typeAssertChain + - yodaStyleExpr + - truncateCmp + - equalFold + - preferDecodeRune + - preferFprint + - preferStringWriter + - preferWriteByte + - sliceClear + #- ruleguard + + # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty + disabled-checks: + - regexpMust + - exitAfterDefer + - dupBranchBody + - singleCaseSwitch + - unlambda + - captLocal + - commentFormatting + - ifElseChain + - importShadow + - builtinShadow + + # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. + # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". + enabled-tags: + - performance + - diagnostic + - opinionated + - style + disabled-tags: + - experimental + + cyclop: + skip-tests: true + + govet: + disable: + - deepequalerrors + - fieldalignment + - shadow + - unsafeptr + check-shadowing: true + enable-all: true +# settings: +# printf: +# # Run `go tool vet help printf` to see available settings for `printf` analyzer. +# funcs: +# - (github.com/ethereum/go-ethereum/log.Logger).Trace +# - (github.com/ethereum/go-ethereum/log.Logger).Debug +# - (github.com/ethereum/go-ethereum/log.Logger).Info +# - (github.com/ethereum/go-ethereum/log.Logger).Warn +# - (github.com/ethereum/go-ethereum/log.Logger).Error +# - (github.com/ethereum/go-ethereum/log.Logger).Crit + + revive: + ignore-generated-header: true + severity: error + enable-all-rules: true + # Sets the default failure confidence. + # This means that linting errors with less than 0.8 confidence will be ignored. + # Default: 0.8 + confidence: 0.1 + rules: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant + - name: add-constant + severity: warning + disabled: false + arguments: + - maxLitCount: "3" + allowStrs: '""' + allowInts: "0,1,2" + allowFloats: "0.0,0.,1.0,1.,2.0,2." + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit + - name: argument-limit + severity: warning + disabled: false + arguments: [ 4 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic + - name: atomic + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters + - name: banned-characters + severity: warning + disabled: false + arguments: [ "Ω", "Σ", "σ", "7" ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return + - name: bare-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports + - name: blank-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr + - name: bool-literal-in-expr + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc + - name: call-to-gc + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity + - name: cognitive-complexity + severity: warning + disabled: false + arguments: [ 7 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming + - name: confusing-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results + - name: confusing-results + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr + - name: constant-logical-expr + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument + - name: context-as-argument + severity: warning + disabled: false + arguments: + - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type + - name: context-keys-type + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic + - name: cyclomatic + severity: warning + disabled: false + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace + - name: datarace + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit + - name: deep-exit + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer + - name: defer + severity: warning + disabled: false + arguments: + - [ "call-chain", "loop" ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports + - name: dot-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports + - name: duplicated-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return + - name: early-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block + - name: empty-block + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines + - name: empty-lines + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming + - name: error-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return + - name: error-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings + - name: error-strings + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf + - name: errorf + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported + - name: exported + severity: warning + disabled: false + arguments: + - "checkPrivateReceivers" + - "sayRepetitiveInsteadOfStutters" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header + - name: file-header + severity: warning + disabled: false + arguments: + - This is the text that must appear at the top of source files. + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter + - name: flag-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit + - name: function-result-limit + severity: warning + disabled: false + arguments: [ 2 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length + - name: function-length + severity: warning + disabled: false + arguments: [ 10, 0 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return + - name: get-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches + - name: identical-branches + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return + - name: if-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement + - name: increment-decrement + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow + - name: indent-error-flow + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist + - name: imports-blacklist + severity: warning + disabled: false + arguments: + - "crypto/md5" + - "crypto/sha1" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing + - name: import-shadowing + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit + - name: line-length-limit + severity: warning + disabled: false + arguments: [ 80 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs + - name: max-public-structs + severity: warning + disabled: false + arguments: [ 3 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter + - name: modifies-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver + - name: modifies-value-receiver + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs + - name: nested-structs + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order + - name: optimize-operands-order + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments + - name: package-comments + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range + - name: range + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure + - name: range-val-in-closure + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address + - name: range-val-address + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming + - name: receiver-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id + - name: redefines-builtin-id + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int + - name: string-of-int + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format + - name: string-format + severity: warning + disabled: false + arguments: + - - 'core.WriteError[1].Message' + - '/^([^A-Z]|$)/' + - must not start with a capital letter + - - 'fmt.Errorf[0]' + - '/(^|[^\.!?])$/' + - must not end in punctuation + - - panic + - '/^[^\n]*$/' + - must not contain line breaks + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag + - name: struct-tag + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else + - name: superfluous-else + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal + - name: time-equal + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming + - name: time-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + disabled: false + arguments: + - [ "ID" ] # AllowList + - [ "VM" ] # DenyList + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration + - name: var-declaration + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion + - name: unconditional-recursion + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming + - name: unexported-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return + - name: unexported-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error + - name: unhandled-error + severity: warning + disabled: false + arguments: + - "fmt.Printf" + - "myFunction" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt + - name: unnecessary-stmt + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code + - name: unreachable-code + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter + - name: unused-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver + - name: unused-receiver + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break + - name: useless-break + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value + - name: waitgroup-by-value + severity: warning + disabled: false issues: + max-issues-per-linter: 0 + max-same-issues: 0 new-from-rev: origin/main # report only new issues with reference to develop branch whole-files: true exclude-rules: diff --git a/Makefile b/Makefile index 4d0761e..f5a29f7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ -.PHONY: lint +.PHONY: lint install-deps + lint: - golangci-lint run -E whitespace -E wsl -E wastedassign -E unconvert -E tparallel -E thelper -E stylecheck -E prealloc \ - -E predeclared -E nlreturn -E misspell -E makezero -E lll -E importas -E ifshort -E gosec -E gofmt -E goconst \ - -E forcetypeassert -E dogsled -E dupl -E errname -E errorlint -E nolintlint --timeout 2m + ./build/bin/golangci-lint run --config ./.golangci.yml +install-deps: + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.50.1 From 1ab821c1091b7575c80ea7396bbab61d7c50bb21 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Fri, 4 Nov 2022 22:59:28 +0400 Subject: [PATCH 02/16] run all --- .golangci.yml | 2 +- Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 5c53692..509c58b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -360,7 +360,7 @@ linters-settings: - name: line-length-limit severity: warning disabled: false - arguments: [ 80 ] + arguments: [ 180 ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs - name: max-public-structs severity: warning diff --git a/Makefile b/Makefile index f5a29f7..b68ed67 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ .PHONY: lint install-deps +FIRST_COMMIT ?= $(shell git rev-list --max-parents=0 HEAD) lint: ./build/bin/golangci-lint run --config ./.golangci.yml +lint-all: + ./build/bin/golangci-lint run --config ./.golangci.yml --new-from-rev=$(FIRST_COMMIT) + install-deps: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.50.1 From eda7db4776e9e7183ea3a52578f48e2c334f0565 Mon Sep 17 00:00:00 2001 From: Evgeny Danilenko <6655321@bk.ru> Date: Tue, 8 Nov 2022 11:33:39 +0300 Subject: [PATCH 03/16] Update .github/workflows/lint.yml Co-authored-by: Victor Castell --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5a70e38..0bea167 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -34,4 +34,4 @@ jobs: - name: staticcheck uses: dominikh/staticcheck-action@v1.2.0 with: - version: "2022.1.1" \ No newline at end of file + version: "2022.1.1" From c9338da51dbca47f79445e454e3c76220ec24cba Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Tue, 8 Nov 2022 14:16:02 +0400 Subject: [PATCH 04/16] count parallel code --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a97ab3b..c81bbcd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: submodules: recursive - name: Go test - run: go test -shuffle=on -coverprofile coverage.out -timeout 28m ./... + run: go test -covermode=atomic -shuffle=on -coverprofile coverage.out -timeout 28m ./... - name: Upload coverage file to Codecov uses: codecov/codecov-action@v3 From 3abce5792714071a6e27007719c869a7b7f76d68 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Wed, 9 Nov 2022 12:10:12 +0400 Subject: [PATCH 05/16] cr --- .golangci.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 509c58b..d72bada 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -123,19 +123,6 @@ linters-settings: - sliceClear #- ruleguard - # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty - disabled-checks: - - regexpMust - - exitAfterDefer - - dupBranchBody - - singleCaseSwitch - - unlambda - - captLocal - - commentFormatting - - ifElseChain - - importShadow - - builtinShadow - # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". enabled-tags: From dc6e4c5736a88a8a5f4c93e6cb4ba73e10436197 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 16:30:27 +0400 Subject: [PATCH 06/16] linters --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c2a4140..c3ac31d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,7 +7,7 @@ on: # yamllint disable-line rule:truthy paths: - '**.go' workflow_call: - workflow_dispatch: + pull_request: jobs: lint: From 4987b088047c1971f7ddf4b353adfe38c96e690d Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:19:03 +0400 Subject: [PATCH 07/16] linters --- .github/workflows/lint.yml | 2 -- .golangci.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c3ac31d..c4be02b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,8 +25,6 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 with: - # Specify a version instead of 'latest' - # because of something wrong with 1.48.0 version: v1.50.1 args: --config=./.golangci.yml diff --git a/.golangci.yml b/.golangci.yml index d72bada..92c2ce2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -87,7 +87,7 @@ linters-settings: local-prefixes: github.com/0xPolygon/go-ibft nestif: - min-complexity: 3 + min-complexity: 4 prealloc: for-loops: true From 407a44c1a839db558428c272d19052fe3ffaa243 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:20:01 +0400 Subject: [PATCH 08/16] linters --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 92c2ce2..a89c6e2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -485,7 +485,7 @@ linters-settings: issues: max-issues-per-linter: 0 max-same-issues: 0 - new-from-rev: origin/main # report only new issues with reference to develop branch + new-from-rev: main # report only new issues with reference to develop branch whole-files: true exclude-rules: - path: _test\.go From 8e6689a0dfd7299ff62e71c60dfb4bd3519a03d9 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:25:15 +0400 Subject: [PATCH 09/16] linters --- .github/workflows/lint.yml | 5 +++++ .golangci.yml | 2 ++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c4be02b..8d76ebd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,6 +21,8 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + with: + fetch-depth: '0' - name: Lint uses: golangci/golangci-lint-action@v3 @@ -29,6 +31,9 @@ jobs: args: --config=./.golangci.yml + - name: main + run: git fetch origin master && git branch master remotes/origin/master + - name: staticcheck uses: dominikh/staticcheck-action@v1.2.0 with: diff --git a/.golangci.yml b/.golangci.yml index a89c6e2..ab7684b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -486,6 +486,8 @@ issues: max-issues-per-linter: 0 max-same-issues: 0 new-from-rev: main # report only new issues with reference to develop branch + #new-from-rev: "" + new: false whole-files: true exclude-rules: - path: _test\.go From 7df4651e31b8742f075efa74e707b549a7bf3ba4 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:26:07 +0400 Subject: [PATCH 10/16] linters --- .github/workflows/lint.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8d76ebd..c33acf9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,6 +24,9 @@ jobs: with: fetch-depth: '0' + - name: fetch main + run: git fetch origin master && git branch master remotes/origin/master + - name: Lint uses: golangci/golangci-lint-action@v3 with: @@ -31,9 +34,6 @@ jobs: args: --config=./.golangci.yml - - name: main - run: git fetch origin master && git branch master remotes/origin/master - - name: staticcheck uses: dominikh/staticcheck-action@v1.2.0 with: From bd2af4be12eaefc8afca1229be10c2ce4769afb5 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:27:15 +0400 Subject: [PATCH 11/16] linters --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c33acf9..deee26a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: '0' - name: fetch main - run: git fetch origin master && git branch master remotes/origin/master + run: git fetch origin main && git branch main remotes/origin/main - name: Lint uses: golangci/golangci-lint-action@v3 From 4ae09001a3f438f9cedb7be78372ffa5c2dbf9d2 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:30:02 +0400 Subject: [PATCH 12/16] linters --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index deee26a..b4292da 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,3 +38,4 @@ jobs: uses: dominikh/staticcheck-action@v1.2.0 with: version: "2022.1.1" + install-go: false From 43b331f8946f4204650f4f2506466ef02002de52 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:32:39 +0400 Subject: [PATCH 13/16] use io.copy --- build/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/main.go b/build/main.go index f531304..72fd21d 100644 --- a/build/main.go +++ b/build/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "io" + "strings" "github.com/0xPolygon/go-ibft/core" ) @@ -11,5 +12,5 @@ func main() { b := core.NewIBFT(nil, nil, nil) // prevent golang compiler from removing the whole function - fmt.Sprint(io.Discard, b) + io.Copy(io.Discard, strings.NewReader(fmt.Sprint(b))) } From e6ffef73a9529bd46253058ebf032c8462b88c13 Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:34:55 +0400 Subject: [PATCH 14/16] linters --- build/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/main.go b/build/main.go index 72fd21d..7d71608 100644 --- a/build/main.go +++ b/build/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "io" - "strings" "github.com/0xPolygon/go-ibft/core" ) @@ -12,5 +11,5 @@ func main() { b := core.NewIBFT(nil, nil, nil) // prevent golang compiler from removing the whole function - io.Copy(io.Discard, strings.NewReader(fmt.Sprint(b))) + _, _ = fmt.Fprint(io.Discard, b) } From e350dc612049d56a1f8c381e74cdfebe2e3a3c3d Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:38:57 +0400 Subject: [PATCH 15/16] linters --- .golangci.yml | 2 +- build/main.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index ab7684b..7f4683f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -295,7 +295,7 @@ linters-settings: # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header - name: file-header severity: warning - disabled: false + disabled: true arguments: - This is the text that must appear at the top of source files. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter diff --git a/build/main.go b/build/main.go index 7d71608..37411d7 100644 --- a/build/main.go +++ b/build/main.go @@ -1,3 +1,4 @@ +// this is a dummy package only for checking builds package main import ( From 8d231b55df5a7d8eba64fea0060742dbebb5f05b Mon Sep 17 00:00:00 2001 From: Evgeny Danienko <6655321@bk.ru> Date: Thu, 10 Nov 2022 23:44:50 +0400 Subject: [PATCH 16/16] linters --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b4292da..aa21d94 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,7 +30,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 with: - version: v1.50.1 + version: latest args: --config=./.golangci.yml