CloudSlang/cloud-slang

View on GitHub
cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java

Summary

Maintainability
F
3 days
Test Coverage

File SlangTestRunner.java has 499 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*******************************************************************************
 * (c) Copyright 2016 Hewlett-Packard Development Company, L.P.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0 which accompany this distribution.
 *

    SlangTestRunner has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @Component
    public class SlangTestRunner {
    
        private static final String PROJECT_PATH_TOKEN = "${project_path}";
        public static final long MAX_TIME_PER_TESTCASE_IN_MINUTES = 10;

      Method createTestCases has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public Map<String, SlangTestCase> createTestCases(String testPath, Set<String> allAvailableExecutables) {
              Validate.notEmpty(testPath, "You must specify a path for tests");
              File testPathDir = new File(testPath);
              Validate.isTrue(testPathDir.isDirectory(),
                      "Directory path argument \'" + testPath + "\' does not lead to a directory");

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

          public Map<String, SlangTestCase> createTestCases(String testPath, Set<String> allAvailableExecutables) {
              Validate.notEmpty(testPath, "You must specify a path for tests");
              File testPathDir = new File(testPath);
              Validate.isTrue(testPathDir.isDirectory(),
                      "Directory path argument \'" + testPath + "\' does not lead to a directory");

        Method runTestsParallel has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void runTestsParallel(String projectPath, Map<String, SlangTestCase> testCases,
                                         Map<String, CompilationArtifact> compiledFlows,
                                         ThreadSafeRunTestResults runTestsResults) {
                if (MapUtils.isEmpty(testCases)) {
                    return;

          Method runTestCaseSequentiallyToCompletion has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public Long runTestCaseSequentiallyToCompletion(SlangTestCase testCase, CompilationArtifact compilationArtifact,
                                                              Map<String, Value> inputs,
                                                              Set<SystemProperty> systemProperties) {
          
                  final String result = testCase.getResult();

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

                public Long runTestCaseInParallelToCompletion(SlangTestCase testCase, CompilationArtifact compilationArtifact,
                                                              Map<String, Value> inputs,
                                                              Set<SystemProperty> systemProperties,
                                                              MultiTriggerTestCaseEventListener globalListener) {
            
            

              Method runTestsParallel has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public void runTestsParallel(String projectPath, Map<String, SlangTestCase> testCases,
                                               Map<String, CompilationArtifact> compiledFlows,
                                               ThreadSafeRunTestResults runTestsResults) {
                      if (MapUtils.isEmpty(testCases)) {
                          return;

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

                  public Map<TestCaseRunState, Map<String, SlangTestCase>> splitTestCasesByRunState(
                          final BulkRunMode bulkRunMode,
                          final Map<String, SlangTestCase> testCases,
                          final List<String> testSuites,
                          final IRunTestResults runTestsResults,

              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 handleExpectedExceptionCase has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private Long handleExpectedExceptionCase(SlangTestCase testCase, CompilationArtifact compilationArtifact,
                                                           String flowName, Long executionId,
                                                           String errorMessageFlowExecution, String testCaseReference) {

                Method runTestCaseInParallelToCompletion has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public Long runTestCaseInParallelToCompletion(SlangTestCase testCase, CompilationArtifact compilationArtifact,
                                                                  Map<String, Value> inputs,
                                                                  Set<SystemProperty> systemProperties,
                                                                  MultiTriggerTestCaseEventListener globalListener) {

                  Method splitTestCasesByRunState has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                              final BulkRunMode bulkRunMode,
                              final Map<String, SlangTestCase> testCases,
                              final List<String> testSuites,
                              final IRunTestResults runTestsResults,
                              final BuildModeConfig buildModeConfig) {

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

                        private void handleTestCaseFailuresFromOutputs(SlangTestCase testCase, String testCaseReference,
                                                                       Map<String, Serializable> outputs,
                                                                       Map<String, Serializable> executionOutputs) {
                            String message;
                            if (MapUtils.isNotEmpty(outputs)) {

                    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 processActiveTest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private void processActiveTest(final BulkRunMode bulkRunMode, final Map<TestCaseRunState,
                                Map<String, SlangTestCase>> resultMap, Map.Entry<String, SlangTestCase> testCaseEntry,
                                                       SlangTestCase testCase) {
                            if (bulkRunMode == BulkRunMode.POSSIBLY_MIXED) {
                                TestCaseRunMode runModeForTestCase = testRunInfoService

                    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

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

                            if (result != null && !result.equals(executionResult)) {
                                message = TEST_CASE_FAILED + testCaseReference + " - " + testCase.getDescription() +
                                        "\n\tExpected result: " + result + "\n\tActual result: " + executionResult;
                                loggingService.logEvent(Level.ERROR, message);
                                throw new RuntimeException(message);
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 489..494

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

                    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 (result != null && !result.equals(executionResult)) {
                                message = TEST_CASE_FAILED + testCaseReference + " - " + testCase.getDescription() +
                                        "\n\tExpected result: " + result + "\n\tActual result: " + executionResult;
                                loggingService.logEvent(Level.ERROR, message);
                                throw new RuntimeException(message);
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 538..543

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

                    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

                                if (runModeForTestCase == TestCaseRunMode.SEQUENTIAL) {
                                    resultMap.get(TestCaseRunState.SEQUENTIAL).put(testCaseEntry.getKey(), testCase);
                                } else if (runModeForTestCase == TestCaseRunMode.PARALLEL) {
                                    resultMap.get(TestCaseRunState.PARALLEL).put(testCaseEntry.getKey(), testCase);
                                }
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 325..329

                    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

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

                            } else if (bulkRunMode == BulkRunMode.ALL_SEQUENTIAL) {
                                resultMap.get(TestCaseRunState.SEQUENTIAL).put(testCaseEntry.getKey(), testCase);
                            } else if (bulkRunMode == BulkRunMode.ALL_PARALLEL) {
                                resultMap.get(TestCaseRunState.PARALLEL).put(testCaseEntry.getKey(), testCase);
                            }
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 320..324

                    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

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

                            if (StringUtils.isNotBlank(errorMessageFlowExecution)) {
                                // unexpected exception occurred during flow execution
                                message = "Error occurred while running test: " + testCaseReference + " - " +
                                        testCase.getDescription() + "\n\t" + errorMessageFlowExecution;
                                loggingService.logEvent(Level.INFO, message);
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 529..535

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 58.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                            if (StringUtils.isNotBlank(errorMessageFlowExecution)) {
                                // unexpected exception occurred during flow execution
                                message = "Error occurred while running test: " + testCaseReference + " - " +
                                        testCase.getDescription() + "\n\t" + errorMessageFlowExecution;
                                loggingService.logEvent(Level.INFO, message);
                    cloudslang-content-verifier/src/main/java/io/cloudslang/lang/tools/build/tester/SlangTestRunner.java on lines 480..486

                    Duplicated Code

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

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

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

                    Tuning

                    This issue has a mass of 58.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    There are no issues that match your filters.

                    Category
                    Status