tomokinakamaru/silverchain

View on GitHub
src/test/java/diagram/Tests.java

Summary

Maintainability
D
1 day
Test Coverage

File Tests.java has 285 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package diagram;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.ByteArrayInputStream;
Severity: Minor
Found in src/test/java/diagram/Tests.java - About 2 hrs to fix

    Method test12 has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Test
      void test12() {
        test("Foo<T;S> { Qux bar(T t) baz(S s)*; }")
            .name("Foo")
            .typeParameterCount(2)
    Severity: Minor
    Found in src/test/java/diagram/Tests.java - About 1 hr to fix

      Method test11 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        @Test
        void test11() {
          test("Foo<T;S> { Qux<T,S> bar(T t) baz(S s); }")
              .name("Foo")
              .typeParameterCount(2)
      Severity: Minor
      Found in src/test/java/diagram/Tests.java - About 1 hr to fix

        Define and throw a dedicated exception instead of using a generic one.
        Open

              throw new RuntimeException(e);
        Severity: Major
        Found in src/test/java/diagram/Tests.java by sonar-java

        Using such generic exceptions as Error, RuntimeException, Throwable, and Exception prevents calling methods from handling true, system-generated exceptions differently than application-generated errors.

        Noncompliant Code Example

        public void foo(String bar) throws Throwable {  // Noncompliant
          throw new RuntimeException("My Message");     // Noncompliant
        }
        

        Compliant Solution

        public void foo(String bar) {
          throw new MyOwnRuntimeException("My Message");
        }
        

        Exceptions

        Generic exceptions in the signatures of overriding methods are ignored, because overriding method has to follow signature of the throw declaration in the superclass. The issue will be raised on superclass declaration of the method (or won't be raised at all if superclass is not part of the analysis).

        @Override
        public void myMethod() throws Exception {...}
        

        Generic exceptions are also ignored in the signatures of methods that make calls to methods that throw generic exceptions.

        public void myOtherMethod throws Exception {
          doTheThing();  // this method throws Exception
        }
        

        See

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          @Test
          void test4() {
            test("Foo { Baz bar(Bar bar) baz(Baz baz)*; }")
                .name("Foo")
                .typeParameterCount(0)
        Severity: Major
        Found in src/test/java/diagram/Tests.java and 2 other locations - About 1 hr to fix
        src/test/java/diagram/Tests.java on lines 144..164
        src/test/java/diagram/Tests.java on lines 185..205

        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 117.

        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 3 locations. Consider refactoring.
        Open

          @Test
          void test10() {
            test("Foo { Qux bar(Bar bar); Qux baz(Baz baz); }")
                .name("Foo")
                .typeParameterCount(0)
        Severity: Major
        Found in src/test/java/diagram/Tests.java and 2 other locations - About 1 hr to fix
        src/test/java/diagram/Tests.java on lines 68..88
        src/test/java/diagram/Tests.java on lines 144..164

        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 117.

        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 3 locations. Consider refactoring.
        Open

          @Test
          void test8() {
            test("Foo { Qux bar(Bar bar) | baz(Baz baz); }")
                .name("Foo")
                .typeParameterCount(0)
        Severity: Major
        Found in src/test/java/diagram/Tests.java and 2 other locations - About 1 hr to fix
        src/test/java/diagram/Tests.java on lines 68..88
        src/test/java/diagram/Tests.java on lines 185..205

        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 117.

        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.
        Open

            test("Foo { void bar(Bar bar); }")
                .name("Foo")
                .typeParameterCount(0)
                .stateCount(2)
                .end(1)
        Severity: Minor
        Found in src/test/java/diagram/Tests.java and 1 other location - About 45 mins to fix
        src/test/java/diagram/Tests.java on lines 92..102

        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 56.

        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.
        Open

            test("Foo { Baz bar(Bar bar) baz(Baz baz)+; }")
                .name("Foo")
                .typeParameterCount(0)
                .stateCount(3)
                .end(2)
        Severity: Minor
        Found in src/test/java/diagram/Tests.java and 1 other location - About 45 mins to fix
        src/test/java/diagram/Tests.java on lines 33..43

        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 56.

        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.
        Open

            test("Foo { Baz bar(Bar bar) baz(Baz baz)?; }")
                .name("Foo")
                .typeParameterCount(0)
                .stateCount(3)
                .end(1, 2)
        Severity: Minor
        Found in src/test/java/diagram/Tests.java and 1 other location - About 30 mins to fix
        src/test/java/diagram/Tests.java on lines 168..175

        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 40.

        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.
        Open

            test("Foo { Baz foo(); Bar foo(); }")
                .name("Foo")
                .typeParameterCount(0)
                .stateCount(2)
                .stateTypeParameterCount(0, 0)
        Severity: Minor
        Found in src/test/java/diagram/Tests.java and 1 other location - About 30 mins to fix
        src/test/java/diagram/Tests.java on lines 120..127

        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 40.

        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