ManageIQ/manageiq-ui-classic

View on GitHub
app/controllers/vm_remote.rb

Summary

Maintainability
A
1 hr
Test Coverage
F
31%

Method console_after_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def console_after_task(console_type)
    miq_task = MiqTask.find(params[:task_id])
    unless miq_task.results_ready?
      add_flash(_("Console access failed: %{message}") % {:message => miq_task.message}, :error)
    end
Severity: Minor
Found in app/controllers/vm_remote.rb - About 35 mins 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

Method console_before_task has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def console_before_task(console_type)
    ticket_type = console_type.to_sym

    record = identify_record(params[:id], VmOrTemplate)
    ems = record.ext_management_system
Severity: Minor
Found in app/controllers/vm_remote.rb - About 35 mins 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

Within %w/%W, quotes and ',' are unnecessary and may be unwanted in the resulting strings.
Open

    override_content_security_policy_directives(:connect_src => ["'self'", websocket_origin], :img_src => %w[data: blob: 'self'])
Severity: Minor
Found in app/controllers/vm_remote.rb by rubocop

Checks for quotes and commas in %w, e.g. %w('foo', "bar")

It is more likely that the additional characters are unintended (for example, mistranslating an array of literals to percent string notation) rather than meant to be part of the resulting strings.

Safety:

The cop is unsafe because the correction changes the values in the array and that might have been done purposely.

%w('foo', "bar") #=> ["'foo',", '"bar"']
%w(foo bar)      #=> ['foo', 'bar']

Example:

# bad

%w('foo', "bar")

Example:

# good

%w(foo bar)

There are no issues that match your filters.

Category
Status