Use tr
instead of gsub
. Open
return title.downcase.strip.gsub(' ', '_').gsub(/[^\w-]/, '')
- Read upRead up
- Exclude checks
This cop identifies places where gsub
can be replaced by
tr
or delete
.
Example:
# bad
'abc'.gsub('b', 'd')
'abc'.gsub('a', '')
'abc'.gsub(/a/, 'd')
'abc'.gsub!('a', 'd')
# good
'abc'.gsub(/.*/, 'a')
'abc'.gsub(/a+/, 'd')
'abc'.tr('b', 'd')
'a b c'.delete(' ')
Use tr
instead of gsub
. Open
return title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
- Read upRead up
- Exclude checks
This cop identifies places where gsub
can be replaced by
tr
or delete
.
Example:
# bad
'abc'.gsub('b', 'd')
'abc'.gsub('a', '')
'abc'.gsub(/a/, 'd')
'abc'.gsub!('a', 'd')
# good
'abc'.gsub(/.*/, 'a')
'abc'.gsub(/a+/, 'd')
'abc'.tr('b', 'd')
'a b c'.delete(' ')
TODO found Open
# TODO: Migrate slugify from '-' to '_'. Need to write script to migrate filenames
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Redundant return
detected. Open
return title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
- Read upRead up
- 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
# strip characters and whitespace to create valid filenames, also lowercase
- Exclude checks
Redundant return
detected. Open
return title.downcase.strip.gsub(' ', '_').gsub(/[^\w-]/, '')
- Read upRead up
- 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
# strip characters and whitespace to create valid filenames, also lowercase
- Exclude checks
Line is too long. [86/80] Open
# TODO: Migrate slugify from '-' to '_'. Need to write script to migrate filenames
- Exclude checks
Missing top-level class documentation comment. Open
class Utils
- 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