ManageIQ/manageiq

View on GitHub
lib/vmdb/util.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
54%

Use =~ in places where the MatchData returned by #match will not be used.
Open

        f.match(/.+-(\d+\.gz)/)
Severity: Minor
Found in lib/vmdb/util.rb by rubocop

This cop identifies the use of Regexp#match or String#match, which returns #<MatchData>/nil. The return value of =~ is an integral index/nil and is more performant.

Example:

# bad
do_something if str.match(/regex/)
while regex.match('str')
  do_something
end

# good
method(str =~ /regex/)
return value unless regex =~ 'str'

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

      rescue Exception => e
        _log.error(e.to_s)
        return []
Severity: Minor
Found in lib/vmdb/util.rb by rubocop

This cop 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

There are no issues that match your filters.

Category
Status