Skip to content

Commit

Permalink
lint config
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Sep 13, 2024
1 parent e4f1698 commit b9194b2
Showing 1 changed file with 66 additions and 118 deletions.
184 changes: 66 additions & 118 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ run:
concurrency: 4

# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
timeout: 1m

# exit code when at least one issue was found, default is 1
issues-exit-code: 1
Expand All @@ -19,50 +19,18 @@ run:
build-tags:
- mytag

# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-dirs:
- .github
- .make
- dist

# default is true. Enables skipping of directories:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work
# on Windows.
skip-files:
- ".*\\.my\\.go$"
- lib/bad.go

# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
# If invoked with -mod=readonly, the go command is disallowed from the implicit
# automatic updating of go.mod described above. Instead, it fails when any changes
# to go.mod are needed. This setting is most useful to check that go.mod does
# not need updates, such as in a continuous integration and testing system.
# If invoked with -mod=vendor, the go command assumes that the vendor
# directory holds the correct copies of dependencies and ignores
# the dependency descriptions in go.mod.
#modules-download-mode: readonly|release|vendor
# skip-dirs-use-default: true

# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false


# output configuration options
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
# formats:
# - colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand All @@ -76,7 +44,6 @@ output:
# add a prefix to the output file references; default is no prefix
path-prefix: ""


# all available settings of specific linters
linters-settings:
dogsled:
Expand All @@ -94,14 +61,11 @@ linters-settings:
# default is false: such cases aren't reported by default.
check-blank: false

# [deprecated] comma-separated list of pairs of the form pkg:regex
# the regex is used to ignore names within pkg. (default "fmt:.*").
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
ignore: fmt:.*,io/ioutil:^Read.*
# use exclude-functions instead of ignore
exclude-functions:
- fmt:.*
- io/ioutil:^Read.*

# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
#exclude: /path/to/file.txt
exhaustive:
# indicates that switch statements are to be considered exhaustive if a
# 'default' case is present, even if all enum members aren't listed in the
Expand All @@ -111,10 +75,10 @@ linters-settings:
lines: 60
statements: 40
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/org/project
sections:
- Standard
- Default
- Prefix(github.com/org/project)
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
Expand Down Expand Up @@ -166,16 +130,16 @@ linters-settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
goheader:
values:
const:
# define here const type values in format k:v, for example:
# YEAR: 2020
# COMPANY: MY COMPANY
regexp:
# define here regexp type values, for example
# AUTHOR: .*@mycompany\.com
template:
# goheader:
# values:
# const:
# # define here const type values in format k:v, for example:
# # YEAR: 2020
# # COMPANY: MY COMPANY
# regexp:
# # define here regexp type values, for example
# # AUTHOR: .*@mycompany\.com
# template:
# put here copyright header template for source code files, for example:
# {{ AUTHOR }} {{ COMPANY }} {{ YEAR }}
# SPDX-License-Identifier: Apache-2.0
Expand All @@ -191,20 +155,25 @@ linters-settings:
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
template-path:
# template-path:
# also as alternative of directive 'template' you may put the path to file with the template source
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/org/project
gomnd:
settings:
mnd:
# the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
checks: argument,case,condition,operation,return,assign
# gomnd:
# checks:
# - argument
# - case
# - condition
# - operation
# - return
# - assign
# ignored-numbers: [] # Add numbers here if needed
# ignored-files: [] # Add file patterns to ignore if needed
# ignored-functions: [] # Add function patterns to ignore if needed
govet:
# report about shadowed variables
check-shadowing: true
# Removed deprecated `check-shadowing` option

