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

Personal/dabradley/lint #182

Merged

Conversation

dabradley
Copy link
Collaborator

What type of PR is this?

/kind cleanup

Any locking operation should have its unlock in a defer statement so
that the lock is cleanly unlocked in the event of any issues that
occur during the processing that occurs while the lock is held.
This helps make the method more readable since the concerns
it works on remain near the same level of abstraction. Pushing
these details into helper methods makes the logic of the publish
method more clear, while giving a clear name to these operations.
These are unnecessary in golang, so keeping all conditionals in
the expected format makes glancing through the logic easier by
ensuring each check is consistent.
Instead of having different linters and configuration options in
the various places we call golangci-lint, this changes how we
run it so that it uses a shared configuration. This prevents the
case where one of these checks would pass only to fail for the user
when the workflows are run prior to merging.
When testing for the existence or lack of errors, it is beneficial
to have the test fail at the first unexpected assertion. If we don't,
then it is likely that any further processing will obscure the original
failure, or even cause a panic in the test.
Improves failure reporting to have the function configured as a
testing helper to make the actual failure more clear.
It's not necessary to change the actual process's actual environment
to test these values. The t.Setenv functionality ensures that these
values are reset at the end of the test so that other testing is not
affected.
Shadowing existing language identifiers is unexpected and creates
error-prone expectations of how a given identfier might be used.
Since Go 1.22, the scope of loop variables has changed. It is no
longer necessary to copy loop vars to prevent accidental reuse.
The '%w' format automatically works with the unwrapping and wrapping
of the existing error to provide more useful debugging information.
Accessing nested protobuf fields directly allows for nil pointer
deferences. By forcing the use of getter methods, these chains
will not cause these errors and will simply return a nil/zero value
for the entire expression if one of the links does not exist.
Using named returns can create very brittle logic where zero
values are automatically created and returned and can easily
be missed by later maintainers. The existing usage did not
leverage the actual named return logic and can be safely
removed.
GCI ensures consistent and readable import ordering
For consistent logging and debugging, we should always be using the
existing logging framework, rather than printing to standard out.
We are alroady running gofmt, so this just adds further formatting
consistency.
@dabradley dabradley requested a review from t-mialve October 15, 2024 13:20
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Oct 15, 2024
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 15, 2024
@coveralls
Copy link

coveralls commented Oct 15, 2024

Coverage Status

coverage: 82.773% (+0.2%) from 82.552%
when pulling f81402e on dabradley:personal/dabradley/lint
into 2ed0f0d on kubernetes-sigs:development.

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 15, 2024
Copy link
Collaborator

@t-mialve t-mialve 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
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dabradley, t-mialve

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

@dabradley dabradley merged commit d583bcd into kubernetes-sigs:development Oct 16, 2024
9 of 10 checks passed
@dabradley dabradley deleted the personal/dabradley/lint branch October 16, 2024 11:54
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants