crowbar/crowbar-hyperv

View on GitHub

Showing 17 of 45 total issues

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

    def load_user_hive(hive,reg_path,user_hive)
      Chef::Log.debug("Reg Path #{reg_path}")
      # See if the hive is loaded. Logged in users will have a key that is named their SID
      # if the user has specified the a path by SID and the user is logged in, this function
      # should not be executed.
Severity: Minor
Found in chef/cookbooks/windows/libraries/registry_helper.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

File registry_helper.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

if RUBY_PLATFORM =~ /mswin|mingw32|windows/
  require "win32/registry"
  require "ruby-wmi"
end

Severity: Minor
Found in chef/cookbooks/windows/libraries/registry_helper.rb - About 2 hrs to fix

Method extract_installed_packages_from_key has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def extract_installed_packages_from_key(hkey = ::Win32::Registry::HKEY_LOCAL_MACHINE, desired = ::Win32::Registry::Constants::KEY_READ)
  uninstall_subkey = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'
  packages = {}
  begin
    ::Win32::Registry.open(hkey, uninstall_subkey, desired) do |reg|
Severity: Minor
Found in chef/cookbooks/windows/providers/package.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 installer_type has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def installer_type
  @installer_type || begin
    if @new_resource.installer_type
      @new_resource.installer_type
    else
Severity: Minor
Found in chef/cookbooks/windows/providers/package.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 set_value has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def set_value(mode,path,values,type=nil)
      hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
      key_name = reg_path.join("\\")

      Chef::Log.debug("Creating #{path}")
Severity: Minor
Found in chef/cookbooks/windows/libraries/registry_helper.rb - About 1 hr to fix

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

    def set_value(mode,path,values,type=nil)
      hive, reg_path, hive_name, root_key, hive_loaded = get_reg_path_info(path)
      key_name = reg_path.join("\\")

      Chef::Log.debug("Creating #{path}")
Severity: Minor
Found in chef/cookbooks/windows/libraries/registry_helper.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 load_user_hive has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def load_user_hive(hive,reg_path,user_hive)
      Chef::Log.debug("Reg Path #{reg_path}")
      # See if the hive is loaded. Logged in users will have a key that is named their SID
      # if the user has specified the a path by SID and the user is logged in, this function
      # should not be executed.
Severity: Minor
Found in chef/cookbooks/windows/libraries/registry_helper.rb - About 1 hr to fix

Method installer_type has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def installer_type
  @installer_type || begin
    if @new_resource.installer_type
      @new_resource.installer_type
    else
Severity: Minor
Found in chef/cookbooks/windows/providers/package.rb - About 1 hr to fix

Method action_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def action_create
  if compare_shortcut
    @link.TargetPath = @new_resource.target if @new_resource.target != nil
    @link.Arguments = @new_resource.arguments if @new_resource.arguments != nil
    @link.Description = @new_resource.description if @new_resource.description != nil
Severity: Minor
Found in chef/cookbooks/windows/providers/shortcut.rb - About 55 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 deeply nested control flow statements.
Open

              if priv.reg_load_key(sid,ntuser_dat)
                Chef::Log.debug("RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})")
                reg_path[0] = sid
              else
                Chef::Log.debug("Failed RegLoadKey(#{sid}, #{user_hive}, #{ntuser_dat})")
Severity: Major
Found in chef/cookbooks/windows/libraries/registry_helper.rb - About 45 mins to fix

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

      def run_command(script, options)
        if options && options[:architecture]
          architecture = options[:architecture]
          options.delete(:architecture)
        else
Severity: Minor
Found in chef/cookbooks/powershell/libraries/powershell_out.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 report has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def report
    log_message, reboot = begin
      if reboot_requested?
        ["chef_handler[#{self.class}] requested reboot will occur in #{timeout} seconds", true]
      elsif reboot_pending?
Severity: Minor
Found in chef/cookbooks/windows/files/default/handlers/windows_reboot_handler.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 disable_wow64_file_redirection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def disable_wow64_file_redirection(node)
          original_redirection_state = ["0"].pack("P")

          if ((node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
            win32_wow_64_disable_wow_64_fs_redirection =
Severity: Minor
Found in chef/cookbooks/powershell/libraries/windows_architecture_helper.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 restore_wow64_file_redirection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def restore_wow64_file_redirection(node, original_redirection_state)
          if ( (node_windows_architecture(node) == :x86_64) && ::Chef::Platform.windows?)
            win32_wow_64_revert_wow_64_fs_redirection =
              ::Win32::API.new("Wow64RevertWow64FsRedirection", "P", "L", "kernel32")

Severity: Minor
Found in chef/cookbooks/powershell/libraries/windows_architecture_helper.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 install_feature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def install_feature(name)
  addsource = @new_resource.source ? "/LimitAccess /Source:\"#{@new_resource.source}\"" : ""
  addall = @new_resource.all ? "/All" : ""
  restart = @new_resource.restart ? "/quiet" : "/norestart"
  shell_out!("#{dism} /online /enable-feature /featurename:#{@new_resource.feature_name} #{restart} #{addsource} #{addall}", {returns: [0,42,127,3010]})
Severity: Minor
Found in chef/cookbooks/windows/providers/feature_dism.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 load_task_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def load_task_hash(task_name)
  Chef::Log.debug "looking for existing tasks"
  output = `schtasks /Query /FO LIST /V /TN \"#{task_name}\" 2> NUL`
  if output.empty?
    task = false
Severity: Minor
Found in chef/cookbooks/windows/providers/task.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 load_current_resource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def load_current_resource
  @current_resource = Chef::Resource::WindowsTask.new(@new_resource.name)
  @current_resource.name(@new_resource.name)

  task_hash = load_task_hash(@current_resource.name)
Severity: Minor
Found in chef/cookbooks/windows/providers/task.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