r4fterman/pdf.forms

View on GitHub
src/main/java/org/pdf/forms/gui/designer/Designer.java

Summary

Maintainability
C
1 day
Test Coverage
F
16%

File Designer.java has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.pdf.forms.gui.designer;

import java.awt.*;
import java.util.Collection;
import java.util.HashSet;
Severity: Minor
Found in src/main/java/org/pdf/forms/gui/designer/Designer.java - About 6 hrs to fix

    Designer has 43 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Designer extends PdfDecoder implements IDesigner {
    
        private final Logger logger = LoggerFactory.getLogger(Designer.class);
    
        private final WidgetSelection widgetSelection;
    Severity: Minor
    Found in src/main/java/org/pdf/forms/gui/designer/Designer.java - About 5 hrs to fix

      Constructor has 9 parameters, which is greater than 7 authorized.
      Open

          public Designer(

      A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

      Noncompliant Code Example

      With a maximum number of 4 parameters:

      public void doSomething(int param1, int param2, int param3, String param4, long param5) {
      ...
      }
      

      Compliant Solution

      public void doSomething(int param1, int param2, int param3, String param4) {
      ...
      }
      

      Exceptions

      Methods annotated with :

      • Spring's @RequestMapping (and related shortcut annotations, like @GetRequest)
      • JAX-RS API annotations (like @javax.ws.rs.GET)
      • Bean constructor injection with @org.springframework.beans.factory.annotation.Autowired
      • CDI constructor injection with @javax.inject.Inject
      • @com.fasterxml.jackson.annotation.JsonCreator

      may have a lot of parameters, encapsulation being possible. Such methods are therefore ignored.

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

                  final String pdfFile) throws Exception {

      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

      Using the '.*' form of import should be avoided - java.awt.*.
      Open

      import java.awt.*;

      Checks that there are no import statements that use the * notation.

      Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Extra separation in import group before 'javax.swing.*'
      Open

      import javax.swing.*;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 106).
      Open

              g2.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dashPattern, 0));

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 109).
      Open

                  final Rectangle r = new Rectangle(inset, inset, currentPage.getWidth(), currentPage.getHeight());

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Using the '.*' form of import should be avoided - javax.swing.*.
      Open

      import javax.swing.*;

      Checks that there are no import statements that use the * notation.

      Rationale: Importing all classes from a package or staticmembers from a class leads to tight coupling between packagesor classes and might lead to problems when a new version of alibrary introduces name clashes.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Parameter name 'y' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
      Open

                  final int y) {

      Checks that method parameter names conform to a specified pattern.By using accessModifiers property it is possibleto specify different formats for methods at different visibility levels.

      To validate catch parameters please useCatchParameterName.

      To validate lambda parameters please useLambdaParameterName.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 110).
      Open

                          final boolean drawNodes = selectedWidgets.size() == 1 && selectedWidgets.contains(widget);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Parameter name 'x' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
      Open

                  final int x,

      Checks that method parameter names conform to a specified pattern.By using accessModifiers property it is possibleto specify different formats for methods at different visibility levels.

      To validate catch parameters please useCatchParameterName.

      To validate lambda parameters please useLambdaParameterName.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Parameter name 'g' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
      Open

          public void paintComponent(final Graphics g) {

      Checks that method parameter names conform to a specified pattern.By using accessModifiers property it is possibleto specify different formats for methods at different visibility levels.

      To validate catch parameters please useCatchParameterName.

      To validate lambda parameters please useLambdaParameterName.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      All overloaded methods should be placed next to each other. Placing non-overloaded methods in between overloaded methods with the same type is a violation. Previous overloaded method located at line '378'.
      Open

          private boolean removeWidget(

      Checks that overloaded methods are grouped together. Overloaded methods have the samename but different signatures where the signature can differ by the number of inputparameters or type of input parameters or both.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Extra separation in import group before 'org.jpedal.PdfDecoder'
      Open

      import org.jpedal.PdfDecoder;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      There are no issues that match your filters.

      Category
      Status