bogdanRada/washout_builder

View on GitHub
lib/washout_builder/document/generator.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class Generator has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Generator
      # class that is used to generate HTML documentation for a soap service
      #
      # @!attribute soap_actions
      #   @return [Hash] Hash that contains all the actions to which the web service responds to and information about them
Severity: Minor
Found in lib/washout_builder/document/generator.rb - About 2 hrs to fix

    Use each_value instead of each.
    Open

              soap_actions.each do |_operation, formats|

    This cop checks for uses of each_key and each_value Hash methods.

    Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.

    Example:

    # bad
    hash.keys.each { |k| p k }
    hash.values.each { |v| p v }
    hash.each { |k, _v| p k }
    hash.each { |_k, v| p v }
    
    # good
    hash.each_key { |k| p k }
    hash.each_value { |v| p v }

    Use casecmp instead of downcase ==.
    Open

            hash_object = soap_actions.find { |operation, _formats| operation.to_s.downcase == operation_name.to_s.downcase }

    This cop identifies places where a case-insensitive string comparison can better be implemented using casecmp.

    Example:

    # bad
    str.downcase == 'abc'
    str.upcase.eql? 'ABC'
    'abc' == str.downcase
    'ABC'.eql? str.upcase
    str.downcase == str.downcase
    
    # good
    str.casecmp('ABC').zero?
    'abc'.casecmp(str).zero?

    Omit parentheses for ternary conditions.
    Open

            format_type = (type == 'input') ? 'builder_in' : 'builder_out'

    This cop checks for the presence of parentheses around ternary conditions. It is configurable to enforce inclusion or omission of parentheses using EnforcedStyle. Omission is only enforced when removing the parentheses won't cause a different behavior.

    Example: EnforcedStyle: requirenoparentheses (default)

    # bad
    foo = (bar?) ? a : b
    foo = (bar.baz?) ? a : b
    foo = (bar && baz) ? a : b
    
    # good
    foo = bar? ? a : b
    foo = bar.baz? ? a : b
    foo = bar && baz ? a : b

    Example: EnforcedStyle: require_parentheses

    # bad
    foo = bar? ? a : b
    foo = bar.baz? ? a : b
    foo = bar && baz ? a : b
    
    # good
    foo = (bar?) ? a : b
    foo = (bar.baz?) ? a : b
    foo = (bar && baz) ? a : b

    Example: EnforcedStyle: requireparentheseswhen_complex

    # bad
    foo = (bar?) ? a : b
    foo = (bar.baz?) ? a : b
    foo = bar && baz ? a : b
    
    # good
    foo = bar? ? a : b
    foo = bar.baz? ? a : b
    foo = (bar && baz) ? a : b

    Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Open

            controller_route_helpers.url_for(controller: controller_name, action: "_generate_wsdl", only_path: true)

    Checks if uses of quotes match the configured preference.

    Example: EnforcedStyle: single_quotes (default)

    # bad
    "No special symbols"
    "No string interpolation"
    "Just text"
    
    # good
    'No special symbols'
    'No string interpolation'
    'Just text'
    "Wait! What's #{this}!"

    Example: EnforcedStyle: double_quotes

    # bad
    'Just some text'
    'No special chars or interpolation'
    
    # good
    "Just some text"
    "No special chars or interpolation"
    "Every string in #{project} uses double_quotes"

    There are no issues that match your filters.

    Category
    Status