fog/fog-azure-rm

View on GitHub
lib/fog/azurerm/models/network/express_route_circuit_peering.rb

Summary

Maintainability
A
1 hr
Test Coverage
F
50%

Method parse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
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)
Severity: Minor
Found in lib/fog/azurerm/models/network/express_route_circuit_peering.rb - About 1 hr to fix

    Favor a normal unless-statement over a modifier clause in a multiline statement.
    Open

                public_prefixes.each do |public_prefix|
                  express_route_circuit_peering['advertised_public_prefixes'] << public_prefix
                end unless public_prefixes.nil?

    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

              requires :advertised_public_prefixes if peering_type.casecmp(MICROSOFT_PEERING) == 0

    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

    There are no issues that match your filters.

    Category
    Status