SUSE/pennyworth

View on GitHub

Showing 23 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

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

      RSpec::Matchers.define :have_stdout do |expected|
        match do |result|
          if expected.is_a?(Regexp)
            expected.match(result.stdout)
          else
      Severity: Major
      Found in lib/pennyworth/matchers.rb and 1 other location - About 1 hr to fix
      lib/pennyworth/matchers.rb on lines 43..63

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

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

      RSpec::Matchers.define :have_stderr do |expected|
        match do |result|
          if expected.is_a?(Regexp)
            expected.match(result.stderr)
          else
      Severity: Major
      Found in lib/pennyworth/matchers.rb and 1 other location - About 1 hr to fix
      lib/pennyworth/matchers.rb on lines 81..101

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

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

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

            RSpec::Matchers.define :include_stdout do |expected|
              match do |result|
                result.stdout.include? expected
              end
            
            
            Severity: Minor
            Found in lib/pennyworth/matchers.rb and 1 other location - About 35 mins to fix
            lib/pennyworth/matchers.rb on lines 67..76

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

            RSpec::Matchers.define :include_stderr do |expected|
              match do |result|
                result.stderr.include? expected
              end
            
            
            Severity: Minor
            Found in lib/pennyworth/matchers.rb and 1 other location - About 35 mins to fix
            lib/pennyworth/matchers.rb on lines 105..114

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

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

                def vagrant_libvirt_installed?
                  begin
                    vagrant_libvirt = Cheetah.run "vagrant", "plugin", "list", stdout: :capture
                  rescue
                    return false
            Severity: Minor
            Found in lib/pennyworth/commands/setup_command.rb and 1 other location - About 25 mins to fix
            lib/pennyworth/commands/setup_command.rb on lines 65..74

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

            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

            Severity
            Category
            Status
            Source
            Language