Showing 31 of 31 total issues
Method finalize!
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def finalize!
# Try to get username and api key from environment variables.
# They will default to nil if the environment variables are not present.
@api_key = ENV["SL_API_KEY"] if @api_key == UNSET_VALUE
@username = ENV["SL_USERNAME"] if @username == UNSET_VALUE
- 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 action_up
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def self.action_up
Vagrant::Action::Builder.new.tap do |b|
if defined?(HandleBox)
b.use HandleBox
else
- 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 call
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
@app.call(env)
ssh_info = env[:machine].ssh_info
- 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 action_rebuild
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.action_rebuild
Vagrant::Action::Builder.new.tap do |b|
b.use Call, Confirm, I18n.t("vagrant_softlayer.vm.rebuild_confirmation"), :force_rebuild do |env, b2|
if env[:result]
b2.use ConfigValidate
- 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 validate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def validate(machine)
errors = []
errors << I18n.t("vagrant_softlayer.config.api_key_required") if !@api_key
errors << I18n.t("vagrant_softlayer.config.username_required") if !@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 call
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(env)
@app.call(env)
ssh_info = env[:machine].ssh_info
Method sl_warden
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def sl_warden(rescue_proc = nil, retry_interval = 0, &block)
begin
yield
rescue ::OpenSSL::SSL::SSLError
raise Errors::SLCertificateError
- 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
ready = virtual_server.wait_until_ready((env[:machine].provider_config.provision_timeout.to_f/10).ceil, env[:machine].provider_config.transaction_wait, 10) do |server_ready|
unless server_ready
provision_status = env[:sl_machine].getActiveTransaction
provision_status = " Provision status: #{provision_status["transactionStatus"]["friendlyName"]} (#{provision_status["transactionStatus"]["name"]})." if provision_status && ! provision_status.empty?
@logger.info("#{env[:machine].provider_config.hostname} is still provisioning. Retrying in 10 seconds.#{provision_status}")
- 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 62.
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
ready = virtual_server.wait_until_ready((env[:machine].provider_config.rebuild_timeout.to_f/10).ceil, env[:machine].provider_config.transaction_wait, 10) do |server_ready|
unless server_ready
rebuild_status = env[:sl_machine].getActiveTransaction
rebuild_status = " Rebuild status: #{rebuild_status["transactionStatus"]["friendlyName"]} (#{rebuild_status["transactionStatus"]["name"]})." if rebuild_status && ! rebuild_status.empty?
@logger.info("#{env[:machine].provider_config.hostname} is still rebuilding. Retrying in 10 seconds.#{rebuild_status}")
- 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 62.
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 action_up
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.action_up
Vagrant::Action::Builder.new.tap do |b|
if defined?(HandleBox)
b.use HandleBox
else
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@api_key = UNSET_VALUE
@api_timeout = UNSET_VALUE
@endpoint_url = UNSET_VALUE
@username = UNSET_VALUE
Method get_vlan_id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_vlan_id(vlan_name, vlan_space)
return vlan_name unless vlan_name.kind_of?(String)
routers = @env[:sl_client]["SoftLayer_Account"].object_mask("mask[routers,routers.datacenter,routers.networkVlans,routers.networkVlans.networkSpace,routers.networkVlans.type]").getObject["routers"]
- 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 action_destroy
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.action_destroy
Vagrant::Action::Builder.new.tap do |b|
b.use Call, DestroyConfirm do |env, b2|
if env[:result]
b2.use ConfigValidate
- 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 finalize!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def finalize!
# Try to get username and api key from environment variables.
# They will default to nil if the environment variables are not present.
@api_key = ENV["SL_API_KEY"] if @api_key == UNSET_VALUE
@username = ENV["SL_USERNAME"] if @username == UNSET_VALUE
Method call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
env[:ui].info I18n.t("vagrant_softlayer.vm.wait_for_provision")
env[:sl_machine] = env[:sl_client]["SoftLayer_Virtual_Guest"].object_with_id(env[:machine].id.to_i)
- 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 call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def call(env)
env[:ui].info I18n.t("vagrant_softlayer.vm.wait_for_rebuild")
#Rechecks every 10 sec
virtual_server = ::SoftLayer::VirtualServer.server_with_id(env[:machine].id.to_i, :client => env[:sl_client])
- 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 ssh_keys
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def ssh_keys(env, ids_only = false)
account = env[:sl_client]["SoftLayer_Account"]
acc_keys = sl_warden { account.object_mask("mask[id,label]").getSshKeys }
key_ids = []
Array(env[:machine].provider_config.ssh_key).each do |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 action_provision
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use Call, Is, :running do |env, b2|
if !env[:result]
- 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 update_dns
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_dns
unless @env[:machine].provider_config.manage_dns
@logger.debug("Not managing DNS. Going ahead.")
return
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def self.action_halt
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use Call, Is, :running do |env, b2|
if !env[:result]
- 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 40.
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