Skip to content

Commit

Permalink
Merge pull request #45 from saschagrunert/lint
Browse files Browse the repository at this point in the history
Update golangci-lint and fix lints
  • Loading branch information
k8s-ci-robot authored Jul 8, 2024
2 parents 3f924ca + 055a0f0 commit b3c912f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 83 deletions.
86 changes: 9 additions & 77 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
run:
concurrency: 6
deadline: 5m
timeout: 5m
issues:
linters:
disable-all: true
Expand All @@ -10,9 +10,11 @@ linters:
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- cyclop
- decorder
- dogsled
- dupl
Expand All @@ -22,9 +24,9 @@ linters:
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
- exportloopref
- fatcontext
- forcetypeassert
- funlen
- gci
Expand Down Expand Up @@ -59,6 +61,7 @@ linters:
- makezero
- mirror
- misspell
- mnd
- musttag
- nakedret
- nestif
Expand Down Expand Up @@ -97,14 +100,12 @@ linters:
- whitespace
- wrapcheck
- zerologlint
# - cyclop
# - depguard
# - err113
# - exhaustruct
# - forbidigo
# - gochecknoglobals
# - gochecknoinits
# - goerr113
# - gomnd
# - ireturn
# - lll
# - nlreturn
Expand All @@ -113,6 +114,8 @@ linters:
# - varnamelen
# - wsl
linters-settings:
cyclop:
max-complexity: 15
godox:
keywords:
- BUG
Expand All @@ -122,75 +125,4 @@ linters-settings:
check-type-assertions: true
check-blank: true
gocritic:
enabled-checks:
- appendCombine
- badLock
- badRegexp
- badSorting
- badSyncOnceFunc
- boolExprSimplify
- builtinShadow
- builtinShadowDecl
- commentedOutCode
- commentedOutImport
- deferInLoop
- deferUnlambda
- docStub
- dupImport
- dynamicFmtString
- emptyDecl
- emptyFallthrough
- emptyStringTest
- equalFold
- evalOrder
- exposedSyncMutex
- externalErrorReassign
- filepathJoin
- hexLiteral
- httpNoBody
- hugeParam
- importShadow
- indexAlloc
- initClause
- methodExprCall
- nestingReduce
- nilValReturn
- octalLiteral
- paramTypeCombine
- preferDecodeRune
- preferFilepathJoin
- preferFprint
- preferStringWriter
- preferWriteByte
- ptrToRefParam
- rangeExprCopy
- rangeValCopy
- redundantSprint
- regexpPattern
- regexpSimplify
- returnAfterHttpError
- ruleguard
- sliceClear
- sloppyReassign
- sortSlice
- sprintfQuotedString
- sqlQuery
- stringConcatSimplify
- stringXbytes
- stringsCompare
- syncMapLoadAndDelete
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- truncateCmp
- typeAssertChain
- typeDefFirst
- typeUnparen
- uncheckedInlineErr
- unlabelStmt
- unnamedResult
- unnecessaryBlock
- unnecessaryDefer
- weakCond
- whyNoLint
- yodaStyleExpr
enable-all: true
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module sigs.k8s.io/mdtoc

go 1.21
go 1.22

require (
github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -o errexit
set -o nounset
set -o pipefail

VERSION=v1.57.1
VERSION=v1.59.1
URL_BASE=https://raw.githubusercontent.com/golangci/golangci-lint
URL=$URL_BASE/$VERSION/install.sh

Expand Down
3 changes: 0 additions & 3 deletions mdtoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func testdata(subpath string) string {
func TestDryRun(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
opts := utilityOptions{
Expand All @@ -111,7 +110,6 @@ func TestDryRun(t *testing.T) {
func TestInplace(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
original, err := os.ReadFile(test.file)
Expand Down Expand Up @@ -157,7 +155,6 @@ func TestInplace(t *testing.T) {
func TestOutput(t *testing.T) {
t.Parallel()
for _, test := range testcases {
test := test
// Ignore the invalid cases, they're only for inplace tests.
if !test.validTOCTags {
continue
Expand Down
3 changes: 2 additions & 1 deletion pkg/mdtoc/mdtoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ func GetTOC(file string, opts Options) (string, error) {
// A temporary file is used so no changes are made to the original in the case of an error.
func atomicWrite(filePath string, chunks ...string) error {
tmpPath := filePath + "_tmp"
tmp, err := os.OpenFile(tmpPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600)
const perms = 0o600
tmp, err := os.OpenFile(tmpPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perms)
if err != nil {
return fmt.Errorf("unable to open tepmorary file %s: %w", tmpPath, err)
}
Expand Down

0 comments on commit b3c912f

Please sign in to comment.