From c30e3a47621b97c867071a2b1a706e6c5132b1c2 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 18 Apr 2025 11:15:02 +0200 Subject: [PATCH] flake: add golang-lint lsp (#2507) Signed-off-by: Kristoffer Dalby --- .golangci.yaml | 131 +++++++++++++++++++++++++------------------------ flake.lock | 6 +-- flake.nix | 4 ++ 3 files changed, 75 insertions(+), 66 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index c6c574ed..becc14b1 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,74 +1,79 @@ --- -run: - timeout: 10m - build-tags: - - ts2019 - -issues: - skip-dirs: - - gen +version: "2" linters: - enable-all: true + default: all disable: - - revive - - lll - - gofmt + - cyclop + - depguard + - dupl + - exhaustruct + - funlen - gochecknoglobals - gochecknoinits - gocognit - - funlen - - tagliatelle - godox - - ireturn - - execinquery - - exhaustruct - - nolintlint - - musttag # causes issues with imported libs - - depguard - - exportloopref - - tenv - - # We should strive to enable these: - - wrapcheck - - dupl - - makezero - - maintidx - - # Limits the methods of an interface to 10. We have more in integration tests - interfacebloat - - # We might want to enable this, but it might be a lot of work - - cyclop + - ireturn + - lll + - maintidx + - makezero + - musttag - nestif - - wsl # might be incompatible with gofumpt - - testpackage + - nolintlint - paralleltest + - revive + - tagliatelle + - testpackage + - wrapcheck + - wsl + settings: + gocritic: + disabled-checks: + - appendAssign + - ifElseChain + nlreturn: + block-size: 4 + varnamelen: + ignore-names: + - err + - db + - id + - ip + - ok + - c + - tt + - tx + - rx + - sb + - wg + - pr + - p + - p2 + ignore-type-assert-ok: true + ignore-map-index-ok: true + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ + - gen -linters-settings: - varnamelen: - ignore-type-assert-ok: true - ignore-map-index-ok: true - ignore-names: - - err - - db - - id - - ip - - ok - - c - - tt - - tx - - rx - - sb - - wg - - pr - - p - - p2 - - gocritic: - disabled-checks: - - appendAssign - # TODO(kradalby): Remove this - - ifElseChain - - nlreturn: - block-size: 4 +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ + - gen diff --git a/flake.lock b/flake.lock index 5c58efbd..49e4ab6b 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e146591a..70be5c88 100644 --- a/flake.nix +++ b/flake.nix @@ -81,6 +81,9 @@ # golangci-lint = prev.golangci-lint.override { # buildGoModule = buildGo; # }; + # golangci-lint-langserver = prev.golangci-lint.override { + # buildGoModule = buildGo; + # }; goreleaser = prev.goreleaser.override { buildGoModule = buildGo; @@ -114,6 +117,7 @@ buildDeps ++ [ golangci-lint + golangci-lint-langserver golines nodePackages.prettier goreleaser