Run golangci-lint automatically - #7
Conversation
WalkthroughThe pull request introduces several modifications to enhance linting and pre-commit validation for Go projects. A new job named 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This runs golangci-lint via pre-commit locally, and via the official github action [1] in our pre-commit workflow. [1]: https://github.com/golangci/golangci-lint-action
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/pre-commit.yaml (1)
18-30: New GolangCI-lint Job Configuration is Well-Structured
The newly introducedgolangci-lintjob correctly sets up the Go environment and invokes the linting tool usinggolangci/golangci-lint-action@v7with versionv2.0.
- Note: It would be worthwhile to verify that version
v2.0is fully compatible with your project requirements and that any additional golangci-lint configurations (if needed) are provided either in a configuration file or inline.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.github/workflows/pre-commit.yaml(1 hunks).golangci.yml(0 hunks).pre-commit-config-ci.yaml(1 hunks).pre-commit-config.yaml(1 hunks)
💤 Files with no reviewable changes (1)
- .golangci.yml
🔇 Additional comments (4)
.pre-commit-config-ci.yaml (2)
1-13: Pre-commit Hooks (General) Configuration Looks Solid
The configuration from the pre-commit-hooks repository (v5.0.0) covers an extensive set of checks (trailing whitespace, merge conflicts, etc.) which is excellent for enforcing code quality.
14-21: YAML Lint Hook Configuration is Robust
The yamllint hook is well-configured with strict mode enabled and excludes theconfig/directory as intended. This should help catch YAML syntax issues effectively..github/workflows/pre-commit.yaml (1)
15-16: Extra Arguments Update for Pre-commit Action
Adding the parameterextra_args: -c .pre-commit-config-ci.yamldirects the pre-commit action to use the CI-specific configuration file. This improves consistency between local and CI checks..pre-commit-config.yaml (1)
23-30: Local GolangCI-lint Hook Addition is Correctly Configured
The new local repository hook forgolangci-lintis integrated properly:
- It targets files with the
.goextension.- Uses the system-installed version via
language: system.- Disables passing filenames (using
pass_filenames: false), which is appropriate if golangci-lint is configured to scan the repository as a whole rather than individual files.
Make sure that this setting aligns with your intended workflow for locally invoking the linter.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/pre-commit.yaml (1)
15-16: Extra Args Configuration for Pre-Commit Action
The added parameterextra_args: -c .pre-commit-config-ci.yamlensures that the pre-commit hook uses a custom configuration for CI. Please verify that the file.pre-commit-config-ci.yamlexists in the repository root and is maintained in sync with local development settings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.github/workflows/pre-commit.yaml(1 hunks).golangci.yml(3 hunks).pre-commit-config-ci.yaml(1 hunks).pre-commit-config.yaml(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- .pre-commit-config.yaml
- .pre-commit-config-ci.yaml
🔇 Additional comments (6)
.github/workflows/pre-commit.yaml (1)
18-29: New golangci-lint Job Integration
The newgolangci-lintjob is correctly defined. It checks out the repository, sets up the Go environment with the stable version, and subsequently runs the linting action usinggolangci/golangci-lint-action@v7withversion: v2.0. Please confirm that v2.0 is the desired version for your linting policies, as newer versions might offer additional features or fixes..golangci.yml (5)
5-8: Updated Linters Configuration
Replacingdisable-all: truewithdefault: noneallows for a more granular enabling of selected linters. The enabled linters (e.g.,dupl,errcheck, etc.) now reflect explicit choices, which enhances maintainability.
14-14: Activation of the 'lll' Linter
The addition of thellllinter in the enable list is a valuable enhancement to catch long line issues. Ensure that any custom thresholds (if needed) are configured elsewhere in the file or in your CI settings.
23-27: Revive Linter Settings Enhancement
The introduction of a dedicatedsettingsblock for therevivelinter—with specific rules such ascomment-spacings—improves the granularity of code style checking. Double-check that this rule conforms to your project's style guidelines.
27-40: Detailed Exclusions Configuration
The updated exclusions configuration now includes agenerated: laxflag along with explicit rules and paths (e.g., exclusions for files matchingapi/*,internal/*, and directories likethird_party,builtin, andexamples). Review these patterns carefully to ensure no essential files are skipped during linting.
45-50: Formatters Exclusions Added
The formatter configuration now includes an exclusions block that appliesgenerated: laxand omits formatting on specified paths, which helps avoid unintended changes to third-party or auto-generated code. This approach is clear and effective.
This runs golangci-lint via pre-commit locally, and via the official github action 1 in our pre-commit workflow.
Summary by CodeRabbit