Showing 93 of 93 total issues
Method scale
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scale
app = input[:app]
if input.has?(:instances)
instances = input[:instances, app.total_instances]
Method wrap_errors
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def wrap_errors
yield
rescue CFoundry::Timeout => e
err(e.message)
rescue Interrupt
Method service_matches
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def service_matches(i, options)
if app = options[:app]
return false unless app.services.include? i
end
Method log_error
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def log_error(e)
ensure_config_dir
msg = e.class.name
msg << ": #{e}" unless e.to_s.empty?
Method create_space
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_space
# TODO: ask org instead
return invoke :help,
:command => "create-space" if input[:organization].nil?
Method delete_service
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_service
if input[:all]
return unless input[:really, "ALL SERVICES", :bad]
client.service_instances.each do |i|
Method delete_org
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def delete_org
org = input[:organization]
return unless input[:really, org]
spaces = org.spaces
Method bind_services
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def bind_services(app)
return unless input[:bind_services]
while true
invoke :bind_service, :app => app
- 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 log_error
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def log_error(e)
ensure_config_dir
msg = e.class.name
msg << ": #{e}" unless e.to_s.empty?
- 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
if frameworks
line unless quiet?
if frameworks.empty? && !quiet?
line "#{d("none")}"
- 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 46.
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
if runtimes
line unless quiet?
if runtimes.empty? && !quiet?
line "#{d("none")}"
- 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 46.
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 show_instance_logs
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show_instance_logs(app, i)
return unless i.id
logs =
with_progress(
- 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 wrap_errors
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def wrap_errors
yield
rescue CFoundry::Timeout => e
err(e.message)
rescue Interrupt
- 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 unmap_domain
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def unmap_domain
domain = input[:domain]
given_org = input.has?(:organization)
given_space = input.has?(:space)
- 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 switch_mode
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def switch_mode(app, mode)
mode = nil if mode == "none"
mode = "run" if mode == "" # no value given
return false if app.debug == mode
- 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 v1_unmap
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def v1_unmap
app = input[:app]
url = input[:url, app.urls] unless input[:all]
with_progress("Updating #{c(app.name, :name)}") do |s|
- 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 display_org_and_space
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def display_org_and_space
return unless v2?
if org = client.current_organization
line "organization: #{c(org.name, :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 display_apps_table
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def display_apps_table(apps)
table(
["name", "status", "usage", v2? && "plan", "runtime", "url"],
apps.collect { |a|
[ c(a.name, :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 org
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def org
org = input[:organization]
unless org
return if quiet?
- 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 crashes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def crashes
apps = input[:apps]
fail "No applications given." if apps.empty?
spaced(apps) do |app|
- 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"