CloudSlang/cs-actions

View on GitHub
cs-postgres/src/main/java/io/cloudslang/content/postgres/services/ConfigService.java

Summary

Maintainability
C
1 day
Test Coverage

Method changeProperty has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public static void changeProperty(String filename, String[] allowedHosts, String[] allowedUsers) throws IOException {

        if ((allowedHosts == null || allowedHosts.length == 0) && (allowedUsers == null || allowedUsers.length == 0)) {
            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 changeProperty has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static void changeProperty(String filename, String[] allowedHosts, String[] allowedUsers) throws IOException {

        if ((allowedHosts == null || allowedHosts.length == 0) && (allowedUsers == null || allowedUsers.length == 0)) {
            return;
        }

    Method validateAndBuildKeyValuesMap has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public static Map<String, Object> validateAndBuildKeyValuesMap(String listenAddresses, String port, String ssl, String sslCaFile, String sslCertFile,
                                                                       String sslKeyFile, String maxConnections, String sharedBuffers,
                                                                       String effectiveCacheSize, String autovacuum, String workMem) {
    
            Map<String, Object> keyValues = new HashMap<>();

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

        public static Map<String, Object> validateAndBuildKeyValuesMap(String listenAddresses, String port, String ssl, String sslCaFile, String sslCertFile,
                                                                       String sslKeyFile, String maxConnections, String sharedBuffers,
                                                                       String effectiveCacheSize, String autovacuum, String workMem) {
    
            Map<String, Object> keyValues = new HashMap<>();

      Method validateAndBuildKeyValuesMap has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static Map<String, Object> validateAndBuildKeyValuesMap(String listenAddresses, String port, String ssl, String sslCaFile, String sslCertFile,
                                                                         String sslKeyFile, String maxConnections, String sharedBuffers,
                                                                         String effectiveCacheSize, String autovacuum, String workMem) {

        Method changeProperty has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static void changeProperty(String filename, Map<String, Object> keyValuePairs) throws IOException {
                if (keyValuePairs.size() == 0) {
                    return;
                }
        
        

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

              public static void changeProperty(String filename, Map<String, Object> keyValuePairs) throws IOException {
                  if (keyValuePairs.size() == 0) {
                      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

          Avoid deeply nested control flow statements.
          Open

                                  if (line.contains(allowedItem[0]) && line.contains(allowedItem[1])) {
                                      skip[x] = true;
                                      break;
                                  }

            There are no issues that match your filters.

            Category
            Status