From 705c72d2939a875978d77badad2b56f7e6eb6ca0 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Sat, 1 Jun 2024 11:46:31 +0200 Subject: [PATCH] build: enable gocritic linter Running with default set of checks, except disabling the following - appendAssign: append result not assigned to the same slice (diagnostics check, many false positives) - captLocal: using capitalized names for local variables (style check, too opinionated) - commentFormatting: not having a space between `//` and comment text (style check, too opinionated) - exitAfterDefer: log.Fatalln will exit, and `defer func(){...}(...)` will not run (diagnostics check, to be revisited) - ifElseChain: rewrite if-else to switch statement (style check, many occurrences and a bit opinionated, to be revisited) - singleCaseSwitch: should rewrite switch statement to if statement (style check, many occurrences and a bit opinionated, to be revisited) --- .golangci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 0d61df700..f4092493a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -13,6 +13,7 @@ linters: - stylecheck - unused - misspell + - gocritic #- prealloc #- maligned disable-all: true @@ -98,3 +99,11 @@ linters-settings: # Only enable the checks performed by the staticcheck stand-alone tool, # as documented here: https://staticcheck.io/docs/configuration/options/#checks checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023"] + gocritic: + disabled-checks: + - appendAssign + - captLocal + - commentFormatting + - exitAfterDefer + - ifElseChain + - singleCaseSwitch