Skip to content

Commit

Permalink
chore(linter): update golangci.yaml
Browse files Browse the repository at this point in the history
add new linters

See: 42
  • Loading branch information
lasiar committed May 18, 2024
1 parent c95bb7d commit 0d16827
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
70 changes: 34 additions & 36 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ linters:
fast: false

enable:
# Globals and init() are no ok, because this linter use on golangci lint.
- gochecknoglobals
- gochecknoinits
# Check for pass []any as any in variadic func(...any).
# Rare case but saved me from debugging a few times.
- asasalint
Expand All @@ -58,6 +61,12 @@ linters:
# Check whether the function uses a non-inherited context.
- contextcheck

# after go 1.22 don't need copy var at for range.
- copyloopvar

# Find duplicate words, rare.
- dupword

# Check for two durations multiplied together.
- durationcheck

Expand All @@ -73,6 +82,10 @@ linters:
# Checks for pointers to enclosing loop variables.
- exportloopref


# Imports order.
- gci

# As you already know I'm a co-author. It would be strange to not use
# one of my warmly loved projects.
- gocritic
Expand Down Expand Up @@ -104,9 +117,15 @@ linters:
# Last week I caught a bug with it.
- ineffassign

# range over int, work after go 1.22
- intrange

# Fix all the misspells, amazing thing.
- misspell

# Reports wrong mirror patterns of bytes/strings usage.
- mirror

# Finds naked/bare returns and requires change them.
- nakedret

Expand All @@ -121,6 +140,9 @@ linters:
# Better not to have //nolint: at all ;)
- nolintlint

# aiming at usages of fmt.Sprintf which have faster alternatives.
- perfsprint

# Finds slices that could potentially be pre-allocated.
# Small performance win + cleaner code.
- prealloc
Expand All @@ -144,6 +166,9 @@ linters:
- rowserrcheck
- sqlclosecheck

# Ensure consistent code style when using log/slog.
- sloglint

# I have found that it's not the same as staticcheck binary :\
- staticcheck

Expand All @@ -156,6 +181,7 @@ linters:
# Test-related checks. All of them are good.
- tenv
- testableexamples
- testifylint
- thelper
- tparallel

Expand Down Expand Up @@ -202,9 +228,6 @@ linters:
# Tool for code clone detection.
- dupl

# Find duplicate words, rare.
- dupword

# I'm fine to check the error from json.Marshal ¯\_(ツ)_/¯
- errchkjson

Expand All @@ -225,19 +248,12 @@ linters:
# I might have long but a simple function.
- funlen

# Imports order. I do this manually ¯\_(ツ)_/¯
- gci

# I'm not a fan of ginkgo and gomega packages.
- ginkgolinter

# Checks that compiler directive comments (//go:) are valid. Rare.
- gocheckcompilerdirectives

# Globals and init() are ok.
- gochecknoglobals
- gochecknoinits

# Same as `cyclop` linter (see above)
- gocognit
- goconst
Expand All @@ -247,7 +263,7 @@ linters:
- godox

# Check the error handling expressions. Too noisy.
- goerr113
- err113

# I don't use file headers.
- goheader
Expand All @@ -256,7 +272,7 @@ linters:
- golint

# Reports magic consts. Might be noisy but still good.
- gomnd
- mnd

# Allowed/blocked packages to import. I prefer to do it manually.
- gomodguard
Expand Down Expand Up @@ -335,6 +351,12 @@ linters:
- wsl

linters-settings:
gci:
sections:
- standard
- default
- localmodule

revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
Expand Down Expand Up @@ -378,7 +400,6 @@ linters-settings:
- name: banned-characters
severity: warning
disabled: false
arguments: ["Ω", "Σ", "σ", "7"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
severity: warning
Expand All @@ -404,9 +425,6 @@ linters-settings:
- name: comment-spacings
severity: warning
disabled: false
arguments:
- mypragma
- otherpragma
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming
- name: confusing-naming
severity: warning
Expand Down Expand Up @@ -444,8 +462,6 @@ linters-settings:
- name: defer
severity: warning
disabled: false
arguments:
- ["call-chain", "loop"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
- name: dot-imports
severity: warning
Expand All @@ -470,8 +486,6 @@ linters-settings:
- name: enforce-map-style
severity: warning
disabled: false
arguments:
- "make"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
- name: error-naming
severity: warning
Expand Down Expand Up @@ -530,8 +544,6 @@ linters-settings:
- name: indent-error-flow
severity: warning
disabled: false
arguments:
- "preserveScope"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming
- name: import-alias-naming
severity: warning
Expand All @@ -542,9 +554,6 @@ linters-settings:
- name: imports-blacklist
severity: warning
disabled: false
arguments:
- "crypto/md5"
- "crypto/sha1"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
severity: warning
Expand Down Expand Up @@ -632,8 +641,6 @@ linters-settings:
- name: superfluous-else
severity: warning
disabled: false
arguments:
- "preserveScope"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
- name: time-equal
severity: warning
Expand All @@ -646,10 +653,6 @@ linters-settings:
- name: var-naming
severity: warning
disabled: false
arguments:
- ["ID"] # AllowList
- ["VM"] # DenyList
- - upperCaseConst: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
- name: var-declaration
severity: warning
Expand All @@ -670,9 +673,6 @@ linters-settings:
- name: unhandled-error
severity: warning
disabled: false
arguments:
- "fmt.Printf"
- "myFunction"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
severity: warning
Expand All @@ -691,8 +691,6 @@ linters-settings:
- name: unused-receiver
severity: warning
disabled: false
arguments:
- allowRegex: "^_"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
severity: warning
Expand Down
1 change: 1 addition & 0 deletions analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
name = "Header"
)

//nolint:gochecknoglobals // struct is not big, can be skip.
var Analyzer = &analysis.Analyzer{
Name: "canonicalheader",
Doc: "canonicalheader checks whether net/http.Header uses canonical header",
Expand Down
1 change: 1 addition & 0 deletions cmd/initialismer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"slices"
)

//nolint:gochecknoglobals // this map no allocate at golangci-lint
var mustBeIgnore = [...]string{
"A-IM",
"Accept",
Expand Down

0 comments on commit 0d16827

Please sign in to comment.