SUSE/pennyworth

View on GitHub

Showing 17 of 23 total issues

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

module Pennyworth
  class Cli
    extend GLI::App

    program_desc 'A tool for controlling networks of machines for integration testing'
Severity: Minor
Found in lib/pennyworth/cli.rb - About 3 hrs to fix

    Method import has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.import(ip, username, password, identity_file = nil)
          tmp_file = Tempfile.new("pennyworth-ssh-key-importer")
    
          cmd = "ssh-copy-id"
          if identity_file
    Severity: Major
    Found in lib/pennyworth/ssh_keys_importer.rb - About 2 hrs to fix

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

          def parse_ssh_config_output(output)
            # See http://linux.die.net/man/5/ssh_config for description of the format.
      
            config = {}
            host = nil
      Severity: Minor
      Found in lib/pennyworth/vagrant.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 execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute(image_name, options = {})
            @vagrant = VagrantCommand.new
            options = {
              subdir: "",
              local: false
      Severity: Minor
      Found in lib/pennyworth/commands/import_base_command.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 inject_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def inject_file(source, destination, opts = {})
            # Append filename (taken from +source+) to destination if it is a path, so
            # that +destination+ is always the full target path including the filename.
            destination += File.basename(source) if destination.end_with?("/")
      
      
      Severity: Minor
      Found in lib/pennyworth/remote_command_runner.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 execute has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def execute(image_name, options = {})
            @vagrant = VagrantCommand.new
            options = {
              subdir: "",
              local: false
      Severity: Minor
      Found in lib/pennyworth/commands/import_base_command.rb - About 1 hr to fix

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

            def inject_directory(source, destination, opts = {})
              if opts[:owner] || opts[:group]
                owner_group = opts[:owner] || ""
                owner_group += ":#{opts[:group]}" if opts[:group]
              end
        Severity: Minor
        Found in lib/pennyworth/remote_command_runner.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 start_system has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def start_system(opts)
              opts = {
                skip_ssh_setup: false
              }.merge(opts)
              username = opts[:username] || "root"
        Severity: Minor
        Found in lib/pennyworth/spec.rb - About 1 hr to fix

          Method adapt_config_file has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def adapt_config_file(file, adaptations)
                # Create a backup.
                Cheetah.run "sudo", "cp", file, "#{file}.pennyworth_save"
          
                # Create a temporary copy with permissions that allow us to modify it.
          Severity: Minor
          Found in lib/pennyworth/commands/setup_command.rb - About 1 hr to fix

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

                def parse(yaml_string)
                  yaml = YAML.load(yaml_string)
                  if !yaml
                    raise HostFileError.new("Could not parse YAML in file '#{config_file}'")
                  end
            Severity: Minor
            Found in lib/pennyworth/host_config.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_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.parse_status output
                  result = []
                  parsing_vms = false
                  output.each_line do |line|
                    line.strip!
            Severity: Minor
            Found in lib/pennyworth/vagrant_command.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 start_system has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def start_system(opts)
                  opts = {
                    skip_ssh_setup: false
                  }.merge(opts)
                  username = opts[:username] || "root"
            Severity: Minor
            Found in lib/pennyworth/spec.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 import has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.import(ip, username, password, identity_file = nil)
                  tmp_file = Tempfile.new("pennyworth-ssh-key-importer")
            
                  cmd = "ssh-copy-id"
                  if identity_file
            Severity: Minor
            Found in lib/pennyworth/ssh_keys_importer.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 ensure_libvirt_env_started has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def ensure_libvirt_env_started
                    # The check here is unnecessary for technical reasons ("sysctl start" does
                    # not fail if the service is already running), but it avoids an unnecessary
                    # sudo password prompt.
                    libvirtd_start unless libvirtd_active?
            Severity: Minor
            Found in lib/pennyworth/libvirt.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 base_image_export has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def base_image_export(name, tmp_dir)
                  Dir.chdir(tmp_dir) do
                    image = Dir.glob("*.box").first
                    if image
                      from_file = File.join(tmp_dir, image)
            Severity: Minor
            Found in lib/pennyworth/commands/build_base_command.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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def list
                  host_config.hosts.each do |host_name|
                    host = host_config.host(host_name)
                    out = "#{host_name}"
                    attributes = []
            Severity: Minor
            Found in lib/pennyworth/cli_host_controller.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 up has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def up(vm_name, destroy)
                  Pennyworth::Libvirt.ensure_libvirt_env_started
            
                  if vm_name
                    log "Starting VM #{vm_name}..."
            Severity: Minor
            Found in lib/pennyworth/vagrant_command.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