app/representers/proxy_rule_representer.rb
ProxyRuleRepresenter::JSON tests 'backend_api_owner?' at least 4 times Open
Open
if backend_api_owner?
admin_api_backend_api_mapping_rule_path(owner_id, id)
else
admin_api_service_proxy_mapping_rule_path(service_id, id)
end
- Read upRead up
- Exclude checks
Repeated Conditional
is a special case of Simulated Polymorphism
. Basically it means you are checking the same value throughout a single class and take decisions based on this.
Example
Given
class RepeatedConditionals
attr_accessor :switch
def repeat_1
puts "Repeat 1!" if switch
end
def repeat_2
puts "Repeat 2!" if switch
end
def repeat_3
puts "Repeat 3!" if switch
end
end
Reek would emit the following warning:
test.rb -- 4 warnings:
[5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)
If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.