CloudSlang/cs-actions

View on GitHub
cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java

Summary

Maintainability
F
1 wk
Test Coverage

Method updateWorkspaceVariables has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    @NotNull
    public static Map<String, Map<String, String>> updateWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception {
        String workspaceVariableName;
        String workspaceVariableValue;
        String sensitiveWorkspaceVariableValue;

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

File WorkspaceVariableImpl.java has 523 lines of code (exceeds 250 allowed). Consider refactoring.
Open



package io.cloudslang.content.hashicorp.terraform.services;

import com.fasterxml.jackson.core.JsonProcessingException;

    Method getWorkspaceVariablesOperationOutput has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        @NotNull
        public static Map<String, String> getWorkspaceVariablesOperationOutput(String workspaceVariablesJson, String sensitiveWorkspaceVariablesJson, Map<String, Map<String, String>> result) {
            try {
                final Map<String, String> results = new HashMap<>();
                JSONParser parser = new JSONParser();

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

        @NotNull
        public static Map<String, Map<String, String>> updateWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception {
            String workspaceVariableName;
            String workspaceVariableValue;
            String sensitiveWorkspaceVariableValue;

      Method createWorkspaceVariables has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @NotNull
          public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception {
              String workspaceVariableName;
              String workspaceVariableValue;
              String hcl;

        Method getWorkspaceVariablesOperationOutput has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @NotNull
            public static Map<String, String> getWorkspaceVariablesOperationOutput(String workspaceVariablesJson, String sensitiveWorkspaceVariablesJson, Map<String, Map<String, String>> result) {
                try {
                    final Map<String, String> results = new HashMap<>();
                    JSONParser parser = new JSONParser();

          Method createWorkspaceVariables has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              @NotNull
              public static Map<String, Map<String, String>> createWorkspaceVariables(@NotNull TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) throws Exception {
                  String workspaceVariableName;
                  String workspaceVariableValue;
                  String hcl;

          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

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

                  if (!terraformWorkspaceVariableInputs.getWorkspaceVariableJson().isEmpty() & !terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson().isEmpty()) {
                      String sensitiveWorkspaceVariableValue;
          
                      JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getWorkspaceVariableJson());
                      JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(terraformWorkspaceVariableInputs.getSensitiveWorkspaceVariableJson());
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/VariableImpl.java on lines 81..176

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

          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 < updateWorkspaceVariableJsonArray.size(); i++) {
                          updateWorkspaceVariableJson = (JSONObject) updateWorkspaceVariableJsonArray.get(i);
                          workspaceVariableName = (String) updateWorkspaceVariableJson.get("propertyName");
                          workspaceVariableValue = (String) updateWorkspaceVariableJson.get("propertyValue");
                          workspaceVariableCategory = (String) updateWorkspaceVariableJson.get("Category");
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 208..240

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

          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 < updateWorkspaceVariableJsonArray.size(); i++) {
                          updateWorkspaceVariableJson = (JSONObject) updateWorkspaceVariableJsonArray.get(i);
                          workspaceVariableName = (String) updateWorkspaceVariableJson.get("propertyName");
                          workspaceVariableValue = (String) updateWorkspaceVariableJson.get("propertyValue");
                          workspaceVariableCategory = (String) updateWorkspaceVariableJson.get("Category");
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 271..303

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

          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 < updateSensitiveWorkspaceVariableJsonArray.size(); i++) {
                          updateSensitiveWorkspaceVariableJson = (JSONObject) updateSensitiveWorkspaceVariableJsonArray.get(i);
                          workspaceVariableName = (String) updateSensitiveWorkspaceVariableJson.get("propertyName");
                          sensitiveWorkspaceVariableValue = (String) updateSensitiveWorkspaceVariableJson.get("propertyValue");
                          workspaceVariableCategory = (String) updateSensitiveWorkspaceVariableJson.get("Category");
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 308..333

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

          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 < updateSensitiveWorkspaceVariableJsonArray.size(); i++) {
                          updateSensitiveWorkspaceVariableJson = (JSONObject) updateSensitiveWorkspaceVariableJsonArray.get(i);
                          workspaceVariableName = (String) updateSensitiveWorkspaceVariableJson.get("propertyName");
                          sensitiveWorkspaceVariableValue = (String) updateSensitiveWorkspaceVariableJson.get("propertyValue");
                          workspaceVariableCategory = (String) updateSensitiveWorkspaceVariableJson.get("Category");
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 241..266

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

          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

              @NotNull
              public static String updateWorkspaceVariableRequestBody(TerraformWorkspaceVariableInputs terraformWorkspaceVariableInputs) {
                  String requestBody = EMPTY;
                  ObjectMapper updateWorkspaceVariableMapper = new ObjectMapper();
                  UpdateWorkspaceVariableRequestBody updateWorkspaceVariableRequestBody = new UpdateWorkspaceVariableRequestBody();
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/VariableImpl.java on lines 563..595

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

          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 (!sensitiveWorkspaceVariablesJson.isEmpty()) {
                          JSONArray createSensitiveWorkspaceVariableJsonArray = (JSONArray) parser.parse(sensitiveWorkspaceVariablesJson);
                          JSONObject createSensitiveWorkspaceVariableJson;
                          String sensitiveWorkspaceVariableName = EMPTY;
                          for (int i = 0; i < createSensitiveWorkspaceVariableJsonArray.size(); i++) {
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 408..430

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

          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 {
                          JSONArray createWorkspaceVariableJsonArray = (JSONArray) parser.parse(workspaceVariablesJson);
                          JSONObject createWorkspaceVariableJson;
                          String workspaceVariableName = EMPTY;
          
          
          cs-hashicorp-terraform/src/main/java/io/cloudslang/content/hashicorp/terraform/services/WorkspaceVariableImpl.java on lines 386..408

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

          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