ManageIQ/manageiq

View on GitHub
tools/rest_api.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use find instead of select.first.
Open

gem_dir = Pathname.new(Bundler.locked_gems.specs.select { |g| g.name == "manageiq-api" }.first.gem_dir)
Severity: Minor
Found in tools/rest_api.rb by rubocop

This cop is used to identify usages of select.first, select.last, find_all.first, and find_all.last and change them to use detect instead.

Example:

# bad
[].select { |item| true }.first
[].select { |item| true }.last
[].find_all { |item| true }.first
[].find_all { |item| true }.last

# good
[].detect { |item| true }
[].reverse.detect { |item| true }

ActiveRecord compatibility: ActiveRecord does not implement a detect method and find has its own meaning. Correcting ActiveRecord methods with this cop should be considered unsafe.

There are no issues that match your filters.

Category
Status