feat: add golangci-lint config and apply Go best practices#29
Merged
Conversation
- Add .golangci.yml with 19 linters (defaults + bodyclose, errorlint, noctx, gosec, errname, gocritic, misspell, revive, gocognit, perfsprint, unconvert, usetesting) - Add package doc comments to all packages - Replace fmt.Errorf with errors.New for static error strings - Replace context.Background() with t.Context() in tests - Use Go 1.13+ octal literal syntax (0o644 instead of 0644) - Fix misspelling: cancelled -> canceled - Combine same-type function parameters - Refactor resolveAndElevateUnified and runFavoritesAddWithDeps to reduce cognitive complexity below gocognit threshold of 40 - Add -trimpath to Makefile and .goreleaser.yaml for reproducible builds - Use CommitDate and mod_timestamp in .goreleaser.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.golangci.ymlwith 19 linters enabled (defaults + bodyclose, errorlint, noctx, gosec, errname, gocritic, misspell, revive, gocognit, perfsprint, unconvert, usetesting) with tuned exclusions for test files and Cobra conventionsfmt.Errorf->errors.New, ~40context.Background()->t.Context(), octal literals, misspellings, param combining, else-if simplification)resolveAndElevateUnified(complexity 57 -> under 40) andrunFavoritesAddWithDeps(complexity 56 -> under 40) by extracting helper functions-trimpathflag andCommitDate/mod_timestampto Makefile and.goreleaser.yamlfor reproducible buildsTest plan
make testpasses (all existing tests)make lintpasses with zero issuesgo vet ./...passesmake buildproduces a working binary with-trimpath