mattray/spiceweasel

View on GitHub

Showing 52 of 64 total issues

Method process_chef_client has a Cognitive Complexity of 126 (exceeds 5 allowed). Consider refactoring.
Open

    def process_chef_client(names, options, run_list) # rubocop:disable CyclomaticComplexity
      commands = []
      environment = nil
      protocol = "ssh"
      protooptions = ""
Severity: Minor
Found in lib/spiceweasel/nodes.rb - About 2 days 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 54 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(nodes, cookbooks, environments, roles, knifecommands, rootoptions) # rubocop:disable CyclomaticComplexity
      @create = []
      @delete = []
      chefclient = []
      create_command_options = {}
Severity: Minor
Found in lib/spiceweasel/nodes.rb - About 1 day 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

File nodes.rb has 424 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Spiceweasel
  # manages parsing of Nodes
  class Nodes
    include CommandHelper

Severity: Minor
Found in lib/spiceweasel/nodes.rb - About 6 hrs to fix

    Method process_chef_client has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def process_chef_client(names, options, run_list) # rubocop:disable CyclomaticComplexity
          commands = []
          environment = nil
          protocol = "ssh"
          protooptions = ""
    Severity: Major
    Found in lib/spiceweasel/nodes.rb - About 5 hrs to fix

      File cli.rb has 322 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "mixlib/cli"
      require "ffi_yajl"
      require "yaml"
      
      require "spiceweasel/command_helper"
      Severity: Minor
      Found in lib/spiceweasel/cli.rb - About 3 hrs to fix

        Method process_parallel has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_parallel(count, create_command_options, name, options, provider, run_list)
              parallel = "seq #{count} | parallel -u -j 0 -v -- "
              if provider.eql?("vsphere")
                if bundler?
                  parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, "{}")
        Severity: Minor
        Found in lib/spiceweasel/nodes.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 initialize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(nodes, cookbooks, environments, roles, knifecommands, rootoptions) # rubocop:disable CyclomaticComplexity
              @create = []
              @delete = []
              chefclient = []
              create_command_options = {}
        Severity: Major
        Found in lib/spiceweasel/nodes.rb - About 2 hrs to fix

          Method do_flattened_environments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def do_flattened_environments(cookbooks, environments)
                flatenvs = environments.map(&:keys).flatten
                envfiles = []
                flatenvs.each do |env|
                  Spiceweasel::Log.debug("environment: #{env}")
          Severity: Minor
          Found in lib/spiceweasel/environments.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

          Method validate_cookbooks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate_cookbooks(cookbooks)
                c_names = []
                cookbooks.each do |cookbook|
                  name = cookbook.keys.first
                  if cookbook[name]
          Severity: Minor
          Found in lib/spiceweasel/cookbooks.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

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

              def validate_run_list(node, run_list, cookbooks, roles)
                run_list.split(",").each do |item|
                  if item.start_with?("recipe[")
                    # recipe[foo] or recipe[foo::bar]
                    cb = item.split(/\[|\]/)[1].split(":")[0]
          Severity: Minor
          Found in lib/spiceweasel/nodes.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

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

              def role_run_list(c_role, cookbooks, role, roles)
                c_role.run_list.each do |runlist_item|
                  if runlist_item.recipe?
                    Spiceweasel::Log.debug("recipe: #{runlist_item.name}")
                    cookbook, _recipe = runlist_item.name.split("::")
          Severity: Minor
          Found in lib/spiceweasel/roles.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

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

              def parse_and_validate_input(file) # rubocop:disable CyclomaticComplexity
                begin
                  Spiceweasel::Log.debug("file: #{file}")
                  unless File.file?(file)
                    STDERR.puts "ERROR: #{file} is an invalid manifest file, please check your path."
          Severity: Minor
          Found in lib/spiceweasel/cli.rb - About 1 hr to fix

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

                def process_parallel(count, create_command_options, name, options, provider, run_list)
                  parallel = "seq #{count} | parallel -u -j 0 -v -- "
                  if provider.eql?("vsphere")
                    if bundler?
                      parallel += "bundle exec knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, "{}")
            Severity: Minor
            Found in lib/spiceweasel/nodes.rb - About 1 hr to fix

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

                  def node_names_flatten(create_command_options, node, run_list)
                    if File.directory?("nodes/")
                      if File.exist?("nodes/#{node}.json")
                        validate_node_file(node) unless Spiceweasel::Config[:novalidation]
                        servercommand = "knife node from file #{node}.json #{Spiceweasel::Config[:knife_options]}".rstrip
              Severity: Minor
              Found in lib/spiceweasel/nodes.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

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

                  def process_providers(names, count, name, options, run_list, create_command_options, knifecommands) # rubocop:disable CyclomaticComplexity
                    provider = names[0]
                    validate_provider(provider, names, count, options, knifecommands) unless Spiceweasel::Config[:novalidation]
                    provided_names = []
                    if name.nil? && options.split.index("-N") # pull this out for deletes
              Severity: Minor
              Found in lib/spiceweasel/nodes.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

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

                  def unwind_roles(cookbooks, environments, flatroles, rolefiles)
                    flatroles.each do |role|
                      Spiceweasel::Log.debug("role: #{role}")
                      if File.directory?("roles")
                        # expand wildcards and push into flatroles
              Severity: Minor
              Found in lib/spiceweasel/roles.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

              Method process_manifest has 28 lines of code (exceeds 25 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 1 hr to fix

                Method do_bulk_delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def do_bulk_delete(provider)
                      if ["kvm", "vsphere"].member?(provider)
                        if bundler?
                          delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs bundle exec knife #{provider} vm delete -y")
                        else
                Severity: Minor
                Found in lib/spiceweasel/nodes.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

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

                    def initialize(knives = {}, allknifes = [])
                      @create = []
                
                      return unless knives
                
                
                Severity: Minor
                Found in lib/spiceweasel/knife.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

                Method initialize has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def initialize(berkshelf = nil)
                      @create = []
                      @delete = []
                      @cookbook_list = {}
                      # only load berkshelf if we are going to use it
                Severity: Minor
                Found in lib/spiceweasel/berksfile.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language