Futsch1/medTimer

View on GitHub
app/src/main/java/com/futsch1/medtimer/GenerateTestData.java

Summary

Maintainability
A
1 hr
Test Coverage

Method generateTestMedicine has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void generateTestMedicine() {
        TestMedicine[] testMedicines = new TestMedicine[]{
                new TestMedicine("Omega 3 (EPA/DHA 500mg)", null, 1, new TestReminder[]{
                        new TestReminder("1", 9 * 60, 1, 0, ""),
                        new TestReminder("1", 18 * 60, 2, 2, "after meals")
Severity: Minor
Found in app/src/main/java/com/futsch1/medtimer/GenerateTestData.java - About 1 hr to fix

    Method TestReminder has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Wontfix

        private record TestReminder(String amount, int time, int consecutiveDays,
                                    int pauseDays,
                                    String instructions) {
    Severity: Minor
    Found in app/src/main/java/com/futsch1/medtimer/GenerateTestData.java - About 35 mins to fix

      Remove this unused method parameter "amount".
      Invalid

          private record TestReminder(String amount, int time, int consecutiveDays,

      Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.

      Noncompliant Code Example

      void doSomething(int a, int b) {     // "b" is unused
        compute(a);
      }
      

      Compliant Solution

      void doSomething(int a) {
        compute(a);
      }
      

      Exceptions

      The rule will not raise issues for unused parameters:

      • that are annotated with @javax.enterprise.event.Observes
      • in overrides and implementation methods
      • in interface default methods
      • in non-private methods that only throw or that have empty bodies
      • in annotated methods, unless the annotation is @SuppressWarning("unchecked") or @SuppressWarning("rawtypes"), in which case the annotation will be ignored
      @Override
      void doSomething(int a, int b) {     // no issue reported on b
        compute(a);
      }
      
      public void foo(String s) {
        // designed to be extended but noop in standard case
      }
      
      protected void bar(String s) {
        //open-closed principle
      }
      
      public void qix(String s) {
        throw new UnsupportedOperationException("This method should be implemented in subclasses");
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Similar blocks of code found in 2 locations. Consider refactoring.
      Wontfix

                      new TestMedicine("Omega 3 (EPA/DHA 500mg)", null, 1, new TestReminder[]{
                              new TestReminder("1", 9 * 60, 1, 0, ""),
                              new TestReminder("1", 18 * 60, 2, 2, "after meals")
                      }),
      Severity: Minor
      Found in app/src/main/java/com/futsch1/medtimer/GenerateTestData.java and 1 other location - About 35 mins to fix
      app/src/main/java/com/futsch1/medtimer/GenerateTestData.java on lines 27..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Wontfix

                      new TestMedicine("Selen (200 µg)", null, 0, new TestReminder[]{
                              new TestReminder("2", 9 * 60, 1, 0, ""),
                              new TestReminder("1", 22 * 60, 1, 1, "")
                      })
      Severity: Minor
      Found in app/src/main/java/com/futsch1/medtimer/GenerateTestData.java and 1 other location - About 35 mins to fix
      app/src/main/java/com/futsch1/medtimer/GenerateTestData.java on lines 17..20

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 46.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status