alexpeattie/nitlink

View on GitHub
lib/nitlink/param_decoder.rb

Summary

Maintainability
A
0 mins
Test Coverage

Use casecmp instead of downcase ==.
Open

      raise wrong_charset(charset) unless charset.downcase == 'utf-8'
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

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?

Final newline missing.
Open

end
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

Line is too long. [128/80]
Open

      UnsupportedCharsetError.new("Invalid charset #{charset}, encoded parameter values must use the UTF-8 character encoding") 
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

Use % instead of %Q.
Open

      EncodedParamSyntaxError.new(%Q{Syntax error decoding encoded parameter value "#{ val }", must be in the form: charset "'" [ language ] "'" value-chars})
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

This cop checks if usage of %() or %Q() matches configuration.

Example: EnforcedStyle: bare_percent (default)

# bad
%Q(He said: "#{greeting}")
%q{She said: 'Hi'}

# good
%(He said: "#{greeting}")
%{She said: 'Hi'}

Example: EnforcedStyle: percent_q

# bad
%|He said: "#{greeting}"|
%/She said: 'Hi'/

# good
%Q|He said: "#{greeting}"|
%q/She said: 'Hi'/

Line is too long. [158/80]
Open

      EncodedParamSyntaxError.new(%Q{Syntax error decoding encoded parameter value "#{ val }", must be in the form: charset "'" [ language ] "'" value-chars})
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

Missing top-level class documentation comment.
Open

  class ParamDecoder
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Space inside string interpolation detected.
Open

      EncodedParamSyntaxError.new(%Q{Syntax error decoding encoded parameter value "#{ val }", must be in the form: charset "'" [ language ] "'" value-chars})
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

This cop checks for whitespace within string interpolations.

Example: EnforcedStyle: no_space (default)

# bad
   var = "This is the #{ space } example"

# good
   var = "This is the #{no_space} example"

Example: EnforcedStyle: space

# bad
   var = "This is the #{no_space} example"

# good
   var = "This is the #{ space } example"

Trailing whitespace detected.
Open

      UnsupportedCharsetError.new("Invalid charset #{charset}, encoded parameter values must use the UTF-8 character encoding") 
Severity: Minor
Found in lib/nitlink/param_decoder.rb by rubocop

%Q-literals should be delimited by ( and ).
Open

      EncodedParamSyntaxError.new(%Q{Syntax error decoding encoded parameter value "#{ val }", must be in the form: charset "'" [ language ] "'" value-chars})
Severity: Minor
Found in lib/nitlink/param_decoder.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)

There are no issues that match your filters.

Category
Status