prowide/prowide-core

View on GitHub
src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java

Summary

Maintainability
C
1 day
Test Coverage

Method testFullMessage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Test
    public void testFullMessage() throws IOException {
        SwiftMessageComparator comp = new SwiftMessageComparator();
        assertTrue(comp.compare(new SwiftMessage(), new SwiftMessage()) == 0);

    Define a constant instead of duplicating this literal "I103BBBBUSCAXXXXN" 3 times.
    Open

            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSCAXXXXN");

    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.

    Define a constant instead of duplicating this literal "I103BBBBUSC0XXXXN" 5 times.
    Open

            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSC0XXXXN");

    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.

    Define a constant instead of duplicating this literal ":72:/ACC/ 00940060752415000231 " 3 times.
    Open

                            + ":72:/ACC/ 00940060752415000231\n"

    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.

    Define a constant instead of duplicating this literal ":20:FDF0510141142100 " 3 times.
    Open

                            + ":20:FDF0510141142100\n"

    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.

    Define a constant instead of duplicating this literal "O1001200010103BANKBEBBAXXX22221234560101031201N" 5 times.
    Open

            SwiftBlock2Output b3 = new SwiftBlock2Output("O1001200010103BANKBEBBAXXX22221234560101031201N");

    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.

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

        @Test
        public void testB2Output() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Output b3 = new SwiftBlock2Output("O1001200010103BANKBEBBAXXX22221234560101031201N");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 111..123

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 75.

    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

        @Test
        public void testB1Location() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock1 left = new SwiftBlock1();
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 79..93

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

    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

        @Test
        public void testB2Input() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSC0XXXXN");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 183..195

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

    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

        @Test
        public void testB1LT() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock1 left = new SwiftBlock1();
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 95..109

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

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

        @Test
        public void testB2InputLocation() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSC0XXXXN");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 147..157
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 171..181
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 197..207
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 209..219
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 221..231

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

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

        @Test
        public void testB2InputPriority() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSCAXXXXN");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 147..157
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 159..169
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 197..207
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 209..219
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 221..231

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

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

        @Test
        public void testB2OutputLocation() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Output b3 = new SwiftBlock2Output("O1001200010103BANKBEBBAXXX22221234560101031201N");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 147..157
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 159..169
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 171..181
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 197..207
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 221..231

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

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

        @Test
        public void testB2OutputPriority() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Output b3 = new SwiftBlock2Output("O1001200010103BANKBEBBAXXX22221234560101031201N");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 147..157
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 159..169
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 171..181
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 197..207
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 209..219

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

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

        @Test
        public void testB2OutputLT() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Output b3 = new SwiftBlock2Output("O1001200010103BANKBEBBAXXX22221234560101031201N");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 147..157
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 159..169
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 171..181
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 209..219
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 221..231

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

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

        @Test
        public void testB2InputLT() {
            SwiftMessageComparator comp = new SwiftMessageComparator();
    
            SwiftBlock2Input left = new SwiftBlock2Input("I103BBBBUSCAXXXXN");
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 159..169
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 171..181
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 197..207
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 209..219
    src/test/java/com/prowidesoftware/swift/utils/SwiftMessageComparatorTest.java on lines 221..231

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

    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

            final String fin = "{1:F01AAAAUSC0AXXX6083000009}{2:I103BBBBUSC0XXXXN}{4:\n"
                    + ":20:TCLIO200908132\n"
                    + ":23B:CRED\n"
                    + ":32A:090813USD1000,\n"
                    + ":50K:/01115446997234567890\n"
    src/test/java/com/prowidesoftware/swift/model/field/NarrativeContainerJsonUtilsTest.java on lines 33..45

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

    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