Skip to content
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

⚠️ Refactor golangci-lint config to remove false negatives #4657

Merged
merged 1 commit into from
May 24, 2021

Conversation

vincepri
Copy link
Member

What this PR does / why we need it:

During some audit of golangci-lint, it was found that one of the exclude
directives was matching a lot more than it should have.

The removal of the unwanted regex caused a large backlog of linting
errors to show up. This changeset brings in a refactor in the
golangci-lint configuration to make sure we catch more errors in the
linting process and enable more linters over time.

Marking this as an ⚠️ breaking change given that in some cases we're unexporting some variables that are only used internally.

/milestone v0.4
/kind release-blocking

@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone May 24, 2021
@k8s-ci-robot k8s-ci-robot added kind/release-blocking Issues or PRs that need to be closed before the next CAPI release cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 24, 2021
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 24, 2021
@vincepri vincepri force-pushed the golangci-refactor branch from 79b2ae8 to beed942 Compare May 24, 2021 18:42
@vincepri
Copy link
Member Author

sigs.k8s.io/cluster-api/test/framework
  Compatible changes:
  - PodListCondition: added
sigs.k8s.io/cluster-api/cmd/clusterctl/client/repository
  Incompatible changes:
  - NewComponents: changed from func(ComponentsInput) (*components, error) to func(ComponentsInput) (Components, error)
  - NewTemplate: changed from func(TemplateInput) (*template, error) to func(TemplateInput) (Template, error)
sigs.k8s.io/cluster-api/cmd/clusterctl/client/config
  Incompatible changes:
  - InjectConfigPaths: removed
sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4
  Incompatible changes:
  - ConflictingFileSourceMsg: removed
  - MissingSecretKeyMsg: removed
  - MissingSecretNameMsg: removed
  - PathConflictMsg: removed
sigs.k8s.io/cluster-api/errors
  Incompatible changes:
  - ErrNotImplemented: removed
sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster
  Incompatible changes:
  - Scheme: removed
sigs.k8s.io/cluster-api/test/framework/bootstrap
  Compatible changes:
  - KindClusterProvider: added
sigs.k8s.io/cluster-api/controllers/remote
  Incompatible changes:
  - ClusterCacheControllerName: removed
sigs.k8s.io/cluster-api/exp/controllers
  Incompatible changes:
  - ErrNoAvailableNodes: removed

@vincepri vincepri force-pushed the golangci-refactor branch from beed942 to d46e0cf Compare May 24, 2021 18:45
@vincepri
Copy link
Member Author

/retest

@sbueringer
Copy link
Member

/test pull-cluster-api-test-main

@fabriziopandini
Copy link
Member

fabriziopandini commented May 24, 2021

That's definitely a big PR, but I'm glad we are doing this now vs later in the cycle
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2021
@vincepri
Copy link
Member Author

@fabriziopandini @CecileRobertMichon Could you folks double check the incompatible changes from above?

.golangci.yml Show resolved Hide resolved
.golangci.yml Outdated
@@ -23,11 +23,10 @@ linters:
- nolintlint
- prealloc
- rowserrcheck
- scopelint
- exportloopref
Copy link
Member

Choose a reason for hiding this comment

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

I think the linters are sorted alphabetically

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a linter for that linter 🙃 ? I got no errors locally, but I'd rather not enforce something that cannot be tested/validated

Copy link
Member

@sbueringer sbueringer May 24, 2021

Choose a reason for hiding this comment

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

Nope, but I guess not every review comment can be enforced by linter and the list would be nicer to navigate if it stays sorted :) (although it's btw possible to integrate custom linters into golangci-lint :))

P.S. But if you want to keep it as, it's fine for me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it, although we should either automate that or just keep it random

@sbueringer
Copy link
Member

Apart from the two nits => lgtm

@fabriziopandini
Copy link
Member

@fabriziopandini @CecileRobertMichon Could you folks double check the incompatible changes from above?

@vincepri I double checked incompatible changes and all of them seems reasonable to me

During some audit of golangci-lint, it was found that one of the exclude
directives was matching a lot more than it should have.

The removal of the unwanted regex caused a large backlog of linting
errors to show up. This changeset brings in a refactor in the
golangci-lint configuration to make sure we catch more errors in the
linting process and enable more linters over time.

Signed-off-by: Vince Prignano <[email protected]>
@vincepri vincepri force-pushed the golangci-refactor branch from d46e0cf to af33e43 Compare May 24, 2021 19:39
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2021
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2021
@sbueringer
Copy link
Member

@vincepri ex > er but close enough :)

/lgtm

@k8s-ci-robot
Copy link
Contributor

@vincepri: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cluster-api-apidiff-main af33e43 link /test pull-cluster-api-apidiff-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@vincepri
Copy link
Member Author

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/release-blocking Issues or PRs that need to be closed before the next CAPI release lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants