r4fterman/pdf.forms

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

Summary

Maintainability
D
2 days
Test Coverage
F
0%

File WidgetParser.java has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package org.pdf.forms.widgets.utils;

import java.awt.*;
import java.util.Collections;
import java.util.HashSet;
Severity: Minor
Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 4 hrs to fix

    Method handleBorder has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private void handleBorder(
                final FormObject formObject,
                final IWidget widget) {
            final Map<String, String> border = Optional.ofNullable(formObject.getBorder())
                    .map(map -> (Map<String, String>) map)
    Severity: Minor
    Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 1 hr to fix

      Method addCheckBox has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void addCheckBox(
                  final FormObject formObject,
                  final Page page,
                  final String groupName,
                  final int pageHeight,
      Severity: Minor
      Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 1 hr to fix

        Method addCheckBox has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                    final FormObject formObject,
                    final Page page,
                    final String groupName,
                    final int pageHeight,
                    final int cropHeight,
        Severity: Major
        Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 1 hr to fix

          Method addFormButton has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                      final Page page,
                      final int pageHeight,
                      final int cropHeight,
                      final int cropX,
                      final int cropY,
          Severity: Major
          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 50 mins to fix

            Method getBasicWidget has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                        final FormObject formObject,
                        final int type,
                        final int pageHeight,
                        final int cropHeight,
                        final int cropX,
            Severity: Major
            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 50 mins to fix

              Method parseWidgets has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                          final AcroRenderer currentFormRenderer,
                          final Page page,
                          final int pageHeight,
                          final int cropHeight,
                          final int cropX,
              Severity: Major
              Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 50 mins to fix

                Method addTextField has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                            final int pageHeight,
                            final int cropHeight,
                            final int cropX,
                            final int cropY,
                            final List<IWidget> widgetsOnPage,
                Severity: Minor
                Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 45 mins to fix

                  Method addListBox has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                              final int pageHeight,
                              final int cropHeight,
                              final int cropX,
                              final int cropY,
                              final List<IWidget> widgetsOnPage,
                  Severity: Minor
                  Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 45 mins to fix

                    Method addPushButton has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                                final int pageHeight,
                                final int cropHeight,
                                final int cropX,
                                final int cropY,
                                final List<IWidget> widgetsOnPage,
                    Severity: Minor
                    Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 45 mins to fix

                      Method addChoice has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                                  final int pageHeight,
                                  final int cropHeight,
                                  final int cropX,
                                  final int cropY,
                                  final List<IWidget> widgetsOnPage,
                      Severity: Minor
                      Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 45 mins to fix

                        Method addComboBox has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                    final int pageHeight,
                                    final int cropHeight,
                                    final int cropX,
                                    final int cropY,
                                    final List<IWidget> widgetsOnPage,
                        Severity: Minor
                        Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 45 mins to fix

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

                              private void handleChoiceField(
                                      final FormObject formObject,
                                      final IWidget widget) {
                                  final ObjectProperties objectProperties = widget.getWidgetModel().getProperties().getObject();
                          
                          
                          Severity: Minor
                          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.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 getBounds has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                      final FormObject formObject,
                                      final int pageHeight,
                                      final int cropHeight,
                                      final int cropX,
                                      final int cropY) {
                          Severity: Minor
                          Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java - About 35 mins to fix

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

                                private void handleBorder(
                                        final FormObject formObject,
                                        final IWidget widget) {
                                    final Map<String, String> border = Optional.ofNullable(formObject.getBorder())
                                            .map(map -> (Map<String, String>) map)
                            Severity: Minor
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.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 addCheckBox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private void addCheckBox(
                                        final FormObject formObject,
                                        final Page page,
                                        final String groupName,
                                        final int pageHeight,
                            Severity: Minor
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.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 has 8 parameters, which is greater than 7 authorized.
                            Open

                                private void addCheckBox(

                            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.

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

                                private void addTextField(
                                        final int pageHeight,
                                        final int cropHeight,
                                        final int cropX,
                                        final int cropY,
                            Severity: Major
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java and 1 other location - About 1 hr to fix
                            src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java on lines 180..204

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

                            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 addPushButton(
                                        final int pageHeight,
                                        final int cropHeight,
                                        final int cropX,
                                        final int cropY,
                            Severity: Major
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java and 1 other location - About 1 hr to fix
                            src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java on lines 155..178

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

                            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

                                    for (final IWidget widget: widgets) {
                                        final String widgetName = widget.getWidgetName();
                                        if (name.equals(widgetName) && !widget.equals(widgetToTest)) {
                                            // another widget of this name already exists, and this is the first
                                            // we've heard of it
                            Severity: Minor
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java and 1 other location - About 1 hr to fix
                            src/main/java/org/pdf/forms/gui/VLFrame.java on lines 620..632

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

                            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 addListBox(
                                        final int pageHeight,
                                        final int cropHeight,
                                        final int cropX,
                                        final int cropY,
                            Severity: Minor
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java and 1 other location - About 40 mins to fix
                            src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java on lines 135..153

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

                            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 addComboBox(
                                        final int pageHeight,
                                        final int cropHeight,
                                        final int cropX,
                                        final int cropY,
                            Severity: Minor
                            Found in src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java and 1 other location - About 40 mins to fix
                            src/main/java/org/pdf/forms/widgets/utils/WidgetParser.java on lines 114..133

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

                            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

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

                                    final Optional<BorderProperties> properties = widget.getWidgetModel().getProperties().getBorder();

                            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

                                        borderProperties.getBackgroundFill().setFillColor(String.valueOf(backgroundColor.getRGB()));

                            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.jpedal.objects.acroforms.formData.FormObject'
                            Open

                            import org.jpedal.objects.acroforms.formData.FormObject;

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

                                    final ObjectProperties objectProperties = widget.getWidgetModel().getProperties().getObject();

                            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.

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

                                    final BindingProperties bindingProperties = widget.getWidgetModel().getProperties().getObject().getBinding();

                            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

                                            addFormButton(page, pageHeight, cropHeight, cropX, cropY, widgetsOnPage, formObject);

                            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.

                            There are no issues that match your filters.

                            Category
                            Status