Skip to content

Fix all golangci-lint warnings#3

Merged
andrew merged 1 commit intomainfrom
lint-fixes
Mar 26, 2026
Merged

Fix all golangci-lint warnings#3
andrew merged 1 commit intomainfrom
lint-fixes

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Mar 18, 2026

Resolves all 17 issues reported by golangci-lint with gocritic, gocognit, gocyclo, dupl, and mnd linters enabled.

  • Extract buildSegments, validateSegmentBrackets, appendTrailingDoubleStar from compilePattern to reduce cognitive complexity
  • Extract validateBracketAt from validateBrackets
  • Extract matchBracketElement and readBracketChar from matchBracket
  • Convert matchPosixClass from switch to map lookup to reduce cyclomatic complexity
  • Fix else { if } to else if in wildmatch.go
  • Replace magic number 2 with named constants (posixClassOffset, extraStarSegments)
  • Extract shared test helpers (initGitRepo, createCheckPaths, compareWithGit, setupMatcherRoot, setupScopedMatcher) to eliminate duplicate code across git-check-ignore test functions

Extract helpers to reduce cognitive/cyclomatic complexity and eliminate
duplicate code in both production and test files. Replace magic numbers
with named constants, fix else-if style issue, and convert POSIX class
matching from switch to map lookup.
@andrew andrew merged commit 5807ff7 into main Mar 26, 2026
4 checks passed
@andrew andrew deleted the lint-fixes branch March 26, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant