Skip to content

golangci-lint: Migrate to v2 #303

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

Merged
merged 2 commits into from
May 13, 2025

Conversation

vyasgun
Copy link
Contributor

@vyasgun vyasgun commented May 5, 2025

This PR does the following:

  • Migrate golangci-lint to v2 schema
  • Fix lint errors after migration

Copy link

sourcery-ai bot commented May 5, 2025

Reviewer's Guide

This pull request migrates the golangci-lint configuration to the v2 schema by updating the .golangci.yml file structure, reorganizing linters and formatters, and adding exclusions. The golangci-lint installation command in tools.mk is also updated. Several minor code adjustments were made to satisfy the updated linting rules.

Class Diagram: Updated USBMassStorage Struct

classDiagram
    class USBMassStorage {
      +string ImagePath
      +bool ReadOnly
      +SetReadOnly(bool readOnly) void
      +toVz() vz.StorageDeviceConfiguration, error
      +AddToVirtualMachineConfig(vmConfig *VirtualMachineConfiguration) error
    }
    note for USBMassStorage "ReadOnly field is now accessed directly (previously via StorageConfig)."
Loading

File-Level Changes

Change Details Files
Migrated .golangci.yml to the v2 schema.
  • Set version: "2".
  • Removed the top-level run section.
  • Moved gofmt and goimports from linters.enable to the new formatters.enable section.
  • Removed errcheck and unused linters (potentially covered by others or defaults).
  • Added exclusions sections for both linters and formatters to ignore generated code, specific paths, and apply presets.
.golangci.yml
Updated the golangci-lint installation command.
  • Modified the go install command to fetch the v2 version of golangci-lint (github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest).
tools/tools.mk
Corrected minor linting issues.
  • Removed redundant type conversions.
  • Ensured error messages start with a lowercase letter.
  • Corrected field access in USBMassStorage.SetReadOnly.
  • Fixed variable access in test helper.
pkg/vf/virtio.go
pkg/config/virtio.go
pkg/cmdline/string_slice.go
cmd/vfkit/timesync.go
pkg/vf/bootloader.go
pkg/vf/vm.go
test/vm_helpers.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@openshift-ci openshift-ci bot requested review from anjannath and praveenkumar May 5, 2025 07:53
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @vyasgun - I've reviewed your changes - here's some feedback:

  • Was the removal of the errcheck and unused linters intentional?
  • Using presets under linters.exclusions appears non-standard; review if issues.exclude-rules might be more appropriate for disabling specific checks.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@vyasgun vyasgun moved this to Ready for review in Project planning: crc May 5, 2025
@vyasgun vyasgun force-pushed the pr/golangci-v2 branch 2 times, most recently from bf5471c to bf10189 Compare May 6, 2025 16:23
@vyasgun vyasgun self-assigned this May 7, 2025
@vyasgun vyasgun force-pushed the pr/golangci-v2 branch 2 times, most recently from 19a7aed to ae6ad83 Compare May 7, 2025 13:32
Copy link
Collaborator

@cfergeau cfergeau left a comment

Choose a reason for hiding this comment

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

@cfergeau
Copy link
Collaborator

Can you squash go.mod changes for golangci-lint migration with golangci-lint: migrate configuration to v2 schema?

Apart from this, looks good to me!

@vyasgun vyasgun requested a review from cfergeau May 13, 2025 09:26
@cfergeau
Copy link
Collaborator

/lgtm
/approve

Copy link

openshift-ci bot commented May 13, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfergeau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 039a4c3 into crc-org:main May 13, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Done in Project planning: crc May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants