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

Fix and enforce linter #283

Merged
merged 2 commits into from
Jul 1, 2022
Merged

Fix and enforce linter #283

merged 2 commits into from
Jul 1, 2022

Conversation

jacobweinstock
Copy link
Member

@jacobweinstock jacobweinstock commented Jul 1, 2022

Description

This gets the repo to a baseline of linting based on the .golangci.yml file generated from running lint-install.

Why is this needed

Fixes: #63

How Has This Been Tested?

How are existing users impacted? What migration steps/scripts do we need?

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

This adds the scafolding for running golangci-lint.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
@jacobweinstock jacobweinstock added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jul 1, 2022
@codecov
Copy link

codecov bot commented Jul 1, 2022

Codecov Report

Merging #283 (4b4e5de) into main (5faab79) will decrease coverage by 0%.
The diff coverage is 34%.

@@         Coverage Diff         @@
##           main   #283   +/-   ##
===================================
- Coverage    37%    37%   -1%     
===================================
  Files        41     41           
  Lines      2787   2782    -5     
===================================
- Hits       1037   1032    -5     
- Misses     1680   1683    +3     
+ Partials     70     67    -3     
Impacted Files Coverage Δ
client/client.go 0% <ø> (ø)
client/instance.go 35% <0%> (ø)
client/kubernetes/cluster.go 0% <ø> (ø)
client/kubernetes/hardware_finder.go 0% <0%> (ø)
client/noop_reporter.go 0% <0%> (ø)
client/noop_workflow_finder.go 0% <ø> (ø)
client/standalone/discover.go 7% <0%> (ø)
client/standalone/hardware.go 14% <0%> (+<1%) ⬆️
client/tinkerbell/discovery.go 33% <0%> (ø)
cmd/boots/dhcp.go 11% <0%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5faab79...4b4e5de. Read the comment docs.

Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

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

fantastic!. A couple of minor comments and one nit. The nit is that you're mixing 2 different ways to define functions whose arguments are all ignored. Some changes you're doing here are like:

func(_ type1, _ type2, _ type3)

and

func(type1, type2, type3)

I prefer the latter and I think its the most common way. Can you make it so only one way is used please?

@@ -123,14 +123,15 @@ func (f *Finder) HasActiveWorkflow(ctx context.Context, hwID client.HardwareID)

wfContexts := []*workflow.WorkflowContext{}
for _, wf := range stored.Items {
wf := wf
Copy link
Contributor

Choose a reason for hiding this comment

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

this was definitely buggy before

@@ -68,5 +66,5 @@ func TestMain(m *testing.M) {
defer l.Close()
mainlog = l.Package("main")
metrics.Init(l)
os.Exit(m.Run())
os.Exit(m.Run()) //nolint:gocritic // this seems to be the correct pattern
Copy link
Contributor

Choose a reason for hiding this comment

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

yep

dhcp/dhcp.go Outdated Show resolved Hide resolved
@jacobweinstock
Copy link
Member Author

fantastic!. A couple of minor comments and one nit. The nit is that you're mixing 2 different ways to define functions whose arguments are all ignored. Some changes you're doing here are like:

func(_ type1, _ type2, _ type3)

and

func(type1, type2, type3)

I prefer the latter and I think its the most common way. Can you make it so only one way is used please?

yeah, seems reasonable. updated.

@jacobweinstock jacobweinstock requested a review from mmlb July 1, 2022 20:13
@mmlb
Copy link
Contributor

mmlb commented Jul 1, 2022

:( I always forget to check of the "viewed" button while reviewing and then need to go through the whole thing again later ...


import "errors"

var ErrEmptyIpxeConfig = errors.New("ipxe config URL or Script must be defined")
Copy link
Contributor

@mmlb mmlb Jul 1, 2022

Choose a reason for hiding this comment

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

Another nit, one that wasn't caught by gometalinter but is in the spirit of one of its linters: This should be ErrEmptyIPXEConfig since its iPXE because PXE is an acronym like DNS, ID, IP, ... and should be all caps. The i should also be caps because its a new word. It would also match other names in this repo like j.IPXEScriptURL. It'd be nice to get it fixed now.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, that's interesting that the linter didn't catch that. I've updated it regardless.

Copy link
Contributor

Choose a reason for hiding this comment

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

ha!

Copy link
Contributor

Choose a reason for hiding this comment

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

wait what... that was way too fast. I'm pretty sure github sent that to you before I submitted it because it complained about needing a comment for the review as a whole...

This gets the repo to a baseline of linting
based on the .golangci.yml file.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
Copy link
Contributor

@mmlb mmlb left a comment

Choose a reason for hiding this comment

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

just one thing I noticed now

@jacobweinstock jacobweinstock requested a review from mmlb July 1, 2022 20:29
@jacobweinstock jacobweinstock added the ready-to-merge Signal to Mergify to merge the PR. label Jul 1, 2022
@jacobweinstock jacobweinstock removed the request for review from micahhausler July 1, 2022 20:36
@mergify mergify bot merged commit 4a32e2f into tinkerbell:main Jul 1, 2022
@jacobweinstock jacobweinstock deleted the linting branch July 1, 2022 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include error return checking in golangci-lint results
2 participants