# settings per analyzer
settings:
Expand All @@ -219,17 +188,17 @@ linters-settings:
enable:
- atomicalign
enable-all: false
disable:
# disable:
#- shadow
disable-all: false
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/sirupsen/logrus
packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
# depguard:
# list-type: blacklist
# include-go-root: false
# packages:
# - github.com/sirupsen/logrus
# packages-with-error-message:
# # specify an error message to output when a blacklisted package is used
# - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
Expand All @@ -245,7 +214,7 @@ linters-settings:
- bsv
- bitcoin
nakedret:
# make an issue if func has more lines of code than this setting, and it has naked returns; default is 30
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
max-func-lines: 30
prealloc:
# XXX: we don't recommend using this linter before doing performance profiling.
Expand All @@ -260,7 +229,7 @@ linters-settings:
# Enable to ensure that nolint directives are all used. Default is true.
allow-unused: false
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: true
# allow-leading-space: true
# Exclude following linters from requiring an explanation. Default is [].
allow-no-explanation: []
# Enable to require an explanation of nonzero length after each nolint directive. Default is false.
Expand All @@ -279,12 +248,12 @@ linters-settings:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
unused:
# unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
# check-exported: false
whitespace:
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
Expand All @@ -305,28 +274,19 @@ linters-settings:
force-case-trailing-whitespace: 0
# Force cuddling of err checks with err var assignment
force-err-cuddling: false
# Allow leading comments to be separated with empty liens
# Allow leading comments to be separated with empty lines
allow-separated-leading-comment: false
gofumpt:
# Choose whether or not to use the extra rules that are disabled
# by default
extra-rules: false

# The custom section can be used to define linter plugins to be loaded at runtime. See README doc
# for more info.
custom:
# Each custom linter should have a unique name.
#example:
# The path to the plugin *.so. Can be absolute or local. Required for each custom linter
#path: /path/to/example.so
# The description of the linter. Optional, just for documentation purposes.
#description: This is an example usage of a plugin linter.
# Intended to point to the repo location of the linter. Optional, just for documentation purposes.
#original-url: github.com/golangci/example-linter

# linters configuration
linters:
enable:
- megacheck
- gosimple
- staticcheck
- unused
- govet
- gosec
- bodyclose
Expand All @@ -336,19 +296,20 @@ linters:
- misspell
- dogsled
- prealloc
- exportloopref
- copyloopvar
- exhaustive
- sqlclosecheck
- nolintlint
- gci
- goconst
- lll
# - shadow # Added as per the deprecation notice
disable:
- gocritic # use this for very opinionated linting
- gochecknoglobals
- whitespace
- wsl
- goerr113
- err113
- godot
- testpackage
- nestif
Expand All @@ -359,12 +320,17 @@ linters:
- unused
fast: false


# issues configuration
issues:
exclude-files:
- ".*\\.my\\.go$"
- lib/bad.go
exclude-dirs:
- .github
- .make
- dist

# 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:
- abcdef

Expand All @@ -377,7 +343,6 @@ issues:
- errcheck
- dupl
- gosec
- maligned
- lll

# Exclude known linters from partially hard-vendored code,
Expand Down Expand Up @@ -415,38 +380,21 @@ issues:

# Show only new issues: if there are unstaged changes or untracked files,
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
# It's a super-useful option for integration of golangci-lint into existing
# large codebase. It's not practical to fix all existing issues at the moment
# of integration: much better don't allow issues in new code.
# Default is false.
new: false

# Show only new issues created after git revision `REV`
new-from-rev: ""

# Show only new issues created in git patch with set file path.
#new-from-patch: path/to/patch/file

# severity configuration
severity:
# Default value is empty string.
# Set the default severity for issues. If severity rules are defined and the issues
# do not match or no severity is provided to the rule this will be the default
# severity applied. Severities should match the supported severity names of the
# selected out format.
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
default-severity: error

# The default value is false.
# If set to true severity-rules regular expressions become case sensitive.
case-sensitive: false

# Default value is empty list.
# When a list of severity rules are provided, severity information will be added to lint
# issues. Severity rules have the same filtering capability as exclude rules except you
# are allowed to specify one matcher per severity rule.
# Only affects out formats that support setting severity information.
rules:
- linters:
- dupl
Expand Down

0 comments on commit b9194b2

Please sign in to comment.