ManageIQ/manageiq

View on GitHub
app/models/miq_task.rb

Summary

Maintainability
A
25 mins
Test Coverage
A
92%

Method task_results has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def task_results
    # support legacy task that saved results in the results column
    return Marshal.load(Base64.decode64(results.split("\n").join)) unless results.nil?
    return miq_report_result.report_results unless miq_report_result.nil?
    unless binary_blob.nil?
Severity: Minor
Found in app/models/miq_task.rb - About 25 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

Avoid using Marshal.load.
Open

    return Marshal.load(Base64.decode64(results.split("\n").join)) unless results.nil?
Severity: Minor
Found in app/models/miq_task.rb by rubocop

This cop checks for the use of Marshal class methods which have potential security issues leading to remote code execution when loading from an untrusted source.

Example:

# bad
Marshal.load("{}")
Marshal.restore("{}")

# good
Marshal.dump("{}")

# okish - deep copy hack
Marshal.load(Marshal.dump({}))

There are no issues that match your filters.

Category
Status