Skip to content

Conversation

@timyates
Copy link
Contributor

@timyates timyates commented Jun 13, 2024

Best reviewed commit by commit as I've tried to be strong and just fix one thing per commit...

Apologies for when I may have strayed 😢

This clears up a coupld of hundred Sonar errors and warnings


  1. JUnit5 class and method visibility

    In JUnit 5 it is recommendend to have package-private classes and methods for tests, Sonar flags this as an issue

  2. Logger should be a private static field

    Sonar flags this as a naming vilation (as it's all in caps), I think it just needed to be private final static

  3. Replace Collectors.toList() as appropriate

    Instead of stream.collect(Collectors.toList()), it is (since Java 16) recommended to use stream.toList().
    Care must be taken though, as the returned list is then unmodifiable (which is different to the old Collectors version)

  4. assertEquals argument order

    AssertEquals in tests expects the first argument to be the expected value.
    Having it the wrong way round causes the output to be wrong, and can cause delays in debugging issues.

  5. accidental self assignement

    In 1 constructor, we were just setting the id to itself (as it wasn't passed as an argument)
    In the second (due to capitalization) we weren't using the passed value for Id.
    This wasn't an issue however as I don't believe the constructor is used 🤔

  6. CSS: deg instead of eg

    Sonar caught a typo

  7. CSS: duplicated padding member

    I don't believe the spec says what to do when it's declared twice (hence the warning in Sonar).
    I kept the second-most padding (which I believe is what most browsers do)

  8. CSS: invalid box-size parameter

    I believe this should be box-sizing and I've update it as such

  9. Remove unrequired Mockito eq() usage

    This is not required and makes the tests harder to read

  10. Remove parentheses round single lambda parameters

@timyates timyates added chore build Things related to building the software labels Jun 13, 2024
@timyates timyates requested review from mkimberlin and vhscom June 13, 2024 15:19
@timyates timyates self-assigned this Jun 13, 2024
timyates and others added 3 commits June 14, 2024 11:31
Mockito provides argument matchers for flexibly stubbing or verifying method calls.

`Mockito.verify()`, `Mockito.when()`, `Stubber.when()` and `BDDMockito.given()` each have overloads with and without argument matchers.

However, the default matching behavior (i.e. without argument matchers) uses `equals()`.
If only the matcher `org.mockito.ArgumentMatchers.eq()` is used, the call is equivalent to the call without matchers, i.e. the `eq()` is not necessary and can be omitted.
The resulting code is shorter and easier to read.
These aren't required, and add visual noise
@timyates timyates force-pushed the bugfix-sonar-issues branch from 9cbc060 to 3ef25cb Compare June 14, 2024 11:26
Copy link
Contributor

@vhscom vhscom left a comment

Choose a reason for hiding this comment

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

Nice clean-up. Re: CSS cascading order, the spec says:

Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.

@timyates timyates merged commit 486a89a into develop Jun 18, 2024
@timyates timyates deleted the bugfix-sonar-issues branch June 18, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Things related to building the software chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants