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'
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
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
- Read upRead up
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
- Read upRead up
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?("/")
- Read upRead up
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
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
- Read upRead up
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"
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.
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
- Read upRead up
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!
- Read upRead up
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"
- Read upRead up
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
- Read upRead up
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?
- Read upRead up
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)
- Read upRead up
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 = []
- Read upRead up
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}..."
- Read upRead up
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"