Showing 27 of 27 total issues
Freeze mutable objects assigned to constants. Open
Open
DEFAULT_TAGS = ["~FC011", "~FC033"]
- Read upRead up
- Exclude checks
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
Use the return of the conditional for variable assignment and comparison. Open
Open
if File.exist?(path)
@config = JSON.parse(File.read(path))
else
@config = {}
end
- Exclude checks
Use the return of the conditional for variable assignment and comparison. Open
Open
if File.exist?(path)
@config = YAML.load_file(path)
else
@config = {}
end
- Exclude checks
Use warn
instead of $stderr.puts
to allow such output to be disabled. Open
Open
$stderr.puts "foodcritic options: #{options.inspect}"
- Read upRead up
- Exclude checks
This cop identifies places where $stderr.puts
can be replaced by
warn
. The latter has the advantage of easily being disabled by,
e.g. the -W0 interpreter flag, or setting $VERBOSE to nil.
Example:
# bad
$stderr.puts('hello')
# good
warn('hello')
Put a comma after the last item of a multiline hash. Open
Open
}
- Read upRead up
- Exclude checks
This cop checks for trailing comma in array and hash literals.
Example: EnforcedStyleForMultiline: consistent_comma
# bad
a = [1, 2,]
# good
a = [
1, 2,
3,
]
# good
a = [
1,
2,
]
Example: EnforcedStyleForMultiline: comma
# bad
a = [1, 2,]
# good
a = [
1,
2,
]
Example: EnforcedStyleForMultiline: no_comma (default)
# bad
a = [1, 2,]
# good
a = [
1,
2
]
Freeze mutable objects assigned to constants. Open
Open
DEFAULT_INCLUDE_PATHS = ["./"]
- Read upRead up
- Exclude checks
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
Use warn
instead of $stderr.puts
to allow such output to be disabled. Open
Open
$stderr.puts "Omitting issue for non-existent file: #{issue.filename}"
- Read upRead up
- Exclude checks
This cop identifies places where $stderr.puts
can be replaced by
warn
. The latter has the advantage of easily being disabled by,
e.g. the -W0 interpreter flag, or setting $VERBOSE to nil.
Example:
# bad
$stderr.puts('hello')
# good
warn('hello')