Use casecmp
instead of downcase ==
. Open
raise wrong_charset(charset) unless charset.downcase == 'utf-8'
- Read upRead up
- Exclude checks
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
- Exclude checks
Line is too long. [128/80] Open
UnsupportedCharsetError.new("Invalid charset #{charset}, encoded parameter values must use the UTF-8 character encoding")
- Exclude checks
Use %
instead of %Q
. Open
EncodedParamSyntaxError.new(%Q{Syntax error decoding encoded parameter value "#{ val }", must be in the form: charset "'" [ language ] "'" value-chars})
- Read upRead up
- Exclude checks
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})
- Exclude checks
Missing top-level class documentation comment. Open
class ParamDecoder
- Read upRead up
- Exclude checks
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})
- Read upRead up
- Exclude checks
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")
- Exclude checks
%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})
- Read upRead up
- Exclude checks
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)