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

feat: Remove all usage of init() and global command objects #91

Merged
merged 3 commits into from
Nov 7, 2023

Conversation

tarkatronic
Copy link
Contributor

Using init() is generally a bad practice. We don't like side effects. Same thing with global variables. This does away with both! At least as far as the commands themselves are concerned.

This also makes our code ever so slightly more testable. Hopefully.

@tarkatronic tarkatronic requested a review from a team as a code owner November 7, 2023 16:12
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #91 (1861ace) into main (d3223ee) will increase coverage by 0.90%.
The diff coverage is 71.15%.

@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   74.57%   75.48%   +0.90%     
==========================================
  Files          15       15              
  Lines         704      726      +22     
==========================================
+ Hits          525      548      +23     
+ Misses        170      168       -2     
- Partials        9       10       +1     
Flag Coverage Δ
unittests 75.48% <71.15%> (+0.90%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
cmd/scan.go 100.00% <100.00%> (ø)
config/config.go 75.38% <100.00%> (+1.19%) ⬆️
cmd/root.go 53.48% <60.52%> (+23.48%) ⬆️

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!


func TestNewRootCommand(t *testing.T) {
// Mostly just ensure nothing errors out.
c := cmd.NewRootCommand()
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@tarkatronic tarkatronic merged commit 76f1575 into main Nov 7, 2023
29 of 30 checks passed
@tarkatronic tarkatronic deleted the feat/no-init branch November 7, 2023 18:39
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.

2 participants