cloudamatic/mu

View on GitHub
modules/mu/providers/google/container_cluster.rb

Summary

Maintainability
F
4 days
Test Coverage

Assignment Branch Condition size for toKitten is too high. [303.2/75]
Open

        def toKitten(**_args)

          bok = {
            "cloud" => "Google",
            "project" => @config['project'],

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

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

        def create
          labels = Hash[@tags.keys.map { |k|
            [k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
          ]
          labels["name"] = MU::Cloud::Google.nameStr(@mu_name)

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

Assignment Branch Condition size for groom is too high. [235.3/75]
Open

        def groom
          labelCluster 

          me = cloud_desc

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

Assignment Branch Condition size for validateConfig is too high. [197.7/75]
Open

        def self.validateConfig(cluster, configurator)
          ok = true
          cluster['project'] ||= MU::Cloud::Google.defaultProject(cluster['credentials'])

          cluster['master_az'] ||= cluster['availability_zone'] if cluster['availability_zone']

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

Class has too many lines. [1113/1000]
Open

      class ContainerCluster < MU::Cloud::ContainerCluster

        # Initialize this cloud resource object. Calling +super+ will invoke the initializer defined under {MU::Cloud}, which should set the attribtues listed in {MU::Cloud::PUBLIC_ATTRS} as well as applicable dependency shortcuts, like <tt>@vpc</tt>, for us.
        # @param args [Hash]: Hash of named arguments passed via Ruby's double-splat
        def initialize(**args)

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File container_cluster.rb has 1120 lines of code (exceeds 1000 allowed). Consider refactoring.
Open

module MU
  class Cloud
    class Google
      # A Kubernetes cluster as configured in {MU::Config::BasketofKittens::container_clusters}
      class ContainerCluster < MU::Cloud::ContainerCluster
Severity: Major
Found in modules/mu/providers/google/container_cluster.rb - About 4 hrs to fix

    Cyclomatic complexity for toKitten is too high. [56/30]
    Open

            def toKitten(**_args)
    
              bok = {
                "cloud" => "Google",
                "project" => @config['project'],

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Perceived complexity for toKitten is too high. [60/35]
    Open

            def toKitten(**_args)
    
              bok = {
                "cloud" => "Google",
                "project" => @config['project'],

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Perceived complexity for create is too high. [56/35]
    Open

            def create
              labels = Hash[@tags.keys.map { |k|
                [k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
              ]
              labels["name"] = MU::Cloud::Google.nameStr(@mu_name)

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Cyclomatic complexity for validateConfig is too high. [51/30]
    Open

            def self.validateConfig(cluster, configurator)
              ok = true
              cluster['project'] ||= MU::Cloud::Google.defaultProject(cluster['credentials'])
    
              cluster['master_az'] ||= cluster['availability_zone'] if cluster['availability_zone']

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Perceived complexity for validateConfig is too high. [55/35]
    Open

            def self.validateConfig(cluster, configurator)
              ok = true
              cluster['project'] ||= MU::Cloud::Google.defaultProject(cluster['credentials'])
    
              cluster['master_az'] ||= cluster['availability_zone'] if cluster['availability_zone']

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Cyclomatic complexity for create is too high. [49/30]
    Open

            def create
              labels = Hash[@tags.keys.map { |k|
                [k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
              ]
              labels["name"] = MU::Cloud::Google.nameStr(@mu_name)

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Cyclomatic complexity for groom is too high. [48/30]
    Open

            def groom
              labelCluster 
    
              me = cloud_desc
    
    

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Perceived complexity for groom is too high. [53/35]
    Open

            def groom
              labelCluster 
    
              me = cloud_desc
    
    

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Method create has 204 lines of code (exceeds 150 allowed). Consider refactoring.
    Open

            def create
              labels = Hash[@tags.keys.map { |k|
                [k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
              ]
              labels["name"] = MU::Cloud::Google.nameStr(@mu_name)
    Severity: Major
    Found in modules/mu/providers/google/container_cluster.rb - About 3 hrs to fix

      Method schema has 202 lines of code (exceeds 150 allowed). Consider refactoring.
      Open

              def self.schema(config)
                toplevel_required = []
                gke_defaults = defaults
                schema = {
                  "auto_upgrade" => {
      Severity: Major
      Found in modules/mu/providers/google/container_cluster.rb - About 3 hrs to fix

        Method validateConfig has a Cognitive Complexity of 88 (exceeds 75 allowed). Consider refactoring.
        Open

                def self.validateConfig(cluster, configurator)
                  ok = true
                  cluster['project'] ||= MU::Cloud::Google.defaultProject(cluster['credentials'])
        
                  cluster['master_az'] ||= cluster['availability_zone'] if cluster['availability_zone']
        Severity: Minor
        Found in modules/mu/providers/google/container_cluster.rb - About 2 hrs 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

        Method toKitten has 185 lines of code (exceeds 150 allowed). Consider refactoring.
        Open

                def toKitten(**_args)
        
                  bok = {
                    "cloud" => "Google",
                    "project" => @config['project'],
        Severity: Major
        Found in modules/mu/providers/google/container_cluster.rb - About 2 hrs to fix

          Method has too many lines. [204/200]
          Open

                  def create
                    labels = Hash[@tags.keys.map { |k|
                      [k.downcase, @tags[k].downcase.gsub(/[^-_a-z0-9]/, '-')] }
                    ]
                    labels["name"] = MU::Cloud::Google.nameStr(@mu_name)

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method groom has 177 lines of code (exceeds 150 allowed). Consider refactoring.
          Open

                  def groom
                    labelCluster 
          
                    me = cloud_desc
          
          
          Severity: Major
          Found in modules/mu/providers/google/container_cluster.rb - About 2 hrs to fix

            Method has too many lines. [202/200]
            Open

                    def self.schema(config)
                      toplevel_required = []
                      gke_defaults = defaults
                      schema = {
                        "auto_upgrade" => {

            This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

            Method toKitten has a Cognitive Complexity of 78 (exceeds 75 allowed). Consider refactoring.
            Open

                    def toKitten(**_args)
            
                      bok = {
                        "cloud" => "Google",
                        "project" => @config['project'],
            Severity: Minor
            Found in modules/mu/providers/google/container_cluster.rb - About 45 mins 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 more than 4 levels of block nesting.
            Open

                              if (retries % 5) == 0
                                MU.log "Waiting to delete GKE cluster #{cluster.name}: #{e.message}", MU::NOTICE
                              end

            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.

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                              if v.match(/^#{Regexp.quote(cluster['kubernetes']['nodeversion'])}/)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use casecmp instead of downcase ==.
            Open

                             cloud_desc.resource_labels["mu-id"].downcase == sa.description.downcase

            This cop identifies places where a case-insensitive string comparison can better be implemented using casecmp.

            Example:

            # bad
            str.downcase == 'abc'
            str.upcase.eql? 'ABC'
            'abc' == str.downcase
            'ABC'.eql? str.upcase
            str.downcase == str.downcase
            
            # good
            str.casecmp('ABC').zero?
            'abc'.casecmp(str).zero?

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                            elsif e.message.match(/failedPrecondition: /)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                            if v.match(/^#{Regexp.quote(cluster['kubernetes']['nodeversion'])}/)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                            if e.message.match(/notFound: /)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                              if v.match(/^#{Regexp.quote(cluster['kubernetes']['version'])}/)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                      cloud_desc.network_config.network.match(/^projects\/(.*?)\/.*?\/networks\/([^\/]+)(?:$|\/)/)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use =~ in places where the MatchData returned by #match will not be used.
            Open

                            if v.match(/^#{Regexp.quote(cluster['kubernetes']['version'])}/)

            This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

            Example:

            # bad
            do_something if str.match(/regex/)
            while regex.match('str')
              do_something
            end
            
            # good
            method(str =~ /regex/)
            return value unless regex =~ 'str'

            Use tr instead of gsub.
            Open

                              (!ignoremaster and cluster.resource_labels['mu-master-ip'] != MU.mu_public_ip.gsub(/\./, "_"))

            This cop identifies places where gsub can be replaced by tr or delete.

            Example:

            # bad
            'abc'.gsub('b', 'd')
            'abc'.gsub('a', '')
            'abc'.gsub(/a/, 'd')
            'abc'.gsub!('a', 'd')
            
            # good
            'abc'.gsub(/.*/, 'a')
            'abc'.gsub(/a+/, 'd')
            'abc'.tr('b', 'd')
            'a b c'.delete(' ')

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

                      if cluster['kubernetes'] and cluster['kubernetes']['nodeversion']
                        if cluster['kubernetes']['nodeversion'] == "latest"
                          cluster['kubernetes']['nodeversion'] = node_versions.last
                        elsif !node_versions.include?(cluster['kubernetes']['nodeversion'])
                          match = false
            Severity: Major
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 3 hrs to fix
            modules/mu/providers/google/container_cluster.rb on lines 1101..1127

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

            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 cluster['kubernetes'] and cluster['kubernetes']['version']
                        if cluster['kubernetes']['version'] == "latest"
                          cluster['kubernetes']['version'] = master_versions.last
                        elsif !master_versions.include?(cluster['kubernetes']['version'])
                          match = false
            Severity: Major
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 3 hrs to fix
            modules/mu/providers/google/container_cluster.rb on lines 1131..1157

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

            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

                    def self.find(**args)
                      args = MU::Cloud::Google.findLocationArgs(args)
            
                      found = {}
            
            
            Severity: Major
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 3 hrs to fix
            modules/mu/providers/google/function.rb on lines 284..310

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

            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

                        desc[:addons_config] = MU::Cloud::Google.container(:AddonsConfig).new(
                          horizontal_pod_autoscaling: MU::Cloud::Google.container(:HorizontalPodAutoscaling).new(
                            disabled: !@config['kubernetes']['horizontal_pod_autoscaling']
                          ),
                          http_load_balancing: MU::Cloud::Google.container(:HttpLoadBalancing).new(
            Severity: Major
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 1 hr to fix
            modules/mu/providers/google/container_cluster.rb on lines 387..400

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

            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

                          updates << { :desired_addons_config => MU::Cloud::Google.container(:AddonsConfig).new(
                            horizontal_pod_autoscaling: MU::Cloud::Google.container(:HorizontalPodAutoscaling).new(
                              disabled: !@config['kubernetes']['horizontal_pod_autoscaling']
                            ),
                            http_load_balancing: MU::Cloud::Google.container(:HttpLoadBalancing).new(
            Severity: Major
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 1 hr to fix
            modules/mu/providers/google/container_cluster.rb on lines 112..125

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

            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 @config['kubernetes'] and @config['kubernetes']['version']
                        if MU.version_sort(@config['kubernetes']['version'], me.current_master_version) > 0
                          updates << {  :desired_master_version => @config['kubernetes']['version'] }
                        end
                      end
            Severity: Minor
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 25 mins to fix
            modules/mu/providers/google/container_cluster.rb on lines 410..414

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

                      if @config['kubernetes'] and @config['kubernetes']['nodeversion']
                        if MU.version_sort(@config['kubernetes']['nodeversion'], me.current_node_version) > 0
                          updates << { :desired_node_version => @config['kubernetes']['nodeversion'] }
                        end
                      end
            Severity: Minor
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 25 mins to fix
            modules/mu/providers/google/container_cluster.rb on lines 404..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 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

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

                            maintenance_policy: MU::Cloud::Google.container(:MaintenancePolicy).new(
                              window: MU::Cloud::Google.container(:MaintenanceWindow).new(
                                daily_maintenance_window: MU::Cloud::Google.container(:DailyMaintenanceWindow).new(
                                  start_time: @config['preferred_maintenance_window']
                                )
            Severity: Minor
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 20 mins to fix
            modules/mu/providers/google/container_cluster.rb on lines 166..172

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

            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

                        desc[:maintenance_policy] = MU::Cloud::Google.container(:MaintenancePolicy).new(
                          window: MU::Cloud::Google.container(:MaintenanceWindow).new(
                            daily_maintenance_window: MU::Cloud::Google.container(:DailyMaintenanceWindow).new(
                              start_time: @config['preferred_maintenance_window']
                            )
            Severity: Minor
            Found in modules/mu/providers/google/container_cluster.rb and 1 other location - About 20 mins to fix
            modules/mu/providers/google/container_cluster.rb on lines 445..451

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

            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

            end at 1030, 12 is not aligned with if at 1026, 21.
            Open

                        end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            end at 198, 14 is not aligned with if at 194, 45.
            Open

                          end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            Use meaningful heredoc delimiters.
            Open

                          EOF

            This cop checks that your heredocs are using meaningful delimiters. By default it disallows END and EO*, and can be configured through blacklisting additional delimiters.

            Example:

            # good
            <<-SQL
              SELECT * FROM foo
            SQL
            
            # bad
            <<-END
              SELECT * FROM foo
            END
            
            # bad
            <<-EOS
              SELECT * FROM foo
            EOS

            end at 87, 10 is not aligned with if at 83, 22.
            Open

                      end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            Unused method argument - deploy_id.
            Open

                    def self.cleanup(noop: false, deploy_id: MU.deploy_id, ignoremaster: false, region: MU.curRegion, credentials: nil, flags: {})

            This cop checks for unused method arguments.

            Example:

            # bad
            
            def some_method(used, unused, _unused_but_allowed)
              puts used
            end

            Example:

            # good
            
            def some_method(used, _unused, _unused_but_allowed)
              puts used
            end

            Do not suppress exceptions.
            Open

                        rescue NameError

            This cop checks for rescue blocks with no body.

            Example:

            # bad
            
            def some_method
              do_something
            rescue
              # do nothing
            end

            Example:

            # bad
            
            begin
              do_something
            rescue
              # do nothing
            end

            Example:

            # good
            
            def some_method
              do_something
            rescue
              handle_exception
            end

            Example:

            # good
            
            begin
              do_something
            rescue
              handle_exception
            end

            Redundant use of Object#to_s in interpolation.
            Open

                          raise MuError, "Failed to get service account cloud id from #{@config['service_account'].to_s}"

            This cop checks for string conversion in string interpolation, which is redundant.

            Example:

            # bad
            
            "result is #{something.to_s}"

            Example:

            # good
            
            "result is #{something}"

            end at 82, 10 is not aligned with if at 65, 20.
            Open

                      end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            end at 596, 10 is not aligned with if at 590, 32.
            Open

                      end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            end at 312, 10 is not aligned with if at 308, 22.
            Open

                      end

            This cop checks whether the end keywords are aligned properly.

            Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

            If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

            If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

            If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

            Example: EnforcedStyleAlignWith: keyword (default)

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
                       end

            Example: EnforcedStyleAlignWith: variable

            # bad
            
            variable = if true
                end
            
            # good
            
            variable = if true
            end

            Example: EnforcedStyleAlignWith: startofline

            # bad
            
            variable = if true
                end
            
            # good
            
            puts(if true
            end)

            There are no issues that match your filters.

            Category
            Status