Showing 37 of 37 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Cyoi::Cli::KeyPair::KeyPairCliOpenstack
attr_reader :provider_client
attr_reader :attributes
attr_reader :hl
- Read upRead up
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 105.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Cyoi::Cli::KeyPair::KeyPairCliAws
attr_reader :provider_client
attr_reader :attributes
attr_reader :hl
- Read upRead up
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 105.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Class AwsProviderClient
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class Cyoi::Providers::Clients::AwsProviderClient < Cyoi::Providers::Clients::FogProviderClient
include Cyoi::Providers::Constants::AwsConstants
# Creates a bucket and makes it publicly read-only
def create_blobstore(blobstore_name)
Method create_security_group
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def create_security_group(security_group_name, description, defns, extra_attributes={})
security_groups = fog_compute.security_groups
sg = security_groups.find do |s|
if extra_attributes[:vpc_id]
s.name == security_group_name && s.vpc_id == extra_attributes[:vpc_id]
- 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 setup_vcenter
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def setup_vcenter
puts "\n"
attributes.set_default("datacenter", {})
datacenter = attributes.datacenter
datacenter["name"] = hl.ask("Datacenter: ").to_s unless datacenter.exists?("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"
Further reading
Method create_security_group
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_security_group(security_group_name, description, defns, extra_attributes={})
security_groups = fog_compute.security_groups
sg = security_groups.find do |s|
if extra_attributes[:vpc_id]
s.name == security_group_name && s.vpc_id == extra_attributes[:vpc_id]
Method bootstrap
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def bootstrap(new_attributes = {})
new_attributes[:image_id] ||= trusty_image_id(fog_compute.region)
vpc = new_attributes[:subnet_id]
server = fog_compute.servers.new(new_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 setup_credentials
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def setup_credentials
attributes.set_default("credentials", {})
credentials = attributes.credentials
credentials["openstack_username"] = hl.ask("Username: ").to_s unless credentials.exists?("openstack_username")
credentials["openstack_api_key"] = (hl.ask("Password (API Key): ") { |q| q.echo = 'x' }).to_s unless credentials.exists?("openstack_api_key")
- 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 auto_detection_choices
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def auto_detection_choices
fog_choices = {}
# Prepare menu options:
# each provider/profile name gets a menu choice option
fog_config.inject({}) do |iaas_options, fog_profile|
Method extract_port_definition
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def extract_port_definition(port_defn)
protocol = "tcp"
ip_range = "0.0.0.0/0"
if port_defn.is_a? Integer
port_range = (port_defn..port_defn)
- 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 bootstrap
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bootstrap(new_attributes = {})
new_attributes[:image_id] ||= trusty_image_id(fog_compute.region)
vpc = new_attributes[:subnet_id]
server = fog_compute.servers.new(new_attributes)
Method perform_and_return_attributes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def perform_and_return_attributes
unless valid_address?
if networks?
if vpc = select_vpc
subnet = select_subnet_for_vpc(vpc)
- 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 trusty_image_id
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def trusty_image_id(region=nil)
region = fog_compute.region
# http://cloud-images.ubuntu.com/locator/ec2/
# version: 14.04 LTS
# arch: amd64
Method execute!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def execute!
unless valid_infrastructure?
settings["provider"] ||= {}
auto_detection unless settings.exists?("provider.name")
choose_provider unless settings.exists?("provider.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"
Further reading
Method auto_detection_choices
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def auto_detection_choices
fog_choices = {}
# Prepare menu options:
# each provider/profile name gets a menu choice option
fog_config.inject({}) do |iaas_options, fog_profile|
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def blobstore_cli
@blobstore_cli ||= begin
provider_name = settings.exists?("provider.name")
return nil unless provider_name
require "cyoi/cli/provider_blobstore/blobstore_cli_#{settings.provider.name}"
- Read upRead up
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 43.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def key_pair_cli
@key_pair_cli ||= begin
provider_name = settings.exists?("provider.name")
return nil unless provider_name
require "cyoi/cli/provider_key_pair/key_pair_#{settings.provider.name}"
- Read upRead up
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 43.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method setup_credentials
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def setup_credentials
puts "\n"
attributes.set_default("credentials", {})
credentials = attributes.credentials
credentials["vsphere_username"] = hl.ask("Username: ").to_s unless credentials.exists?("vsphere_username")
- 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 setup_resources
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def setup_resources
puts "\n"
attributes.set_default("resources", {})
resources = attributes.resources
resources["persistent_disk"] = hl.ask("Size of Persistent Volume (MB): ", Integer) unless resources.exists?("persistent_disk")
- 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 setup_networking
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def setup_networking
puts "\n"
attributes.set_default("network", {})
network = attributes.network
network["netmask"] = hl.ask("Netmask: ").to_s unless network.exists?("netmask")
- 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"