-
Notifications
You must be signed in to change notification settings - Fork 6
Some sonar cleanup (picking the most prevalent or highest priority) #2502
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
Conversation
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
9cbc060 to
3ef25cb
Compare
vhscom
left a comment
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.
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.
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
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
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 staticReplace
Collectors.toList()as appropriateInstead of
stream.collect(Collectors.toList()), it is (since Java 16) recommended to usestream.toList().Care must be taken though, as the returned list is then unmodifiable (which is different to the old
Collectorsversion)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.
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 🤔
CSS:
deginstead ofegSonar caught a typo
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)
CSS: invalid
box-sizeparameterI believe this should be
box-sizingand I've update it as suchRemove unrequired Mockito
eq()usageThis is not required and makes the tests harder to read
Remove parentheses round single lambda parameters