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

TC: Use switch case to simplify flag conversion and avoid multiple if statements #9507

Merged
merged 4 commits into from
Jul 4, 2022

Conversation

TheodosiouTh
Copy link
Contributor

@TheodosiouTh TheodosiouTh commented May 28, 2022

What I did
I used a map to remove multiple if statements from the code and make it easier to add new argument conversions.
Also, I added missing tests for -v and --verbose.

Related issue
There are no related issues.

@TheodosiouTh TheodosiouTh force-pushed the tc/simplify-flag-conversion branch 2 times, most recently from 21f5165 to c56c579 Compare May 28, 2022 08:48
Copy link
Contributor

@debdutdeb debdutdeb left a comment

Choose a reason for hiding this comment

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

Honestly i don't see the need to use a static one-use map for a simple action like this. There is no benefits to this, no performance gain or anything. Would've made some sense in terms of maintainability if there were a lot of such supp args, but for just four, a couple if statements don't hurt, rather I'd say is better. Probably a better option would be using switch instead (even if the list grows to say 100, a switch statement is far better than a clever use of map. simplicity 😉)

@TheodosiouTh
Copy link
Contributor Author

TheodosiouTh commented Jun 30, 2022

@debdutdeb I understand your way of thinking.
I changed the code to use a switch case statement and it looks just as good as the static map.

Thanks for the review. 😃

@TheodosiouTh TheodosiouTh changed the title TC: Use map to simplify flag conversion and avoid multilple if statements TC: Use switch case to simplify flag conversion and avoid multiple if statements Jun 30, 2022
Copy link
Contributor

@debdutdeb debdutdeb left a comment

Choose a reason for hiding this comment

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

looks good to me

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

LGTM

@glours glours merged commit 5a1fea8 into docker:v2 Jul 4, 2022
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.

3 participants