Skip to content

Commit

Permalink
updated for golangci-lint 1.62.0
Browse files Browse the repository at this point in the history
  • Loading branch information
na4ma4 committed Nov 14, 2024
1 parent a8f7371 commit eebf945
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
27 changes: 19 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021 Marat Reymers

## Golden config for golangci-lint v1.60.3
## Golden config for golangci-lint v1.62.0
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
Expand Down Expand Up @@ -89,6 +89,11 @@ linters-settings:
# Default false
ignore-comments: true

gochecksumtype:
# Presence of `default` case in switch statements satisfies exhaustiveness, if all members are not listed.
# Default: true
default-signifies-exhaustive: false

gocognit:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
Expand Down Expand Up @@ -147,6 +152,10 @@ linters-settings:
# Default: false
skip-single-param: true

misspell:
locale: UK
mode: default

mnd:
# List of function patterns to exclude from analysis.
# Values always ignored: `time.Date`,
Expand Down Expand Up @@ -265,6 +274,7 @@ linters:
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- iface # checks the incorrect use of interfaces, helping developers avoid interface pollution
- intrange # finds places where for loops could make use of an integer range
- lll # reports long lines
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
Expand All @@ -285,6 +295,7 @@ linters:
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- recvcheck # checks for receiver type consistency
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sloglint # ensure consistent code style when using log/slog
Expand All @@ -303,16 +314,16 @@ linters:
- whitespace # detects leading and trailing whitespace

## you may want to enable
#- decorder # checks declaration order and count of types, constants, variables and functions
- decorder # checks declaration order and count of types, constants, variables and functions
#- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
#- gci # controls golang package import order and makes it always deterministic
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
#- godox # detects FIXME, TODO and other comment keywords
#- goheader # checks is file header matches to pattern
#- inamedparam # [great idea, but too strict, need to ignore a lot of cases by default] reports interfaces with unnamed method parameters
- goheader # checks is file header matches to pattern
- inamedparam # [great idea, but too strict, need to ignore a lot of cases by default] reports interfaces with unnamed method parameters
#- interfacebloat # checks the number of methods inside an interface
#- ireturn # accept interfaces, return concrete types
#- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
#- tagalign # checks that struct tags are well aligned
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
#- wrapcheck # checks that errors returned from external packages are wrapped
Expand All @@ -326,20 +337,19 @@ linters:
#- dupword # [useless without config] checks for duplicate words in the source code
#- err113 # [too strict] checks the errors handling expressions
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
#- execinquery # [deprecated] checks query string in Query function which reads your Go src files and warning it finds
#- exportloopref # [not necessary from Go 1.22] checks for pointers to enclosing loop variables
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
#- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
- gosmopolitan # reports certain i18n/l10n anti-patterns in your Go codebase
#- grouper # analyzes expression groups
#- importas # enforces consistent import aliases
#- maintidx # measures the maintainability index of each function
#- misspell # [useless] finds commonly misspelled English words in comments
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
#- tagliatelle # checks the struct tags
#- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines


Expand All @@ -358,6 +368,7 @@ issues:
linters:
- bodyclose
- dupl
- errcheck
- funlen
- goconst
- gosec
Expand Down
16 changes: 8 additions & 8 deletions helper/etag.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ func (e *ETag) Set(key, value string) {
})
}

func (e ETag) GetItem(key string) *ETagItem {
for _, v := range e {
func (e *ETag) GetItem(key string) *ETagItem {
for _, v := range *e {
if v.Key == key {
v.parent = &e
v.parent = e
return &v
}
}

return &ETagItem{
parent: &e,
parent: e,
Key: key,
}
}

func (e ETag) GetRelative(path string) string {
func (e *ETag) GetRelative(path string) string {
after, ok := GetRelativePath(path)
if ok {
return e.Get(after)
Expand All @@ -87,8 +87,8 @@ func (e ETag) GetRelative(path string) string {
return path
}

func (e ETag) Get(key string) string {
for _, v := range e {
func (e *ETag) Get(key string) string {
for _, v := range *e {
if v.Key == key {
return v.Value
}
Expand All @@ -97,7 +97,7 @@ func (e ETag) Get(key string) string {
return ""
}

func (e ETag) Save() error {
func (e *ETag) Save() error {
MustMakeDir(MustGetArtifactPath(), permbits.MustString("ug=rwx,o=rx"))

var f *os.File
Expand Down

0 comments on commit eebf945

Please sign in to comment.