Skip to content

Updated .golangci.yml from v1 to v2 #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

fyzanshaik
Copy link
Contributor

@fyzanshaik fyzanshaik commented Apr 20, 2025

Description

This PR fixes #710

Why?
Old config (v1) is unsupported, causing golangci-lint run to fail.

How?
Manual migration to v2, as auto-migration failed. Followed official docs.

Key Changes:

  • Linter settings now under linters.settings
  • New formatters section for gci
  • Exclusions now in linters.exclusions (need 2+ criteria)
  • linters.default: none replaces enable-all/disable-all
  • Removed run.timeout (ignored in v2)

Removed:

  • golint, scopelint, go-mod-tidy (no longer supported)
  • Original config comments

Outcome:
golangci-lint run now works with the new config.

References:

Signed commits

  • Yes, I signed my commits.

Signed-off-by: fyzanshaik <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @fyzanshaik, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request updates the .golangci.yml configuration file from v1 to v2 format. The previous configuration was outdated and caused golangci-lint run to fail. The configuration was manually migrated to the v2 format based on the official documentation, since automatic migration attempts failed. The PR removes the golint, scopelint, and go-mod-tidy linters, as they are no longer supported. The updated configuration now loads successfully and runs the analysis.

Highlights

  • Configuration Update: The .golangci.yml file has been updated from v1 to v2 format to resolve configuration loading errors.
  • Linter Changes: The golint, scopelint, and go-mod-tidy linters have been removed due to incompatibility with the current golangci-lint version.
  • Manual Migration: The configuration was manually migrated to v2 format, as automatic migration attempts were unsuccessful.
  • Exclusion Rules: Exclusion rules are now handled under linters.exclusions and require at least two matching criteria in v2.

Changelog

Click here to see the changelog
  • .golangci.bck.yml
    • This file is a backup of the original .golangci.yml file before the changes were applied.
  • .golangci.yml
    • Updated the configuration file to v2 format.
    • Removed the linters-settings section; linter settings are now under linters.settings.
    • Added a new formatters section; gci and its settings are moved there.
    • Handled exclusions (exclude-dirs, exclude-rules) under linters.exclusions.
    • Replaced linters.enable-all and linters.disable-all with linters.default: none.
    • Removed the run.timeout option.
    • Removed the golint, scopelint, and go-mod-tidy linters.
    • Added find-duplicates: true to goconst settings.
    • Updated cyclop average strictness to 12.
    • Added more paths to exclusions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Old configs cause much pain,
New versions bring back the gain.
Linting rules align,
Code quality will shine,
Errors vanish, all is sane.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the .golangci.yml configuration file to the v2 format. The migration seems to be done correctly, referring to the documentation for golangci-lint. The key changes in the new config (v2 vs Old) are well documented in the PR description. Overall, the changes look good, but I have a few suggestions for improvement.

Summary of Findings

  • Linter Configuration: The PR updates the .golangci.yml configuration file to the v2 format, addressing the issue of using an outdated configuration. This includes migrating settings, formatters, and exclusions to the new format. The removal of unsupported linters (golint, scopelint, and go-mod-tidy) is also noted.
  • Exclusion Rules: The exclusion rules in the v2 configuration require at least two matching criteria (e.g., text and path). The configuration now includes exclusion rules for testpackage based on both text and path.
  • Cyclop Configuration: The cyclop linter's average-strictness has been increased from 7 to 12. This might lead to more strictness checks, and the author should verify that this doesn't cause unexpected issues.

Merge Readiness

The code changes seem to be well-done, and the PR description is very detailed. I would recommend addressing the suggestions before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.

@fyzanshaik
Copy link
Contributor Author

Fixes CI build break by migrating .golangci.yml to v2. Review on the new config is needed to confirm lint standards(I am not entirely sure of this) did migrate most changes from current config to this . However Code fixes are a follow-up PR after this is merged.
Issues based on this lint yml config :
image

@Jougan-0
Copy link
Contributor

Hey @fyzanshaik ,
The lint checks fail because of the code not the workflow. If you want to tackle the first step would be looking at why the actions are failing.
Possible causes:

  1. Is the code faulty?
  2. Was an error not handled?
  3. Was there any deprecation of some utility function?
    Screenshot from 2025-04-20 23-53-55

If all these are fine then these lint checks would pass and you won't see any crosses under your PR.

Hope this helps. Please go ahead and make sure the above mention problems are not the issue. Then we can review this PR.

@fyzanshaik
Copy link
Contributor Author

fyzanshaik commented Apr 20, 2025

@Jougan-0 Thanks for the review! The code isn't faulty and all errors are being handled properly. Based on the CI
image golangci-lint config file is being rejected by the linter, not because of code , but because the config file itself is full of options that the linter doesn’t recognize or allow. The errors explicitly inform about it.
This means the config file is out of sync with the version of golangci-lint being used in CI. Upon reviewing the CI is using golangci-lint-1.64.8-linux-amd64 which means our config isn't updated.

There's an existing PR addressing this issue for the specific version 694 which addresses the same points and changes I have mentioned in this PR. I have overlooked upon golangci version the existing PR (694) should be the one we should merge, whereas my PR followed the guidelines for version golangci-lint 2.0.2 which isn't needed by the CI.

@hortison
Copy link
Member

PR abandoned.

@hortison hortison closed this Apr 21, 2025
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.

Failing lint jobs
3 participants