ManageIQ/azure-armrest

View on GitHub
lib/azure/armrest/template_deployment_service.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
82%

Use filter_map instead.
Open

        resource_ids = operations.collect do |op|
          if op.properties.provisioning_operation =~ /^create$/i
            op.properties.target_resource.id
          end
        end.compact

Use filter_map instead.
Open

        remaining_ids = ids.collect { |id| delete_resource(id) }.compact

Use match? instead of =~ when MatchData is not used.
Open

          if op.properties.provisioning_operation =~ /^create$/i

In Ruby 2.4, String#match?, Regexp#match? and Symbol#match? have been added. The methods are faster than match. Because the methods avoid creating a MatchData object or saving backref. So, when MatchData is not used, use match? instead of match.

Example:

# bad
def foo
  if x =~ /re/
    do_something
  end
end

# bad
def foo
  if x.match(/re/)
    do_something
  end
end

# bad
def foo
  if /re/ === x
    do_something
  end
end

# good
def foo
  if x.match?(/re/)
    do_something
  end
end

# good
def foo
  if x =~ /re/
    do_something(Regexp.last_match)
  end
end

# good
def foo
  if x.match(/re/)
    do_something($~)
  end
end

# good
def foo
  if /re/ === x
    do_something($~)
  end
end

There are no issues that match your filters.

Category
Status