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 to use getOrDefault method for default values #59" #1815

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Er-Sadiq
Copy link

@Er-Sadiq Er-Sadiq commented Aug 4, 2024

Fix #1814

This pull request refactors the DockerComposeConfiguration constructor to use Java's built-in getOrDefault method available on the Map interface for assigning default values. This change enhances code readability and simplifies the logic for default value assignment.

Changes Made
Replaced the usage of ternary operators with getOrDefault for retrieving configuration values from the config map.
Updated the assignment of basedir, composeFile, and ignoreBuild fields to use getOrDefault.

ignoreBuild = config.containsKey("ignoreBuild") ? Boolean.parseBoolean(config.get("ignoreBuilder")) : false;
basedir = config.getOrDefault("basedir", "src/main/docker");
composeFile = config.getOrDefault("composeFile", "docker-compose.yml");
ignoreBuild = Boolean.parseBoolean(config.getOrDefault("ignoreBuild", "false"));
Copy link
Member

Choose a reason for hiding this comment

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

indentation slightly off here

Copy link
Author

Choose a reason for hiding this comment

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

Okay I'll fix the indentation and push again

@Er-Sadiq
Copy link
Author

Er-Sadiq commented Aug 5, 2024

I am really sorry about the indentation I've made necessary changes and raised another PR kindly let me know if you want any other modifications, Thank you

Copy link

@rohanKanojia
Copy link
Member

@Er-Sadiq : polite ping, are you still working on this?

@Er-Sadiq
Copy link
Author

@rohanKanojia Hi , I've made necessary changes and updated the PR I am not sure went wrong then

@rohanKanojia
Copy link
Member

@Er-Sadiq : my comment still doesn't seem to be addressed #1815 (comment)

I could be wrong here, perhaps you forgot to push changes?

@Er-Sadiq
Copy link
Author

@rohanKanojia no I did push in fact i merged it in the previous pr itself but then some tests are failing for macos i guess

@Er-Sadiq
Copy link
Author

@rohanKanojia kindly let me know how do you want me to fix it as of now

@rohanKanojia
Copy link
Member

rohanKanojia commented Oct 12, 2024

@Er-Sadiq : These failures are not related to your changes. Please take a look at the changes in your branch (I'm only asking to fix the indentation):

https://github.com/Er-Sadiq/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/config/handler/compose/DockerComposeConfiguration.java

@Er-Sadiq
Copy link
Author

@rohanKanojia I am so sorry you were right ,I forgot to update the branch :{ sorry

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.27%. Comparing base (150970d) to head (7d225cf).
Report is 24 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1815      +/-   ##
============================================
+ Coverage     65.87%   66.27%   +0.40%     
- Complexity     2306     2346      +40     
============================================
  Files           172      174       +2     
  Lines         10194    10342     +148     
  Branches       1408     1431      +23     
============================================
+ Hits           6715     6854     +139     
- Misses         2926     2928       +2     
- Partials        553      560       +7     
Files with missing lines Coverage Δ
...ig/handler/compose/DockerComposeConfiguration.java 100.00% <100.00%> (+37.50%) ⬆️

... and 3 files with indirect coverage changes

Copy link

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.

DockerComposeConfiguration : Use Map.getOrDefault instead of conditional statement
2 participants