lib/fog/azurerm/models/network/express_route_circuit_peering.rb
Method parse
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def self.parse(circuit_peering)
express_route_circuit_peering = {}
express_route_circuit_peering['id'] = circuit_peering.id
express_route_circuit_peering['name'] = circuit_peering.name
express_route_circuit_peering['resource_group'] = get_resource_group_from_id(circuit_peering.id)
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
Open
public_prefixes.each do |public_prefix|
express_route_circuit_peering['advertised_public_prefixes'] << public_prefix
end unless public_prefixes.nil?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Use peering_type.casecmp(MICROSOFT_PEERING).zero?
instead of peering_type.casecmp(MICROSOFT_PEERING) == 0
. Open
Open
requires :advertised_public_prefixes if peering_type.casecmp(MICROSOFT_PEERING) == 0
- Read upRead up
- Exclude checks
This cop checks for usage of comparison operators (==
,
>
, <
) to test numbers as zero, positive, or negative.
These can be replaced by their respective predicate methods.
The cop can also be configured to do the reverse.
The cop disregards #nonzero?
as it its value is truthy or falsey,
but not true
and false
, and thus not always interchangeable with
!= 0
.
The cop ignores comparisons to global variables, since they are often
populated with objects which can be compared with integers, but are
not themselves Interger
polymorphic.
Example: EnforcedStyle: predicate (default)
# bad
foo == 0
0 > foo
bar.baz > 0
# good
foo.zero?
foo.negative?
bar.baz.positive?
Example: EnforcedStyle: comparison
# bad
foo.zero?
foo.negative?
bar.baz.positive?
# good
foo == 0
0 > foo
bar.baz > 0