Method has too many lines. [15/10] Open
def custom_caps(text)
# $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
text.gsub(%r{
(<[^/][^>]*?>)| # Ignore any opening tag, so we don't mess up attribute values
(\s| |^|'|"|>|) # Make sure our capture is preceded by whitespace or quotes
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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.
Jekyll::TypogrifyFilter has no descriptive comment Open
module TypogrifyFilter
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.
Example
Given
class Dummy
# Do things...
end
Reek would emit the following warning:
test.rb -- 1 warning:
[1]:Dummy has no descriptive comment (IrresponsibleModule)
Fixing this is simple - just an explaining comment:
# The Dummy class is responsible for ...
class Dummy
# Do things...
end
Jekyll::TypogrifyFilter#amp doesn't depend on instance state (maybe move it to another class?) Open
def amp(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#initial_quotes doesn't depend on instance state (maybe move it to another class?) Open
def initial_quotes(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#titlecase doesn't depend on instance state (maybe move it to another class?) Open
def titlecase(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#entities doesn't depend on instance state (maybe move it to another class?) Open
def entities(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#widont doesn't depend on instance state (maybe move it to another class?) Open
def widont(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#emdash doesn't depend on instance state (maybe move it to another class?) Open
def emdash(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#smartypants doesn't depend on instance state (maybe move it to another class?) Open
def smartypants(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#letter_spacing doesn't depend on instance state (maybe move it to another class?) Open
def letter_spacing(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#improve doesn't depend on instance state (maybe move it to another class?) Open
def improve(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#custom_caps doesn't depend on instance state (maybe move it to another class?) Open
def custom_caps(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Jekyll::TypogrifyFilter#caps doesn't depend on instance state (maybe move it to another class?) Open
def caps(text)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Line is too long. [93/80] Open
# Do nothing with the contents if ignored tags, the inside of an opening HTML element
- Create a ticketCreate a ticket
- Exclude checks
Do not use parallel assignment. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.
Example:
# bad
a, b, c = 1, 2, 3
a, b, c = [1, 2, 3]
# good
one, two = *foo
a, b = foo()
a, b = b, a
a = 1
b = 2
c = 3
Do not use parallel assignment. Open
tag, before, caps = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.
Example:
# bad
a, b, c = 1, 2, 3
a, b, c = [1, 2, 3]
# good
one, two = *foo
a, b = foo()
a, b = b, a
a = 1
b = 2
c = 3
Avoid the use of Perl-style backrefs. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Avoid the use of Perl-style backrefs. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Redundant return
detected. Open
return Typogruby.improve(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Redundant return
detected. Open
return custom_caps(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Use only ascii symbols in comments. Open
# converts a — (em dash) by optional whitespace or a non-breaking space
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).
Example:
# bad
# Translates from English to 日本語。
# good
# Translates from English to Japanese
Avoid using {...}
for multi-line blocks. Open
text.gsub(/(\w|\s| )—(?:mdash;|#8212;)?(\w|\s| )/) { |str|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Check for uses of braces or do/end around single line or multi-line blocks.
Example: EnforcedStyle: linecountbased (default)
# bad - single line block
items.each do |item| item / 5 end
# good - single line block
items.each { |item| item / 5 }
# bad - multi-line block
things.map { |thing|
something = thing.some_method
process(something)
}
# good - multi-line block
things.map do |thing|
something = thing.some_method
process(something)
end
Example: EnforcedStyle: semantic
# Prefer `do...end` over `{...}` for procedural blocks.
# return value is used/assigned
# bad
foo = map do |x|
x
end
puts (map do |x|
x
end)
# return value is not used out of scope
# good
map do |x|
x
end
# Prefer `{...}` over `do...end` for functional blocks.
# return value is not used out of scope
# bad
each { |x|
x
}
# return value is used/assigned
# good
foo = map { |x|
x
}
map { |x|
x
}.inspect
Example: EnforcedStyle: bracesforchaining
# bad
words.each do |word|
word.flip.flop
end.join("-")
# good
words.each { |word|
word.flip.flop
}.join("-")
Useless assignment to variable - word
. Use _
or _word
as a variable name to indicate that it won't be used. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Line is too long. [115/80] Open
(?!\w) # ...which must not be followed by a word character.
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [90/80] Open
}.gsub(/(\w+)="(.*?)<span class="emdash">—<\/span>(.*?)"/, '\1="\2—\3"')
- Create a ticketCreate a ticket
- Exclude checks
Avoid the use of Perl-style backrefs. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
require "jekyll/typogrify/version"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
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"
Avoid using {...}
for multi-line blocks. Open
text.gsub(/(click\S*|clint\S*|final\S*|curt\S*|flick\S*)\b/im) { |str|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Check for uses of braces or do/end around single line or multi-line blocks.
Example: EnforcedStyle: linecountbased (default)
# bad - single line block
items.each do |item| item / 5 end
# good - single line block
items.each { |item| item / 5 }
# bad - multi-line block
things.map { |thing|
something = thing.some_method
process(something)
}
# good - multi-line block
things.map do |thing|
something = thing.some_method
process(something)
end
Example: EnforcedStyle: semantic
# Prefer `do...end` over `{...}` for procedural blocks.
# return value is used/assigned
# bad
foo = map do |x|
x
end
puts (map do |x|
x
end)
# return value is not used out of scope
# good
map do |x|
x
end
# Prefer `{...}` over `do...end` for functional blocks.
# return value is not used out of scope
# bad
each { |x|
x
}
# return value is used/assigned
# good
foo = map { |x|
x
}
map { |x|
x
}.inspect
Example: EnforcedStyle: bracesforchaining
# bad
words.each do |word|
word.flip.flop
end.join("-")
# good
words.each { |word|
word.flip.flop
}.join("-")
Redundant return
detected. Open
return Typogruby.widont(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Use only ascii symbols in comments. Open
# converts a — (em dash) by optional whitespace or a non-breaking space
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for non-ascii (non-English) characters in comments. You could set an array of allowed non-ascii chars in AllowedChars attribute (empty by default).
Example:
# bad
# Translates from English to 日本語。
# good
# Translates from English to Japanese
Redundant return
detected. Open
return Typogruby.entities(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Use %r
around regular expression. Open
}.gsub(/(\w+)="(.*?)<span class="emdash">—<\/span>(.*?)"/, '\1="\2—\3"')
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop enforces using // or %r around regular expressions.
Example: EnforcedStyle: slashes (default)
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = %r{
foo
(bar)
(baz)
}x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = /
foo
(bar)
(baz)
/x
Example: EnforcedStyle: percent_r
# bad
snake_case = /^[\dA-Z_]+$/
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = %r{^[\dA-Z_]+$}
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: EnforcedStyle: mixed
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: AllowInnerSlashes: false (default)
# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.
# bad
x =~ /home\//
# good
x =~ %r{home/}
Example: AllowInnerSlashes: true
# good
x =~ /home\//
Unused block argument - str
. You can omit the argument if you don't care about it. Open
text.gsub(/(\w|\s| )—(?:mdash;|#8212;)?(\w|\s| )/) { |str|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
Example:
#good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end
Missing top-level module documentation comment. Open
module TypogrifyFilter
- Read upRead up
- Create a ticketCreate a ticket
- 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
Redundant return
detected. Open
return Typogruby.initial_quotes(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Avoid the use of Perl-style backrefs. Open
tag, before, caps = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Line is too long. [97/80] Open
# $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [125/80] Open
(<[^/][^>]*?>)| # Ignore any opening tag, so we don't mess up attribute values
- Create a ticketCreate a ticket
- Exclude checks
Avoid the use of Perl-style backrefs. Open
tag, before, caps = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Avoid the use of Perl-style backrefs. Open
$1 + '<span class="emdash">—</span>' + $2
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Avoid the use of Perl-style backrefs. Open
$1 + '<span class="emdash">—</span>' + $2
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Useless assignment to variable - tag
. Use _
or _tag
as a variable name to indicate that it won't be used. Open
tag, before, word = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Line is too long. [122/80] Open
(\s| |^|'|"|>|) # Make sure our capture is preceded by whitespace or quotes
- Create a ticketCreate a ticket
- Exclude checks
Redundant return
detected. Open
return emdash(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Redundant return
detected. Open
return Typogruby.amp(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Redundant return
detected. Open
return Typogruby.smartypants(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Redundant return
detected. Open
return text.to_s.titlecase
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Line is too long. [81/80] Open
# so we don't mess up attribute values, or if our capture is only digits.
- Create a ticketCreate a ticket
- Exclude checks
Line is too long. [142/80] Open
([A-Z\d](?:(\.|'|-|&|&|&\#38;)?[A-Z\d][\.']?){1,}) # Capture capital words, with optional dots, numbers or ampersands in between
- Create a ticketCreate a ticket
- Exclude checks
Avoid the use of Perl-style backrefs. Open
tag, before, caps = $1, $2, $3
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Avoid the use of Perl-style backrefs. Open
elsif $3 =~ /^[\d\.]+$/
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop looks for uses of Perl-style regexp match backreferences like $1, $2, etc.
Example:
# bad
puts $1
# good
puts Regexp.last_match(1)
Redundant return
detected. Open
return Typogruby.caps(text.to_s)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.