Skip to content

Conversation

@timyates
Copy link
Contributor

@timyates timyates commented Jul 5, 2024

Few more sonar fixes here, again one by one for ease of reviewing:

  1. Mergeable "if" statements should be combined
  2. Use !collection.isEmpty() instead of collection.size() > 0 as it expresses intent better
  3. Use new switch expressions instead of if statements for enum/sealed class comparison
    Where 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
  4. Instead of checking a Boolean class is null or false, just use !Boolean.TRUE.equals(v)
  5. Reduce cognitive load on two methods; report and getPotentiallyQualifyingMembers
    Sometimes methods can end up too busy and become hard to follow in your head. Method extraction can help simplify these.
  6. Use anyMatch on stream instead of filter.findFirst.isPresent

timyates added 8 commits July 5, 2024 15:25
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
@timyates timyates added the server label Jul 5, 2024
@timyates timyates requested a review from mkimberlin July 5, 2024 15:18
@timyates timyates self-assigned this Jul 5, 2024
Comment on lines -166 to -171
if (frequency == FrequencyType.DAILY) {
beginningDate = dateToStudy.minusDays(1);
} else if (frequency == FrequencyType.WEEKLY) {
beginningDate = dateToStudy.minusMonths(1);
} else {
beginningDate = dateToStudy.minusMonths(1);
Copy link
Contributor Author

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?

Copy link
Member

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.

@mkimberlin mkimberlin merged commit eb29edd into develop Jul 30, 2024
@mkimberlin mkimberlin deleted the bugfix-sonar-next-round branch July 30, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants