mattray/spiceweasel

View on GitHub

Showing 64 of 64 total issues

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

    def do_google_numeric_provider(create_command_options, names, options, provided_names, run_list)
Severity: Minor
Found in lib/spiceweasel/nodes.rb - About 35 mins to fix

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

        def validate_provider(provider, names, _count, options, knifecommands)
    Severity: Minor
    Found in lib/spiceweasel/nodes.rb - About 35 mins to fix

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

                parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, "{}")
              else
                parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, "{}")
              end
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 293..296
      lib/spiceweasel/nodes.rb on lines 299..302
      lib/spiceweasel/nodes.rb on lines 311..314

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

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

                parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, "{}")
              else
                parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, "{}")
              end
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 287..290
      lib/spiceweasel/nodes.rb on lines 293..296
      lib/spiceweasel/nodes.rb on lines 299..302

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

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

                parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} droplet create #{options}".gsub(/\{\{n\}\}/, "{}")
              else
                parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} droplet create #{options}".gsub(/\{\{n\}\}/, "{}")
              end
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 287..290
      lib/spiceweasel/nodes.rb on lines 293..296
      lib/spiceweasel/nodes.rb on lines 311..314

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

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

              if opt =~ /^-i|^--identity-file/
                if opt =~ /^-i$|^--identity-file$/
                  value = "-i"
                else
                  opt.sub!(/-i/, "") if opt =~ /^-i/
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 366..373
      lib/spiceweasel/nodes.rb on lines 381..388
      lib/spiceweasel/nodes.rb on lines 396..403

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

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

              if opt =~ /^-p|^--ssh-port/
                if opt =~ /^-p$|^--ssh-port$/
                  value = "-p"
                else
                  opt.sub!(/-p/, "") if opt =~ /^-p/
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 351..358
      lib/spiceweasel/nodes.rb on lines 366..373
      lib/spiceweasel/nodes.rb on lines 381..388

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

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

              if opt =~ /^-P|^--ssh-password/
                if opt =~ /^-P$|^--ssh-password$/
                  value = "-P"
                else
                  opt.sub!(/-P/, "") if opt =~ /^-P/
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 351..358
      lib/spiceweasel/nodes.rb on lines 366..373
      lib/spiceweasel/nodes.rb on lines 396..403

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

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

                parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, "{}")
              else
                parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, "{}")
              end
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 287..290
      lib/spiceweasel/nodes.rb on lines 299..302
      lib/spiceweasel/nodes.rb on lines 311..314

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

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

              if opt =~ /^-G|^--ssh-gateway/
                if opt =~ /^-G$|^--ssh-gateway$/
                  value = "-G"
                else
                  opt.sub!(/-G/, "") if opt =~ /^-G/
      Severity: Major
      Found in lib/spiceweasel/nodes.rb and 3 other locations - About 35 mins to fix
      lib/spiceweasel/nodes.rb on lines 351..358
      lib/spiceweasel/nodes.rb on lines 381..388
      lib/spiceweasel/nodes.rb on lines 396..403

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

      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

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

          def validate_provider(provider, names, _count, options, knifecommands)
            unless knifecommands.index { |x| x.start_with?("knife #{provider}") }
              STDERR.puts "ERROR: 'knife #{provider}' is not a currently installed plugin for knife."
              exit(-1)
            end
      Severity: Minor
      Found in lib/spiceweasel/nodes.rb - About 35 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

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

          def validate(environment, cookbooks) # rubocop:disable CyclomaticComplexity
            env = nil
            file = %W{environments/#{environment}.rb environments/#{environment}.json}.find { |f| File.exist?(f) }
            environment = environment.split("/").last if environment =~ /\// # pull out directories
            if file
      Severity: Minor
      Found in lib/spiceweasel/environments.rb - About 35 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

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

          def invoke_validate_item(db, items, secret)
            items = [] if items.nil?
            Spiceweasel::Log.debug("data bag: #{db} #{secret} #{items}")
            items.each do |item|
              Spiceweasel::Log.debug("data bag #{db} item: #{item}")
      Severity: Minor
      Found in lib/spiceweasel/data_bags.rb - About 35 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

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

          def parse_and_validate_options
            ARGV << "-h" if ARGV.empty?
            begin
              parse_options
              # Load knife configuration if using knife config
      Severity: Minor
      Found in lib/spiceweasel/cli.rb - About 35 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

      Method process_manifest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_manifest(manifest)
            do_not_validate = Spiceweasel::Config[:novalidation]
            berksfile = nil
            berksfile = Berksfile.new(manifest["berksfile"]) if manifest.include?("berksfile")
            if berksfile
      Severity: Minor
      Found in lib/spiceweasel/cli.rb - About 25 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

      Method find_manifest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_manifest
            ARGV.each do |arg|
              if arg =~ /\.json$|\.rb$|\.yml$/
                return arg unless ARGV[ARGV.find_index(arg) - 1].eql?("--cluster-file")
              end
      Severity: Minor
      Found in lib/spiceweasel/cli.rb - About 25 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

      Method parse_data_bags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.parse_data_bags
            data_bags = []
            Dir.glob("data_bags/*").each do |data_bag_full_path|
              next unless File.directory?(data_bag_full_path)
              data_bag = data_bag_full_path.split("/").last
      Severity: Minor
      Found in lib/spiceweasel/extract_local.rb - About 25 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

      Method validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(role, _environments, cookbooks, roles) # rubocop:disable CyclomaticComplexity
            # validate the role passed in match the name of either the .rb or .json
            file = %W{roles/#{role}.rb roles/#{role}.json}.find { |f| File.exist?(f) }
            role = role.split("/").last if role =~ /\// # pull out directories
            if file
      Severity: Minor
      Found in lib/spiceweasel/roles.rb - About 25 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

      Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(commands)
            # for now we're shelling out
            commands.each do |cmd|
              Spiceweasel::Log.debug("Command will timeout after #{Spiceweasel::Config[:cmd_timeout]} seconds.")
              knife = Mixlib::ShellOut.new(cmd.command, cmd.shellout_opts.merge(live_stream: STDOUT, timeout: Spiceweasel::Config[:timeout].to_i))
      Severity: Minor
      Found in lib/spiceweasel/execute.rb - About 25 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

      Method evaluate_c_role has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def evaluate_c_role(file)
            c_role = nil
            case file
            when /\.json$/
              c_role = Chef::JSONCompat.from_json(IO.read(file))
      Severity: Minor
      Found in lib/spiceweasel/roles.rb - About 25 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

      Severity
      Category
      Status
      Source
      Language