ManageIQ/manageiq

View on GitHub
lib/workers/bin/run_single_worker.rb

Summary

Maintainability
A
0 mins
Test Coverage

Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError?
Open

  rescue Exception => err
    MiqWorker::Runner.safe_log(worker, "An unhandled error has occurred: #{err}\n#{err.backtrace.join("\n")}", :error)
    STDERR.puts("ERROR: An unhandled error has occurred: #{err}. See log for details.") rescue nil
    exit 1

Checks for rescue blocks targeting the Exception class.

Example:

# bad

begin
  do_something
rescue Exception
  handle_exception
end

Example:

# good

begin
  do_something
rescue ArgumentError
  handle_exception
end

Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
Open

           elsif options[:system_uid] && worker = worker_class.find_by(:system_uid => options[:system_uid])

Checks for assignments in the conditions of if/while/until.

AllowSafeAssignment option for safe assignment. By safe assignment we mean putting parentheses around an assignment to indicate "I know I'm using an assignment as a condition. It's not a mistake."

Safety:

This cop's autocorrection is unsafe because it assumes that the author meant to use an assignment result as a condition.

Example:

# bad
if some_var = true
  do_something
end

# good
if some_var == true
  do_something
end

Example: AllowSafeAssignment: true (default)

# good
if (some_var = true)
  do_something
end

Example: AllowSafeAssignment: false

# bad
if (some_var = true)
  do_something
end

There are no issues that match your filters.

Category
Status