From 3e95215cee1d03cdea21c03767e5e2b0c743f5a8 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Tue, 26 Apr 2022 13:24:42 +0200 Subject: [PATCH] chore(lint): simplify .golangci.yml (#2480) - Set timeout to 10min, remove timeout flag from Makefile - Remove copy pasted comments from example .golangci.yml - Add URL at the top to the .golangci.yml configuration documentation webpage - Remove linter settings for linters not enabled `dupl` and `gocritic` - Remove default `fast: false` - Limit to default 50 errors per linter, instead of no limit - Limit to default 3 same issues, instead of no limit - Remove `megacheck` linter which is no longer available - Remove copyright notice (not really anything to protect) --- .golangci.yml | 86 ++++----------------------------------------------- Makefile | 2 +- 2 files changed, 7 insertions(+), 81 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e4be225d6e..1e89644f0c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,26 +1,8 @@ -# Copyright 2019 ChainSafe Systems (ON) Corp. -# This file is part of gossamer. -# -# The gossamer library is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The gossamer library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with the gossamer library. If not, see . - -# Source: https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml -# options for analysis running +# See https://golangci-lint.run/usage/configuration/#config-file + run: - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 5m + deadline: 10m - # list of build tags, all linters use it. Default is empty list. build-tags: - integration @@ -28,18 +10,11 @@ run: - .*mock_.*\.go - .*mocks\/.*\.go -# all available settings of specific linters linters-settings: govet: # report about shadowed variables check-shadowing: true - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - dupl: - # tokens count to trigger issue, 150 by default - threshold: 100 depguard: list-type: blacklist include-go-root: false @@ -54,28 +29,13 @@ linters-settings: tab-width: 1 misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. locale: UK ignore-words: - gossamer - flavor - gocritic: - # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty - disabled-checks: - - regexpMust # TODO remove this, `regexpMust` should be at global scope. - - # 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 - - settings: # settings passed to gocritic - captLocal: # must be valid enabled check name - paramsOnly: true - rangeValCopy: - sizeThreshold: 32 + - finalized + - finalize + - initialize linters: enable: @@ -93,8 +53,6 @@ linters: - govet - ineffassign - lll - - megacheck - - megacheck - misspell - nilerr - nilnil @@ -105,18 +63,8 @@ linters: - unparam - varcheck - fast: false - issues: - # List of regexps of issue texts to exclude, empty list by default. - # But independently from this option we use default exclude patterns, - # it can be disabled by `exclude-use-default: false`. To list all - # excluded by default patterns execute `golangci-lint run --help` - #exclude: - - # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - # Exclude some linters from running on tests files. - path: _test\.go linters: - gocyclo @@ -141,18 +89,6 @@ issues: linters: - govet - - text: "`finalized` is a misspelling of `finalised`" - linters: - - misspell - - - text: "`finalize` is a misspelling of `finalise`" - linters: - - misspell - - - text: "`initialize` is a misspelling of `initialise`" - linters: - - misspell - - linters: - revive text: "package comment should be of the form" @@ -183,14 +119,4 @@ issues: linters: - gosec - # Independently from option `exclude` we use default exclude patterns, - # it can be disabled by this option. To list all - # excluded by default patterns execute `golangci-lint run --help`. - # Default value for this option is true. exclude-use-default: false - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 diff --git a/Makefile b/Makefile index 40efe95b21..40926cb548 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ help: Makefile .PHONY: lint lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45 - golangci-lint run --build-tags integration --timeout 10m + golangci-lint run clean: rm -fr ./bin