-
Notifications
You must be signed in to change notification settings - Fork 6
Bugfix sonar next round #2538
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
Bugfix sonar next round #2538
Conversation
You get more safety as a missing value will cause the build to fail
- We don't need to test for null - extract validation of skills and members into separate methods - switch conditionals to check the positive not negative (ie: if(a)else instead of if(!a)else)
- extract out a method to build the final map - use computeIfAbsent instead of complex if with lists and stuff
| if (frequency == FrequencyType.DAILY) { | ||
| beginningDate = dateToStudy.minusDays(1); | ||
| } else if (frequency == FrequencyType.WEEKLY) { | ||
| beginningDate = dateToStudy.minusMonths(1); | ||
| } else { | ||
| beginningDate = dateToStudy.minusMonths(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WEEKLY is dateToStudy.minusMonths(1)
But so is the default (MONTHLY)... is this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, not going to lie...I don't think this bit of logic is right. I think some wires got crossed on this bit of fuctionality. I need to go back and find the original task and create some bug fix stories. Luckily this bit doesn't have a UI yet.
Few more sonar fixes here, again one by one for ease of reviewing:
!collection.isEmpty()instead ofcollection.size() > 0as it expresses intent betterWhere there's a fixed number of possible outcomes, it's recommended to use switch expressions as any un-tested branches when a new value is added will throw a compilation error
!Boolean.TRUE.equals(v)Sometimes methods can end up too busy and become hard to follow in your head. Method extraction can help simplify these.
anyMatchon stream instead offilter.findFirst.isPresent