r4fterman/pdf.forms

View on GitHub
src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java

Summary

Maintainability
D
1 day
Test Coverage
F
9%

File WidgetSelection.java has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.pdf.forms.widgets.utils;

import static java.util.stream.Collectors.toUnmodifiableSet;

import java.awt.*;
Severity: Minor
Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java - About 5 hrs to fix

    WidgetSelection has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class WidgetSelection {
    
        public static final int BOX_MARGIN = 3;
        private static final int RESIZE_NODE_SIZE = 4;
        private static final int WIDTH = 22;
    Severity: Minor
    Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java - About 2 hrs to fix

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

          public void drawMulitipleSelectionBox(
                  final Graphics2D g2,
                  final Set<IWidget> selectedWidgets,
                  final boolean drawNodes) {
      
      
      Severity: Minor
      Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java - About 1 hr to fix

        Method getResizeType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public int getResizeType(
                    final int mouseX,
                    final int mouseY,
                    final Set<IWidget> selectedWidgets) {
                if (selectionBoxBounds == null || selectedWidgets.isEmpty()) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java - About 1 hr 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 resizeWidgets has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                    final Set<IWidget> selectedWidgets,
                    final IDesigner designerPanel,
                    final int mouseX,
                    final int mouseY,
                    final int resizeType) {
        Severity: Minor
        Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java - About 35 mins to fix

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

              public void resizeWidgets(
                      final Set<IWidget> selectedWidgets,
                      final IDesigner designerPanel,
                      final int mouseX,
                      final int mouseY,
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.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 drawMulitipleSelectionBox has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public void drawMulitipleSelectionBox(
                      final Graphics2D g2,
                      final Set<IWidget> selectedWidgets,
                      final boolean drawNodes) {
          
          
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.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

          This block of commented-out lines of code should be removed.
          Open

                      //            selectedWidget.setX((int) ((widgetLastX + mouseX) / scale));

          Programmers should not comment out code as it bloats programs and reduces readability.

          Unused code should be deleted and can be retrieved from source control history if required.

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

              private void resizeSplitHorizontal(
                      final Set<IWidget> widgets,
                      final IDesigner designerPanel,
                      final int mouseX) {
                  final int x = selectionBoxBounds.x;
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java and 1 other location - About 50 mins to fix
          src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java on lines 345..355

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

          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

              private void resizeSplitVertical(
                      final Set<IWidget> widgets,
                      final IDesigner designerPanel,
                      final int mouseY) {
                  final int y = selectionBoxBounds.y;
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java and 1 other location - About 50 mins to fix
          src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java on lines 357..367

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

          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

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

                  unGroupButton.addActionListener(e -> {
                      final Commands commands = new Commands(
                              designerPanel.getMainFrame(),
                              version,
                              fontHandler,
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java and 1 other location - About 30 mins to fix
          src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java on lines 50..59

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

          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

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

                  groupButton.addActionListener(e -> {
                      final Commands commands = new Commands(
                              designerPanel.getMainFrame(),
                              version,
                              fontHandler,
          Severity: Minor
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java and 1 other location - About 30 mins to fix
          src/main/java/org/pdf/forms/widgets/utils/WidgetSelection.java on lines 66..75

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

          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

          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.

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

                      final int rightPoint = Math.max(widgetBounds.x + widgetBounds.width, rectangle.x + rectangle.width);

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

                      final int bottomPoint = Math.max(widgetBounds.y + widgetBounds.height, rectangle.y + rectangle.height);

          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.

          Wrong lexicographical order for 'java.awt.*' import. Should be before 'java.util.stream.Collectors.toUnmodifiableSet'.
          Open

          import java.awt.*;

          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.

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

                          && mouseX <= getSelectionBoxBounds().width + widgetX + 5 + WidgetSelection.BOX_MARGIN

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

                          && mouseY <= getSelectionBoxBounds().height + widgetY + 5 + WidgetSelection.BOX_MARGIN;

          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 'java.awt.*'
          Open

          import java.awt.*;

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

                          .round(selectionBoxBounds.x + BOX_MARGIN + (selectionBoxBounds.width * resizeFromLeftRatio)));

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

                      logger.warn("{} Manual exit because of impossible situation in {}", resizeType, getClass());

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

               * @param drawNodes if true then nodes will be drawn around the selection box, and this widget will be internally

          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.

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

              public void resizeWidgets(

          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.

          Wrong lexicographical order for 'java.util.HashSet' import. Should be before 'java.util.stream.Collectors.toUnmodifiableSet'.
          Open

          import java.util.HashSet;

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

                          .round(selectionBoxBounds.y + BOX_MARGIN + (selectionBoxBounds.height * resizeFromTopRatio)));

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

                          && mouseX <= getSelectionBoxBounds().width + widgetX + 5 + WidgetSelection.BOX_MARGIN

          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

                  widget.getWidgetModel().getProperties().getCaptionProperties().setDividerLocation(String.valueOf(mouseX - x));

          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

                      rectangle = new Rectangle(leftPoint, topPoint, rightPoint - leftPoint, bottomPoint - topPoint);

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

                  groupButton.setIcon(new ImageIcon(getClass().getResource("/org/pdf/forms/res/Grouped.gif")));

          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.

          Wrong lexicographical order for 'java.util.Set' import. Should be before 'java.util.stream.Collectors.toUnmodifiableSet'.
          Open

          import java.util.Set;

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

                          && mouseY <= getSelectionBoxBounds().height + widgetY + 5 + WidgetSelection.BOX_MARGIN;

          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 'org.pdf.forms.Configuration'
          Open

          import org.pdf.forms.Configuration;

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

                  unGroupButton.setIcon(new ImageIcon(getClass().getResource("/org/pdf/forms/res/Ungrouped.gif")));

          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

                      if (selectedWidgets.size() == 1 && selectedWidgets.iterator().next().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 118).
          Open

                  widget.getWidgetModel().getProperties().getCaptionProperties().setDividerLocation(String.valueOf(mouseY - y));

          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