Developer's Diary
Software development, with Terry Ebdon
13-Mar-2019 Reducing complexity

Trek.isValid() is overly complex

Trek.isValid() is overly complex. It should be simpler and clearer. Note: There is a similar problem in FederationShip.isValid().

JaCoCo shows a complexity of 24. See the JaCoCo report for the current values.

image

Screen shot is from the [JaCoCo detail report.]:

image

I eliminated repeated use of != null by using the ?. operator, and replaced isValid() with valid. This change reduces the complexity from 24 to 5.

image

Reducing JaCoCo impact on build time

To fix issue #23 I added a second build file, coverage.gradle, and removed the JaCoCo plugin from build.gradle. A "normal" build will now run without the JaCoCo overhead.

To generate a coverage report use:

gradlew -b coverage.gradle cleanTest test jacocoTestReport

12-MAR-2019 👈 Top of page 👉 14-MAR-2019

© 2020 Terry Ebdon.

Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.