From ceb2d485e98d12a0d6212bc5ffc3f32769f1351d Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Wed, 3 Apr 2024 16:46:23 +0200 Subject: [PATCH 1/3] golangci: add lll linter with `new-from-rev` flag This commit adds the lll linter to the golangci-lint configuration file. This forces the code to be formatted with a maximum line length of 80 and a tab width of 8. The `deadline` configuration is replaced with `timeout`. `deadline` is deprecated since v1.20 and will be removed in v1.57.0. The `new-from-rev` flag allows to run linters only on the files changed since the given revision. Since we can assume that the code adheres to linting standards before said revision there are no old errors that we now ignore and this ensures that new code adheres to the additional restrictions from `lll`. --- .golangci.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d8690c064..0369ae569 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: # timeout for analysis - deadline: 4m + timeout: 4m linters-settings: errorlint: @@ -26,13 +26,18 @@ linters-settings: exhaustive: default-signifies-exhaustive: true gocritic: - enabled-checks: - - singleCaseSwitch - - ifElseChain - - assignOp - - unlambda + enabled-checks: + - singleCaseSwitch + - ifElseChain + - assignOp + - unlambda staticcheck: - checks: ["-SA1019"] + checks: ['-SA1019'] + lll: + # Max line length, lines longer will be reported. + line-length: 80 + # Tab width in spaces. + tab-width: 8 linters: enable: @@ -46,6 +51,7 @@ linters: - unconvert - nilerr - exhaustive + - lll issues: exclude-rules: @@ -66,3 +72,4 @@ issues: - unused - deadcode - varcheck + new-from-rev: c118c9095a3175d1d311fa9bf6555b44aa8d3912 From edd3ae53b9b4aa7d64766c0f0c86177e7352c704 Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Thu, 4 Apr 2024 14:45:49 +0200 Subject: [PATCH 2/3] golangci: update `new-from-rev` to latest commit --- .golangci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.golangci.yml b/.golangci.yml index 0369ae569..4a7453d66 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -72,4 +72,4 @@ issues: - unused - deadcode - varcheck - new-from-rev: c118c9095a3175d1d311fa9bf6555b44aa8d3912 + new-from-rev: c723abd3c9db8a6a2f3f1eaa85ce5aefb52c8170 From 73e5439a0b1e8056605db7745485e1c176cdcb70 Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Thu, 4 Apr 2024 15:56:10 +0200 Subject: [PATCH 3/3] github: add `fetch-depth: 0` to the checkout When using `new-from-rev` the CI linting returns `can't prepare diff by revgrep` because of the shallow checkout. --- .github/workflows/main.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bed37acb0..ac2f6539c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,13 +3,13 @@ name: CI on: push: branches: - - "main" + - 'main' pull_request: branches: - - "*" + - '*' merge_group: branches: - - "main" + - 'main' defaults: run: @@ -110,13 +110,13 @@ jobs: - name: Build default image uses: docker/build-push-action@v4 with: - tags: "default-taproot-assets" + tags: 'default-taproot-assets' - name: Build dev image uses: docker/build-push-action@v4 with: file: dev.Dockerfile - tags: "dev-taproot-assets" + tags: 'dev-taproot-assets' ######################## # cross compilation @@ -143,6 +143,8 @@ jobs: steps: - name: git checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup go environment uses: ./.github/actions/setup-go