tomokinakamaru/silverchain

View on GitHub
src/main/java/silverchain/generator/Generator.java

Summary

Maintainability
D
1 day
Test Coverage
A
100%

Generator has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

public final class Generator {

  private final Diagrams diagrams;

  private final Javadocs javadocs;
Severity: Major
Found in src/main/java/silverchain/generator/Generator.java - About 7 hrs to fix

    File Generator.java has 352 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package silverchain.generator;
    
    import static java.lang.String.join;
    import static java.util.Collections.emptyList;
    import static java.util.stream.Collectors.joining;
    Severity: Minor
    Found in src/main/java/silverchain/generator/Generator.java - About 4 hrs to fix

      Method generateState has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private void generateState(State state) {
          beginFile(getFilePath(getStateQualifiedName(state)));
          writePackageDeclaration(getStatePackageName(state));
      
          // Class declaration
      Severity: Minor
      Found in src/main/java/silverchain/generator/Generator.java - About 1 hr to fix

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

          private void generateIAction(Diagram diagram) {
            beginFile(getFilePath(getIActionQualifiedName(diagram)));
            writePackageDeclaration(getIActionPackageName(diagram));
        
            // Interface declaration
        Severity: Minor
        Found in src/main/java/silverchain/generator/Generator.java - About 1 hr to fix

          Remove this unused method parameter "state".
          Open

            private String getIStateModifier(State state) {

          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
          • in overridable methods (non-final, or not member of a final class, non-static, non-private), if the parameter is documented with a proper javadoc.
          @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");
          }
          
          /**
           * @param s This string may be use for further computation in overriding classes
           */
          protected void foobar(int a, String s) { // no issue, method is overridable and unused parameter has proper javadoc
            compute(a);
          }
          

          See

          • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed

          There are no issues that match your filters.

          Category
          Status