Skip to content

Conversation

@baywet
Copy link
Member

@baywet baywet commented Feb 12, 2021

  • adds spotbugs base configuration
  • fixes static analysis errors as example

fixes #148

related #149

This one is set to fail the build on infringements as we only have 60+ errors at this time.
It runs a light level of static analysis, (conditions structures, null checks, redundancy, etc...).
I'm providing examples of fixes to the team to get some early feedback.

I think the typo it caught in the defensive condition clearly demonstrates the value. It an honest mistake that's easy to make and easy to miss on pull requests that can have bad consequences and be hard to debug/find.

@baywet baywet added this to the 2.0.0-release milestone Feb 12, 2021
@baywet baywet self-assigned this Feb 12, 2021
*/
@Nullable
public Class<?> getDerivedClass(@Nonnull final JsonObject jsonObject, @Nonnull final Class<?> parentClass) {
public Class<?> getDerivedClass(@Nonnull final JsonObject jsonObject, @Nullable final Class<?> parentClass) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably off-topic but probably also doesn't hurt: if a parameter should be null ever (i.e. marked with Nonnull), then it might be a good practice to check that explicitly in the method (e.g. Objects.requireNonNull())

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, I'm planning to do a bulk pass for that as part of this static analysis effort. We didn't use to have any annotations not long ago...

Copy link
Member Author

Choose a reason for hiding this comment

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

see the latest commits, I added a lot of defensive programming for nonnull annotations. Also corrected a few annotations that should've been Nullable instead

@baywet baywet marked this pull request as ready for review February 15, 2021 19:41
@baywet baywet requested a review from andrueastman February 18, 2021 15:26
@github-actions

This comment has been minimized.

@baywet baywet merged commit 567051e into feature/v2 Feb 18, 2021
@baywet baywet deleted the feature/spotbugs branch February 18, 2021 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants