prowide/prowide-core

View on GitHub
src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java

Summary

Maintainability
F
1 wk
Test Coverage

File SwiftTagListBlock.java has 1065 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright 2006-2023 Prowide
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Major
Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 2 days to fix

    SwiftTagListBlock has 113 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class SwiftTagListBlock extends SwiftBlock implements Serializable, Iterable<Tag> {
        /**
         * <em>Immutable</em>empty instance of this class.
         */
        public static final SwiftTagListBlock EMPTY_LIST = emptyList();
    Severity: Major
    Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 2 days to fix

      Method getSubBlocksDelimitedWithOptionalTail has a Cognitive Complexity of 39 (exceeds 8 allowed). Consider refactoring.
      Open

          public List<SwiftTagListBlock> getSubBlocksDelimitedWithOptionalTail(
                  final String[] start, final String[] end, final String[] tail) {
              if (tags != null && !tags.isEmpty()) {
                  final List<SwiftTagListBlock> result = new ArrayList<>();
                  int offset = 0;
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 5 hrs 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 getSubBlockDelimitedWithOptionalTail has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
      Open

          public SwiftTagListBlock getSubBlockDelimitedWithOptionalTail(
                  final String[] start, final String[] end, final String[] tail) {
              if (tags != null && !tags.isEmpty()) {
                  final int s = indexOfAnyFirst(start);
                  final int e = indexOfAnyFirstAfterIndex(s + 1, end);
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 3 hrs 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 _searchSubBlockByCriteria has a Cognitive Complexity of 25 (exceeds 8 allowed). Consider refactoring.
      Open

          private SwiftTagListBlock _searchSubBlockByCriteria(
                  final Tag tag,
                  final boolean includeDelimiterInResult,
                  SearchSelection searchSelection,
                  SearchBoundary searchBoundary) {
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 3 hrs 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 filterByName has a Cognitive Complexity of 23 (exceeds 8 allowed). Consider refactoring.
      Open

          public SwiftTagListBlock filterByName(final boolean include, final String... names) {
              final SwiftTagListBlock result = new SwiftTagListBlock();
              if (names.length == 0) {
                  if (include) {
                      // do nothing, will return empty list later
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 2 hrs 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 _getSubBlocks has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
      Open

          private List<SwiftTagListBlock> _getSubBlocks(
                  final int startTagNumber, final String startTagLetter, final int endTagNumber, final String endTagLetter) {
              final List<SwiftTagListBlock> result = new ArrayList<>();
      
              SwiftTagListBlock toAdd = null;

      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 getTagIndex has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
      Open

          public Integer getTagIndex(final String startTagNumber, final String[] letterOptions) {
              for (int i = 0; i < this.tags.size(); i++) {
                  final Tag t = this.tags.get(i);
                  if (StringUtils.startsWith(t.getName(), startTagNumber)) {
                      // check letter options

      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 getSubBlocksDelimitedWithOptionalTail has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public List<SwiftTagListBlock> getSubBlocksDelimitedWithOptionalTail(
                  final String[] start, final String[] end, final String[] tail) {
              if (tags != null && !tags.isEmpty()) {
                  final List<SwiftTagListBlock> result = new ArrayList<>();
                  int offset = 0;

        Method _searchSubBlockByCriteria has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private SwiftTagListBlock _searchSubBlockByCriteria(
                    final Tag tag,
                    final boolean includeDelimiterInResult,
                    SearchSelection searchSelection,
                    SearchBoundary searchBoundary) {

          Consider simplifying this complex logical expression.
          Open

                  if ((start != null && start < 0)
                          || (end != null && (end + 1) > this.tags.size())
                          || (start != null && end != null && start > end)) {
                      throw new IllegalArgumentException("start: " + start + ", end: " + end + ", size=" + this.tags.size());
                  }

            Method removeSubBlock has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
            Open

                private SwiftTagListBlock removeSubBlock(final String blockName, boolean removeAll) {
                    final SwiftTagListBlock result = new SwiftTagListBlock();
                    boolean inBlock = false;
                    boolean blockRemoved = false;
                    for (Tag t : this.tags) {
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 55 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 getTagsByName has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
            Open

                public List<Tag> getTagsByName(final String name, final String componentValue) {
                    Objects.requireNonNull(name, NAME_VALIDATION_MESSAGE);
            
                    final boolean wildcard = name.endsWith("a");
                    final List<Tag> l = new ArrayList<>();
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 55 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 getSubBlocks has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring.
            Open

                public List<SwiftTagListBlock> getSubBlocks(final Tag start, final Tag end) {
                    final List<SwiftTagListBlock> result = new ArrayList<>();
            
                    SwiftTagListBlock toAdd = null;
                    boolean blockFound = false;
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 55 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

            Avoid deeply nested control flow statements.
            Open

                                    if (StringUtils.equals(tags.get(i).getName(), tn)) {
                                        result.append(tags.get(i));
                                        added = true;
                                    }
            Severity: Major
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java - About 45 mins to fix

              Method getOptionalLists has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  public List<SwiftTagListBlock> getOptionalLists(final String[][] optionalTags) {
                      final List<SwiftTagListBlock> result = new ArrayList<>();
                      if (this.tags != null && !this.tags.isEmpty()) {
                          boolean done = false;
                          int offset = 0;
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 indexOfAnyFirst has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  public int indexOfAnyFirst(final String... tagnames) {
                      if (this.tags != null && !this.tags.isEmpty()) {
                          for (int i = 0; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
                                  if (StringUtils.equals(tn, this.tags.get(i).getName())) {
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 indexOfAnyLast has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  public int indexOfAnyLast(final String... tagnames) {
                      int result = -1;
                      if (this.tags != null && !this.tags.isEmpty()) {
                          for (int i = 0; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 indexOfAnyLastAfterIndex has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  public int indexOfAnyLastAfterIndex(final int index, final String... tagnames) {
                      int result = -1;
                      if (this.tags != null && !this.tags.isEmpty()) {
                          for (int i = index; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 indexOfAnyFirstAfterIndex has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
              Open

                  public int indexOfAnyFirstAfterIndex(final int index, final String... tagnames) {
                      if (this.tags != null && !this.tags.isEmpty()) {
                          for (int i = index; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
                                  if (StringUtils.equals(tn, this.tags.get(i).getName())) {
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 sublist has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
              Open

                  public SwiftTagListBlock sublist(final Integer start, final Integer end) {
                      if (tags == null || tags.isEmpty()) {
                          throw new IllegalStateException("No tags in this list");
                      }
                      if ((start != null && start < 0)
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 splitByTagName has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
              Open

                  public List<SwiftTagListBlock> splitByTagName(final String tagName) {
                      final List<SwiftTagListBlock> result = new ArrayList<>();
                      if (this.tags.isEmpty() || !containsTag(tagName)) {
                          result.add(this);
                      } else {
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 splitByTagName has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
              Open

                  public List<SwiftTagListBlock> splitByTagName(int tagNumber, String letterOption) {
                      if (letterOption != null) {
                          Validate.isTrue(StringUtils.length(letterOption) == 1, "letter option must be only one character");
                      }
                      final List<SwiftTagListBlock> result = new ArrayList<>();
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 indexOfFirstValue has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
              Open

                  private int indexOfFirstValue(final String tagname, final String value, boolean ignoreCR) {
                      if (this.tags != null && !this.tags.isEmpty()) {
                          for (int i = 0; i < this.tags.size(); i++) {
                              final Tag t = this.tags.get(i);
                              if ((ignoreCR && t.equalsIgnoreCR(new Tag(tagname, value)))
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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 filterByNameOrdered has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
              Open

                  public SwiftTagListBlock filterByNameOrdered(final String... names) {
                      String[] tagnames = names;
                      final SwiftTagListBlock result = new SwiftTagListBlock();
                      for (final Tag t : getTags()) {
                          boolean matched = false;
              Severity: Minor
              Found in src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.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

              Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.
              Open

                  public Integer getTagIndex(final String startTagNumber, final String[] letterOptions) {

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Refactor this method to reduce its Cognitive Complexity from 23 to the 15 allowed.
              Open

                  public SwiftTagListBlock filterByName(final boolean include, final String... names) {

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Refactor this method to reduce its Cognitive Complexity from 25 to the 15 allowed.
              Open

                  private SwiftTagListBlock _searchSubBlockByCriteria(

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.
              Open

                  private List<SwiftTagListBlock> _getSubBlocks(

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Refactor this method to reduce its Cognitive Complexity from 39 to the 15 allowed.
              Open

                  public List<SwiftTagListBlock> getSubBlocksDelimitedWithOptionalTail(

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Refactor this method to reduce its Cognitive Complexity from 26 to the 15 allowed.
              Open

                  public SwiftTagListBlock getSubBlockDelimitedWithOptionalTail(

              Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

              See

              Use already-defined constant 'NAME_VALIDATION_MESSAGE' instead of duplicating its value here.
              Open

                      Objects.requireNonNull(name, "parameter 'name' cannot not be null");

              Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

              On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

              Noncompliant Code Example

              With the default threshold of 3:

              public void run() {
                prepare("action1");                              // Noncompliant - "action1" is duplicated 3 times
                execute("action1");
                release("action1");
              }
              
              @SuppressWarning("all")                            // Compliant - annotations are excluded
              private void method1() { /* ... */ }
              @SuppressWarning("all")
              private void method2() { /* ... */ }
              
              public String method3(String a) {
                System.out.println("'" + a + "'");               // Compliant - literal "'" has less than 5 characters and is excluded
                return "";                                       // Compliant - literal "" has less than 5 characters and is excluded
              }
              

              Compliant Solution

              private static final String ACTION_1 = "action1";  // Compliant
              
              public void run() {
                prepare(ACTION_1);                               // Compliant
                execute(ACTION_1);
                release(ACTION_1);
              }
              

              Exceptions

              To prevent generating some false-positives, literals having less than 5 characters are excluded.

              Remove usage of generic wildcard type.
              Open

                  public List<? extends Field> getFieldsByName(final String name, final String componentValue) {

              It is highly recommended not to use wildcard types as return types. Because the type inference rules are fairly complex it is unlikely the user of that API will know how to use it correctly.

              Let's take the example of method returning a "List<? extends Animal>". Is it possible on this list to add a Dog, a Cat, ... we simply don't know. And neither does the compiler, which is why it will not allow such a direct use. The use of wildcard types should be limited to method parameters.

              This rule raises an issue when a method returns a wildcard type.

              Noncompliant Code Example

              List<? extends Animal> getAnimals(){...}
              

              Compliant Solution

              List<Animal> getAnimals(){...}
              

              or

              List<Dog> getAnimals(){...}
              

              Remove usage of generic wildcard type.
              Open

                  public List<? extends Field> getFieldsByNumber(final int fieldNumber) {

              It is highly recommended not to use wildcard types as return types. Because the type inference rules are fairly complex it is unlikely the user of that API will know how to use it correctly.

              Let's take the example of method returning a "List<? extends Animal>". Is it possible on this list to add a Dog, a Cat, ... we simply don't know. And neither does the compiler, which is why it will not allow such a direct use. The use of wildcard types should be limited to method parameters.

              This rule raises an issue when a method returns a wildcard type.

              Noncompliant Code Example

              List<? extends Animal> getAnimals(){...}
              

              Compliant Solution

              List<Animal> getAnimals(){...}
              

              or

              List<Dog> getAnimals(){...}
              

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

                  @Override
                  public boolean equals(Object o) {
                      if (this == o) return true;
                      if (o == null || getClass() != o.getClass()) return false;
                      if (!super.equals(o)) return false;
              src/main/java/com/prowidesoftware/swift/model/LogicalTerminalAddress.java on lines 108..115

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

              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

                              if ((endTagLetter != null && StringUtils.equals(t.getName(), endTagNumber + endTagLetter))
                                      || (endTagLetter == null && t.isNumber(endTagNumber))) {
              src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java on lines 840..841

              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

                              if ((startTagLetter != null && StringUtils.equals(t.getName(), startTagNumber + startTagLetter))
                                      || (startTagLetter == null && t.isNumber(startTagNumber))) {
              src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java on lines 833..834

              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

                          for (int i = 0; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
                                  if (StringUtils.equals(tn, this.tags.get(i).getName())) {
                                      result = i;
                                  }
              src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java on lines 1258..1264

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

              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 (int i = index; i < this.tags.size(); i++) {
                              for (final String tn : tagnames) {
                                  if (StringUtils.equals(tn, this.tags.get(i).getName())) {
                                      result = i;
                                  }
              src/main/java/com/prowidesoftware/swift/model/SwiftTagListBlock.java on lines 1241..1247

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

              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

              There are no issues that match your filters.

              Category
              Status