smudge/sojourn

View on GitHub
lib/sojourn/request.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class Request has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Request
    KEYS = %w(uuid referer host path controller action params method ip_address user_agent)

    attr_reader :request

Severity: Minor
Found in lib/sojourn/request.rb - About 2 hrs to fix

    Method has too many lines. [11/10]
    Open

        def referer_data
          return @referer_data if @referer_data
          p = RefererParser::Parser.new.parse(sanitized_referer)
          @referer_data = {
            known: p[:known],
    Severity: Minor
    Found in lib/sojourn/request.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    %w-literals should be delimited by [ and ].
    Open

        KEYS = %w(uuid referer host path controller action params method ip_address user_agent)
    Severity: Minor
    Found in lib/sojourn/request.rb by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Avoid rescuing without specifying an error class.
    Open

        rescue
    Severity: Minor
    Found in lib/sojourn/request.rb by rubocop

    This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

    Example: EnforcedStyle: implicit

    # `implicit` will enforce using `rescue` instead of
    # `rescue StandardError`.
    
    # bad
    begin
      foo
    rescue StandardError
      bar
    end
    
    # good
    begin
      foo
    rescue
      bar
    end
    
    # good
    begin
      foo
    rescue OtherError
      bar
    end
    
    # good
    begin
      foo
    rescue StandardError, SecurityError
      bar
    end

    Example: EnforcedStyle: explicit (default)

    # `explicit` will enforce using `rescue StandardError`
    # instead of `rescue`.
    
    # bad
    begin
      foo
    rescue
      bar
    end
    
    # good
    begin
      foo
    rescue StandardError
      bar
    end
    
    # good
    begin
      foo
    rescue OtherError
      bar
    end
    
    # good
    begin
      foo
    rescue StandardError, SecurityError
      bar
    end

    Freeze mutable objects assigned to constants.
    Open

        KEYS = %w(uuid referer host path controller action params method ip_address user_agent)
    Severity: Minor
    Found in lib/sojourn/request.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    There are no issues that match your filters.

    Category
    Status