ManageIQ/linux_admin

View on GitHub

Showing 16 of 58 total issues

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

    def execute_commands(commands, agent_socket, stdin)
      result = nil
      args = {:verify_host_key => false, :number_of_password_prompts => 0}
      if agent_socket
        args.merge!(:forward_agent              => true,
Severity: Minor
Found in lib/linux_admin/ssh.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 ssh_exec! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def ssh_exec!(ssh, command, stdin)
      stdout_data = ''
      stderr_data = ''
      exit_status = nil
      exit_signal = nil
Severity: Minor
Found in lib/linux_admin/ssh.rb - About 1 hr to fix

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

        def ssh_exec!(ssh, command, stdin)
          stdout_data = ''
          stderr_data = ''
          exit_status = nil
          exit_signal = nil
    Severity: Minor
    Found in lib/linux_admin/ssh.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_repo_list_output has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.parse_repo_list_output(content)
          collect_content = false
          index_start = "repo id"
          index_end   = "repolist:"
    
    
    Severity: Minor
    Found in lib/linux_admin/yum.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 info has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.info(pkg)
          params = { "-qi" => pkg}
          in_description = false
          out = Common.run!(rpm_cmd, :params => params).output
          # older versions of rpm may have multiple fields per line,
    Severity: Minor
    Found in lib/linux_admin/rpm.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

    Method save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def save
          old_contents = @interface_file.file? ? File.read(@interface_file) : ""
    
          stop_success = stop
          # Stop twice because when configure both ipv4 and ipv6 as dhcp, ipv6 dhcp client will
    Severity: Minor
    Found in lib/linux_admin/network_interface/network_interface_rh.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

    Method add_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_name(address, hostname, fqdn, comment, remove_existing = true)
          # Delete entries for this hostname first
          @parsed_file.each { |i| i[:hosts].to_a.delete(hostname) } if remove_existing
    
          # Add entry
    Severity: Minor
    Found in lib/linux_admin/hosts.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

    Method parse_content has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_content(content)
          # Break into content groupings by "\n\n" then process each grouping
          content.split("\n\n").each_with_object([]) do |group, group_array|
            group = group.split("\n").each_with_object({}) do |line, hash|
              next if line.blank?
    Severity: Minor
    Found in lib/linux_admin/registration_system/subscription_manager.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

    Method create_partition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_partition(partition_type, *args)
          create_partition_table unless has_partition_table?
    
          start = finish = size = nil
          case args.length
    Severity: Minor
    Found in lib/linux_admin/disk.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

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

        def apply_static(ip, mask, gw, dns, search = nil)
    Severity: Minor
    Found in lib/linux_admin/network_interface/network_interface_rh.rb - About 35 mins to fix

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

          def add_name(address, hostname, fqdn, comment, remove_existing = true)
      Severity: Minor
      Found in lib/linux_admin/hosts.rb - About 35 mins to fix

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

            def apply_static6(ip, prefix, gw, dns, search = nil)
        Severity: Minor
        Found in lib/linux_admin/network_interface/network_interface_rh.rb - About 35 mins to fix

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

              def self.from_string(apt_cache_string)
                in_description = false
                apt_cache_string.split("\n").each.with_object({}) do |line,deb|
                  tag,value = self.from_line(line)
                  if tag == 'description-en'
          Severity: Minor
          Found in lib/linux_admin/deb.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 lockdown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def lockdown(*args)
                raise "OpenSCAP not available" unless self.class.openscap_available?
                raise "SCAP Security Guide not available" unless self.class.ssg_available?(platform)
          
                values = args.last.kind_of?(Hash) ? args.pop : {}
          Severity: Minor
          Found in lib/linux_admin/scap.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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def register(options)
                raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
          
                install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]
          
          
          Severity: Minor
          Found in lib/linux_admin/registration_system/subscription_manager.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 download_packages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.download_packages(path, packages, options = {})
                raise ArgumentError, "path is required"       unless path
                raise ArgumentError, "packages are required"  unless packages
                options = {:mirror_type => :package}.merge(options)
          
          
          Severity: Minor
          Found in lib/linux_admin/yum.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