cloudamatic/mu

View on GitHub
modules/mu/providers/aws/storage_pool.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Assignment Branch Condition size for create is too high. [83.74/75]
Open

        def create
          MU.log "Creating storage pool #{@mu_name}"
          resp = MU::Cloud::AWS.efs(region: @region, credentials: @credentials).create_file_system(
            creation_token: @mu_name,
            performance_mode: @config['storage_type']

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method cleanup has a Cognitive Complexity of 85 (exceeds 75 allowed). Consider refactoring.
Open

        def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})
          MU.log "AWS::StoragePool.cleanup: need to support flags['known']", MU::DEBUG, details: flags

          supported_regions = %w{us-west-2 us-east-1 eu-west-1}
          if supported_regions.include?(region)
Severity: Minor
Found in modules/mu/providers/aws/storage_pool.rb - 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

Avoid deeply nested control flow statements.
Open

                    raise MuError, "Failed to delete filesystem #{pool.name}: #{pool.file_system_id}, still in use." if attempts >= 6
Severity: Major
Found in modules/mu/providers/aws/storage_pool.rb - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                          rescue Aws::EFS::Errors::BadRequest => e
                            MU.log "Mount target #{mp.mount_target_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid mount target ID")
    Severity: Major
    Found in modules/mu/providers/aws/storage_pool.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          MU.log "Filesystem #{pool.name}: #{pool.file_system_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid file system ID")
      Severity: Major
      Found in modules/mu/providers/aws/storage_pool.rb - About 45 mins to fix

        Avoid more than 4 levels of block nesting.
        Open

                            MU.log "Filesystem #{pool.name}: #{pool.file_system_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid file system ID")

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 4 levels of block nesting.
        Open

                            raise MuError, "Failed to delete filesystem #{pool.name}: #{pool.file_system_id}, still in use." if attempts >= 6

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

        Avoid more than 4 levels of block nesting.
        Open

                              rescue Aws::EFS::Errors::BadRequest => e
                                MU.log "Mount target #{mp.mount_target_id} already deleted", MU::NOTICE if e.to_s.start_with?("invalid mount target ID")

        This cop checks for excessive nesting of conditional and looping constructs.

        You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

        The maximum level of nesting allowed is configurable.

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

                    resp = MU::Cloud::AWS.efs(region: args[:region], credentials: args[:credentials]).describe_file_systems
                    if resp and resp.file_systems
                      resp.file_systems.each { |fs|
                        found[fs.file_system_id] = fs
                      }
        Severity: Minor
        Found in modules/mu/providers/aws/storage_pool.rb and 2 other locations - About 25 mins to fix
        modules/mu/providers/aws/alarm.rb on lines 158..163
        modules/mu/providers/aws/endpoint.rb on lines 450..455

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

        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

                        tags.each { |tag|
                          found_muid = true if tag.key == "MU-ID" && tag.value == deploy_id
                          found_master = true if tag.key == "MU-MASTER-IP" && tag.value == MU.mu_public_ip
                        }
        Severity: Minor
        Found in modules/mu/providers/aws/storage_pool.rb and 2 other locations - About 25 mins to fix
        modules/mu/providers/aws/cache_cluster.rb on lines 624..627
        modules/mu/providers/aws/dnszone.rb on lines 698..701

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

        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

                def arn
                  "arn:"+(MU::Cloud::AWS.isGovCloud?(@region) ? "aws-us-gov" : "aws")+":elasticfilesystem:"+@region+":"+MU::Cloud::AWS.credToAcct(@credentials)+":file-system/"+@cloud_id
        Severity: Major
        Found in modules/mu/providers/aws/storage_pool.rb and 5 other locations - About 20 mins to fix
        modules/mu/providers/aws/cache_cluster.rb on lines 37..38
        modules/mu/providers/aws/firewall_rule.rb on lines 207..208
        modules/mu/providers/aws/msg_queue.rb on lines 73..74
        modules/mu/providers/aws/server.rb on lines 911..912
        modules/mu/providers/aws/vpc.rb on lines 222..223

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

        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