prowide/prowide-core

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

Summary

Maintainability
F
6 days
Test Coverage

File SwiftMessage.java has 879 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/SwiftMessage.java - About 2 days to fix

    SwiftMessage has 98 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class SwiftMessage implements Serializable, JsonSerializable {
        static final int JSON_VERSION = 2;
        private static final long serialVersionUID = 8094995269559985432L;
        private static final transient java.util.logging.Logger log =
                java.util.logging.Logger.getLogger(SwiftMessage.class.getName());
    Severity: Major
    Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java - About 1 day to fix

      Method toMT has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
      Open

          public AbstractMT toMT() {
              final String type = getType();
              if (type == null) {
                  if (isServiceMessage21()) {
                      return ServiceMessage21.newInstance(this);
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.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 visit has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public void visit(final IMessageVisitor visitor) {
              Objects.requireNonNull(visitor);
      
              // start visiting
              visitor.startMessage(this);
      Severity: Minor
      Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java - About 1 hr to fix

        Method toMT has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public AbstractMT toMT() {
                final String type = getType();
                if (type == null) {
                    if (isServiceMessage21()) {
                        return ServiceMessage21.newInstance(this);
        Severity: Minor
        Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java - About 1 hr to fix

          Method visit has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring.
          Open

              public void visit(final IMessageVisitor visitor) {
                  Objects.requireNonNull(visitor);
          
                  // start visiting
                  visitor.startMessage(this);
          Severity: Minor
          Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.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 addBlock has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void addBlock(final SwiftBlock b) {
                  Objects.requireNonNull(b);
          
                  // support for user blocks in this method is useful for XML parser and other code that
                  // takes advantages of using SwiftTagListBlock
          Severity: Minor
          Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java - About 1 hr to fix

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

                public int getBlockCount(final Boolean includeUserBlocks) {
            
                    // count the basic blocks
                    int count = 0;
                    if (this.block1 != null && !this.block1.isEmpty()) {
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.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 equals has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
            Open

                @Override
                public boolean equals(Object o) {
                    if (this == o) return true;
                    if (o == null || getClass() != o.getClass()) return false;
                    SwiftMessage that = (SwiftMessage) o;
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.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 removeEmptyBlocks has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
            Open

                public SwiftMessage removeEmptyBlocks() {
                    if (this.block1 != null && this.block1.isEmpty()) {
                        this.block1 = null;
                    }
                    if (this.block2 != null && this.block2.isEmpty()) {
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.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

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

                public AbstractMT toMT() {

            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

            Null is returned but a "Boolean" is expected.
            Open

                    return null;

            While null is technically a valid Boolean value, that fact, and the distinction between Boolean and boolean is easy to forget. So returning null from a Boolean method is likely to cause problems with callers' code.

            Noncompliant Code Example

            public Boolean isUsable() {
              // ...
              return null;  // Noncompliant
            }
            

            See

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

                    return Objects.equals(block1, that.block1)
                            && Objects.equals(block2, that.block2)
                            && Objects.equals(block3, that.block3)
                            && Objects.equals(block4, that.block4)
                            && Objects.equals(block5, that.block5)
            src/main/java/com/prowidesoftware/swift/model/SwiftBlock2Output.java on lines 635..641

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

            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 3 locations. Consider refactoring.
            Open

                public static void visit(final SwiftBlock5 block, final IMessageVisitor visitor) {
                    // sanity check
                    Objects.requireNonNull(block);
                    Objects.requireNonNull(visitor);
            
            
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 192..202
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 237..248

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

            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 3 locations. Consider refactoring.
            Open

                public static void visit(final SwiftBlock4 block, final IMessageVisitor visitor) {
                    // sanity check
                    Objects.requireNonNull(block);
                    Objects.requireNonNull(visitor);
            
            
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 215..225
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 237..248

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

            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 3 locations. Consider refactoring.
            Open

                public static void visit(final SwiftBlockUser block, final IMessageVisitor visitor) {
                    // sanity check
                    Objects.requireNonNull(block);
                    Objects.requireNonNull(visitor);
            
            
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 192..202
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 215..225

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

            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

                public boolean isNack() {
                    if (isServiceMessage21()) {
                        if (this.block4 == null) {
                            return false;
                        }
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 35 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1678..1686

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

            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

                public boolean isAck() {
                    if (isServiceMessage21()) {
                        if (this.block4 == null) {
                            return false;
                        }
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 35 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1696..1704

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

            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

                public void setServiceTypeIdentifier(final String serviceTypeIdentifier) {
                    if (this.block3 == null) {
                        this.block3 = new SwiftBlock3();
                    }
                    this.block3.builder().setField111(new Field111(serviceTypeIdentifier));
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 30 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1842..1847

            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

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

                public void setUETR(final String uniqueEndToEndTransactionReference) {
                    if (this.block3 == null) {
                        this.block3 = new SwiftBlock3();
                    }
                    this.block3.builder().setField121(new Field121(uniqueEndToEndTransactionReference));
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 30 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1816..1821

            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

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

                public boolean isType(final int... types) {
                    final int mt = getTypeInt();
                    for (final int t : types) {
                        if (mt == t) {
                            return true;
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 30 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1614..1622

            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

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

                public final boolean isCategory(final MtCategory... categories) {
                    final MtCategory cat = getCategory();
                    for (final MtCategory t : categories) {
                        if (cat == t) {
                            return true;
            Severity: Minor
            Found in src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java and 1 other location - About 30 mins to fix
            src/main/java/com/prowidesoftware/swift/model/SwiftMessage.java on lines 1597..1605

            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