intercity/intercity-next

View on GitHub
app/jobs/remove_app_job.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(server, app_name)
    SshExecution.new(server).execute_with_block do |ssh|
      ssh.open_channel do |channel|
        channel.exec "dokku apps:destroy #{app_name}" do |channel2, success|
          abort "could not destroy app" unless success
Severity: Minor
Found in app/jobs/remove_app_job.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

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

            if data =~ /To proceed, type "#{app_name}"/
Severity: Minor
Found in app/jobs/remove_app_job.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

There are no issues that match your filters.

Category
Status