r4fterman/pdf.forms

View on GitHub
src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java

Summary

Maintainability
C
1 day
Test Coverage
F
6%

File CDropTargetListener.java has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.pdf.forms.gui.hierarchy.tree;

import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;

    Method dragOver has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @Override
        public void dragOver(final DropTargetDragEvent event) {
            // This is where the ghost image is drawn.
            // Even if the mouse is not moving, this method is still invoked 10 times per second
            final Point point = event.getLocation();

      Method removeEmptyGroupFromParent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private void removeEmptyGroupFromParent(
                  final Object[] sourceObjectPath,
                  final List<IWidget> sourceWidgetList,
                  final List<IWidget> targetWidgetList) {
              /*
      Severity: Minor
      Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method dragOverPage has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                  final DropTargetDragEvent e,
                  final DefaultMutableTreeNode targetNode,
                  final DefaultMutableTreeNode sourceNode,
                  final List<TreeNode> flattenedTreeItems,
                  final Object targetUserObject) {
      Severity: Minor
      Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 35 mins to fix

        Method getWidgetsList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private List<IWidget> getWidgetsList(
                    final Object[] objectPath,
                    final boolean isTarget) {
                for (int i = objectPath.length - 1; i >= 0; i--) {
                    final Object object = objectPath[i];
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dragOverWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private void dragOverWidget(
                    final DropTargetDragEvent event,
                    final DefaultMutableTreeNode targetNode,
                    final DefaultMutableTreeNode sourceNode,
                    final Object targetUserObject) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dragOver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public void dragOver(final DropTargetDragEvent event) {
                // This is where the ghost image is drawn.
                // Even if the mouse is not moving, this method is still invoked 10 times per second
                final Point point = event.getLocation();
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dropWidget has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private void dropWidget(
                    final DefaultMutableTreeNode sourceNode,
                    final IWidget sourceUserObject,
                    final DefaultMutableTreeNode targetNode,
                    final IWidget targetUserObject) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dropPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private void dropPage(
                    final IMainFrame mainFrame,
                    final DefaultMutableTreeNode sourceNode,
                    final DefaultMutableTreeNode targetNode,
                    final Object targetUserObject) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method dropTransferable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private boolean dropTransferable(
                    final Transferable transferable,
                    final DataFlavor flavor,
                    final DropTargetDropEvent event) {
                try {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method getTargetIndex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private int getTargetIndex(
                    final IWidget targetUserObject,
                    final List<IWidget> sourceWidgetList,
                    final List<IWidget> targetWidgetList,
                    final int sourceIndex) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/gui/hierarchy/tree/CDropTargetListener.java - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    if (radioButtonGroups.isEmpty()) {
                        /*
                         * there are no radio button groups currently on this page, so we need to
                         * create a new on
                         */
        src/main/java/org/pdf/forms/widgets/utils/WidgetFactory.java on lines 118..123

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

        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

        Extra separation in import group before 'org.pdf.forms.document.Page'
        Open

        import org.pdf.forms.document.Page;

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

                // In any case draw (over the ghost image if necessary) a cue line indicating where a drop will occur

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

                final DefaultMutableTreeNode sourceNode = (DefaultMutableTreeNode) cTree.getPathSource().getLastPathComponent();

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

                    final DropTargetDragEvent 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.

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

                final int targetIndex = getTargetIndex(targetUserObject, sourceWidgetList, targetWidgetList, sourceIndex);

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

                final Rectangle raPath = Objects.requireNonNullElse(cTree.getPathBounds(treePath), new Rectangle(0, 0, 0, 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 113).
        Open

                    final DefaultMutableTreeNode sourceNode = (DefaultMutableTreeNode) pathSource.getLastPathComponent();

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

                    // we are dropping it at the document root level which means it is definitely going to be dropped at index 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.

        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.

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

                    final CTree cTree,

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

            private boolean isDropAcceptable(final DropTargetDropEvent 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.

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

            private final CTree cTree;

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

                        final DefaultMutableTreeNode nextItemInList = (DefaultMutableTreeNode) flattenedTreeItems.get(nextIndex);

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

                    final DropTargetDragEvent 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.

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

                    raGhost.setRect(x, y, cTree.getDraggedImage().getWidth(), cTree.getDraggedImage().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.

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

                final boolean rejectDrag = targetIndex == sourceIndex && sourceNode.getParent() == targetNode.getParent();

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

                    final DefaultMutableTreeNode targetNode = (DefaultMutableTreeNode) pathTarget.getLastPathComponent();

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

                            dropWidget(sourceNode, (IWidget) sourceUserObject, targetNode, (IWidget) targetUserObject);

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

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

                    g2.drawImage(cTree.getDraggedImage(), AffineTransform.getTranslateInstance(raGhost.getX(), raGhost.getY()), null);

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

                // we are not trying to drop a widget on a page, so we need to check if it is being dropped in a group

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

                        && (!(targetUserObject instanceof IWidget) || ((IWidget) targetUserObject).getType() != IWidget.GROUP)) {

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

                        final boolean dropOfAPageOverAnotherPage = nextItemInList.getUserObject() instanceof Page;

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

            public void dropActionChanged(final DropTargetDragEvent 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.

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

                        dropRadioButtonOverPage((RadioButtonWidget) sourceUserObject, (Page) source, (Page) target);

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

            private boolean isDragNotAcceptable(final DropTargetDragEvent 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.

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

            private void dragOverWidget(

        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.

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

                        final DefaultMutableTreeNode nextItemInList = (DefaultMutableTreeNode) flattenedTreeItems.get(nextIndex);

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

                final DefaultMutableTreeNode targetNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();

        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.

        There are no issues that match your filters.

        Category
        Status