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(main): simplify defaultAction #896

Merged
merged 5 commits into from
Mar 23, 2023

Conversation

Chirab
Copy link
Contributor

@Chirab Chirab commented Feb 22, 2023

  • Add a changelog entry in the section "To Be Released" of CHANGELOG.md

Should we add an entry even if it small refacto ?

The purpose of this PR is only to refacto the DefaultAction function with less lines.
Btw why should this function return an error, as i don't see any a scenario where Action of cli.Command returns an error for help command.

In the futur, shouldn’t we change the signature of type ActionFunc func(*Context) error in Command struct since every function just exit and none of them returns an error.

Copy link
Member

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution

Btw why should this function return an error, as i don't see any a scenario where Action of cli.Command returns an error for help command.

app.Action has the type cli.ActionFunc which is func(*Context) error.

scalingo/main.go Outdated Show resolved Hide resolved
scalingo/main.go Outdated
break
}
}
if len(os.Args)-2 > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I find this condition more readable the following way. Moreover, I think a comment should be added to explain the reason of both these if instructions.

Suggested change
if len(os.Args)-2 > 0 {
if len(os.Args) > 2 {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reviewing my pull request. I received your request to add a code comment, but I'm not entirely sure what to write.

I know how important it is to have clear and concise code comments. I was wondering if you have any specific suggestions on what kind of information I should include in the comment.

Thank you for your help, and I look forward to hearing back from you soon.

scalingo/main.go Outdated Show resolved Hide resolved
@EtienneM EtienneM self-requested a review March 20, 2023 07:54
@EtienneM EtienneM changed the title fix: refacto cli main DefaultAction function refactor(main): simplify defaultAction Mar 23, 2023
Copy link
Member

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

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

I was wondering if you have any specific suggestions on what kind of information I should include in the comment.

After reading your PR again, I actually think that the code is readable "as is" and do not require an extra comment. Sorry for my previous review and thanks again for your contribution! 👏

@EtienneM EtienneM force-pushed the fix/refacto-default-action branch 2 times, most recently from d7c0871 to a5ac4f4 Compare March 23, 2023 08:42
@EtienneM
Copy link
Member

Cannot execute CodeShip due to external contribution. Manually executed both tests and linters:

 emichon@biniou  ~/Documents/Scalingo/golang/src/github.com/Scalingo/cli   fix/refacto-default-action  sc-golangci-lint --new-from-rev=$(git ls-remote origin master | cut -f1)
 emichon@biniou  ~/Documents/Scalingo/golang/src/github.com/Scalingo/cli   fix/refacto-default-action  grc go test -race -p=1 -count=1 ./...
?       github.com/Scalingo/cli/addon_providers [no test files]
?       github.com/Scalingo/cli/addons  [no test files]
?       github.com/Scalingo/cli/alerts  [no test files]
ok      github.com/Scalingo/cli/apps    0.021s
?       github.com/Scalingo/cli/apps/run        [no test files]
?       github.com/Scalingo/cli/autoscalers     [no test files]
ok      github.com/Scalingo/cli/cmd     0.042s
?       github.com/Scalingo/cli/cmd/autocomplete        [no test files]
?       github.com/Scalingo/cli/collaborators   [no test files]
ok      github.com/Scalingo/cli/config  0.022s
?       github.com/Scalingo/cli/config/auth     [no test files]
?       github.com/Scalingo/cli/crontasks       [no test files]
ok      github.com/Scalingo/cli/crypto/sshkeys  0.041s
?       github.com/Scalingo/cli/db      [no test files]
?       github.com/Scalingo/cli/deployments     [no test files]
ok      github.com/Scalingo/cli/detect  0.032s
?       github.com/Scalingo/cli/dists   [no test files]
?       github.com/Scalingo/cli/domains [no test files]
ok      github.com/Scalingo/cli/env     0.021s
?       github.com/Scalingo/cli/events  [no test files]
?       github.com/Scalingo/cli/git     [no test files]
?       github.com/Scalingo/cli/httpclient      [no test files]
?       github.com/Scalingo/cli/integrationlink [no test files]
?       github.com/Scalingo/cli/io      [no test files]
?       github.com/Scalingo/cli/keys    [no test files]
?       github.com/Scalingo/cli/logdrains       [no test files]
?       github.com/Scalingo/cli/logs    [no test files]
?       github.com/Scalingo/cli/net/ssh [no test files]
?       github.com/Scalingo/cli/notification_platforms  [no test files]
?       github.com/Scalingo/cli/notifiers       [no test files]
?       github.com/Scalingo/cli/region_migrations       [no test files]
?       github.com/Scalingo/cli/regions [no test files]
?       github.com/Scalingo/cli/review_apps     [no test files]
?       github.com/Scalingo/cli/scalingo        [no test files]
?       github.com/Scalingo/cli/scmintegrations [no test files]
?       github.com/Scalingo/cli/services/github [no test files]
?       github.com/Scalingo/cli/session [no test files]
?       github.com/Scalingo/cli/signals [no test files]
?       github.com/Scalingo/cli/stacks  [no test files]
?       github.com/Scalingo/cli/term    [no test files]
?       github.com/Scalingo/cli/update  [no test files]
?       github.com/Scalingo/cli/user    [no test files]
?       github.com/Scalingo/cli/utils   [no test files]

@EtienneM EtienneM merged commit 4742cdf into Scalingo:master Mar 23, 2023
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