r4fterman/pdf.forms

View on GitHub
src/main/java/org/pdf/forms/gui/properties/customcomponents/tridstatecheckbox/TriStateCheckBox.java

Summary

Maintainability
A
2 hrs
Test Coverage
F
47%

TriStateDecorator has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    private final class TriStateDecorator implements ButtonModel {
        private final ButtonModel other;

        private TriStateDecorator(final ButtonModel other) {
            this.other = other;

    Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation.
    Open

        public void addMouseListener(final MouseListener l) {

    There are several reasons for a method not to have a method body:

    • It is an unintentional omission, and should be fixed to prevent an unexpected behavior in production.
    • It is not yet, or never will be, supported. In this case an UnsupportedOperationException should be thrown.
    • The method is an intentionally-blank override. In this case a nested comment should explain the reason for the blank override.

    Noncompliant Code Example

    public void doSomething() {
    }
    
    public void doSomethingElse() {
    }
    

    Compliant Solution

    @Override
    public void doSomething() {
      // Do nothing because of X and Y.
    }
    
    @Override
    public void doSomethingElse() {
      throw new UnsupportedOperationException();
    }
    

    Exceptions

    Default (no-argument) constructors are ignored when there are other constructors in the class, as are empty methods in abstract classes.

    public abstract class Animal {
      void speak() {  // default implementation ignored
      }
    }
    

    Make this method "synchronized" to match the parent class implementation.
    Open

        public void addMouseListener(final MouseListener l) {

    When @Overrides of synchronized methods are not themselves synchronized, the result can be improper synchronization as callers rely on the thread-safety promised by the parent class.

    Noncompliant Code Example

    public class Parent {
    
      synchronized void foo() {
        //...
      }
    }
    
    public class Child extends Parent {
    
     @Override
      public void foo () {  // Noncompliant
        // ...
        super.foo();
      }
    }
    

    Compliant Solution

    public class Parent {
    
      synchronized void foo() {
        //...
      }
    }
    
    public class Child extends Parent {
    
      @Override
      synchronized void foo () {
        // ...
        super.foo();
      }
    }
    

    See

    • CERT, TSM00-J - Do not override thread-safe methods with methods that are not thread-safe

    Make "decorator" transient or serializable.
    Open

        private final TriStateDecorator decorator;

    Fields in a Serializable class must themselves be either Serializable or transient even if the class is never explicitly serialized or deserialized. For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In general a Serializable class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.

    This rule raises an issue on non-Serializable fields, and on collection fields when they are not private (because they could be assigned non-Serializable values externally), and when they are assigned non-Serializable types within the class.

    Noncompliant Code Example

    public class Address {
      //...
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;  // Noncompliant; Address isn't serializable
    }
    

    Compliant Solution

    public class Address implements Serializable {
      private static final long serialVersionUID = 2405172041950251807L;
    }
    
    public class Person implements Serializable {
      private static final long serialVersionUID = 1905122041950251207L;
    
      private String name;
      private Address address;
    }
    

    Exceptions

    The alternative to making all members serializable or transient is to implement special methods which take on the responsibility of properly serializing and de-serializing the object. This rule ignores classes which implement the following methods:

     private void writeObject(java.io.ObjectOutputStream out)
         throws IOException
     private void readObject(java.io.ObjectInputStream in)
         throws IOException, ClassNotFoundException;
    

    See

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

                public void mousePressed(final MouseEvent e) {

    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.

    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.

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

        public void addMouseListener(final MouseListener l) {

    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.

    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 'e' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'.
    Open

                public void actionPerformed(final ActionEvent e) {

    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.

    First sentence of Javadoc is missing an ending period.
    Open

        /**

    Checks thatJavadoc summary sentence does not contain phrases that are not recommended to use.Summaries that contain only the {@inheritDoc} tag are skipped. Check alsoviolate Javadoc that does not contain first sentence.

    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