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: consistent import order #1077

Merged
merged 12 commits into from
Apr 11, 2024
Merged

refactor: consistent import order #1077

merged 12 commits into from
Apr 11, 2024

Conversation

wass3r
Copy link
Collaborator

@wass3r wass3r commented Mar 6, 2024

just testing the waters to see what folks think. maybe i'm not the only one bothered by import order being all over the place? i used gci via gci write --custom-order -s standard -s default -s blank -s dot -s alias -s "prefix(github.com/go-vela)" . gci write --custom-order -s standard -s default -s blank -s dot -s "prefix(github.com/go-vela)" . (UPDATED - see comments) to format all of these. it's a little opinionated. was mostly going for std lib, third party, and our own imports last. we can add this to golangci as a check, but i didn't do it here (yet) to get feedback first.

if we like it, we can apply to all repos.

@wass3r wass3r requested a review from a team as a code owner March 6, 2024 05:39
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.47%. Comparing base (1324474) to head (4822b9c).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1077   +/-   ##
=======================================
  Coverage   64.47%   64.47%           
=======================================
  Files         370      370           
  Lines       11790    11790           
=======================================
  Hits         7602     7602           
  Misses       3671     3671           
  Partials      517      517           
Files Coverage Δ
api/build/approve.go 0.00% <ø> (ø)
api/build/auto_cancel.go 20.95% <ø> (ø)
api/build/cancel.go 0.00% <ø> (ø)
api/build/clean.go 0.00% <ø> (ø)
api/build/compile_publish.go 0.00% <ø> (ø)
api/build/create.go 0.00% <ø> (ø)
api/build/delete.go 0.00% <ø> (ø)
api/build/enqueue.go 0.00% <ø> (ø)
api/build/executable.go 0.00% <ø> (ø)
api/build/get.go 0.00% <ø> (ø)
... and 105 more

... and 89 files with indirect coverage changes

@wass3r wass3r changed the title enhance: consistent import order refactor: consistent import order Mar 6, 2024
@plyr4
Copy link
Contributor

plyr4 commented Mar 6, 2024

I like it

@wass3rw3rk
Copy link
Member

@plyr4 do you like it enough for it to be a linter rule that will gently remind folks that their import order might be ... out of order? golangci-lint does support gci.

@plyr4
Copy link
Contributor

plyr4 commented Mar 6, 2024

@wass3rw3rk yeah it feels like a reasonable linter rule, especially if we can add it to our golangci-lint action

@plyr4
Copy link
Contributor

plyr4 commented Mar 6, 2024

can we supply the configurations you used in

gci write --custom-order -s standard -s default -s blank -s dot -s alias -s "prefix(github.com/go-vela)"

as a file so we can commit the parameters to source?

im not seeing anything in their docs, so maybe its enough to just put the command in our dev docs?

@wass3r
Copy link
Collaborator Author

wass3r commented Mar 6, 2024

@plyr4 see 83d4207

with this in place you could run golangci-lint run --fix and it will fix any violation if the linter supports it. that is the case for gci. we can also add it in CONTRIBUTING.md, if that's what you were thinking?

@plyr4
Copy link
Contributor

plyr4 commented Mar 6, 2024

@wass3rw3rk oh yeah exactly! i was thinking of it from "run gci with config" and not "run golangci-lint with gci config". that is great

ecrupper
ecrupper previously approved these changes Mar 6, 2024
Copy link
Contributor

@ecrupper ecrupper left a comment

Choose a reason for hiding this comment

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

Very cool. I am pro linter rule too

@wass3r wass3r requested review from ecrupper and cognifloyd March 9, 2024 19:26
cognifloyd
cognifloyd previously approved these changes Mar 9, 2024
@wass3rw3rk wass3rw3rk merged commit a0e290b into main Apr 11, 2024
12 of 15 checks passed
@wass3rw3rk wass3rw3rk deleted the enhance/import-order branch April 11, 2024 18:39
wass3rw3rk added a commit to go-vela/types that referenced this pull request Apr 11, 2024
wass3rw3rk added a commit to go-vela/sdk-go that referenced this pull request Apr 11, 2024
wass3rw3rk added a commit to go-vela/types that referenced this pull request Apr 11, 2024
wass3rw3rk added a commit to go-vela/cli that referenced this pull request Apr 11, 2024
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.

6 participants