Assignment Branch Condition size for flush_writes is too high. [24.52/15] Open
def flush_writes #:nodoc:
@queued_for_write.each do |style_name, file|
FileUtils.mkdir_p(File.dirname(path(style_name)))
begin
move_file(file.path, path(style_name))
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method flush_deletes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def flush_deletes #:nodoc:
@queued_for_delete.each do |path|
begin
log("deleting #{path}")
FileUtils.rm(path) if File.exist?(path)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method flush_writes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def flush_writes #:nodoc:
@queued_for_write.each do |style_name, file|
FileUtils.mkdir_p(File.dirname(path(style_name)))
begin
move_file(file.path, path(style_name))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Line is too long. [92/80] Open
# See Paperclip::Attachment#interpolate for more information on variable interpolaton.
- Exclude checks
Use def with parentheses when there are parameters. Open
def self.extended base
- Read upRead up
- Exclude checks
This cops checks for parentheses around the arguments in method definitions. Both instance and class/singleton methods are checked.
Example: EnforcedStyle: require_parentheses (default)
# The `require_parentheses` style requires method definitions
# to always use parentheses
# bad
def bar num1, num2
num1 + num2
end
def foo descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name
do_something
end
# good
def bar(num1, num2)
num1 + num2
end
def foo(descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name)
do_something
end
Example: EnforcedStyle: requirenoparentheses
# The `require_no_parentheses` style requires method definitions
# to never use parentheses
# bad
def bar(num1, num2)
num1 + num2
end
def foo(descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name)
do_something
end
# good
def bar num1, num2
num1 + num2
end
def foo descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name
do_something
end
Example: EnforcedStyle: requirenoparenthesesexceptmultiline
# The `require_no_parentheses_except_multiline` style prefers no
# parantheses when method definition arguments fit on single line,
# but prefers parantheses when arguments span multiple lines.
# bad
def bar(num1, num2)
num1 + num2
end
def foo descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name
do_something
end
# good
def bar num1, num2
num1 + num2
end
def foo(descriptive_var_name,
another_descriptive_var_name,
last_descriptive_var_name)
do_something
end
Use 0o for octal literals. Open
resolved_chmod = (@options[:override_file_permissions] & ~0111) || (0666 & ~File.umask)
- Read upRead up
- Exclude checks
This cop checks for octal, hex, binary and decimal literals using
uppercase prefixes and corrects them to lowercase prefix
or no prefix (in case of decimals).
eg. for octal use 0o
instead of 0
or 0O
.
Can be configured to use 0
only for octal literals using
EnforcedOctalStyle
=> zero_only
Line is too long. [86/80] Open
# They also can be processed more easily after they've been saved, as they're just
- Exclude checks
Line is too long. [84/80] Open
# normal files. There are two Filesystem-specific options for has_attached_file:
- Exclude checks
Line is too long. [86/80] Open
# almost all cases, should) be coordinated with the value of the +url+ option to
- Exclude checks
Line is too long. [101/80] Open
# you to use paperclip on filesystems that don't understand unix file permissions, and has the
- Exclude checks
Use 0o for octal literals. Open
resolved_chmod = (@options[:override_file_permissions] & ~0111) || (0666 & ~File.umask)
- Read upRead up
- Exclude checks
This cop checks for octal, hex, binary and decimal literals using
uppercase prefixes and corrects them to lowercase prefix
or no prefix (in case of decimals).
eg. for octal use 0o
instead of 0
or 0O
.
Can be configured to use 0
only for octal literals using
EnforcedOctalStyle
=> zero_only
Space inside parentheses detected. Open
FileUtils.chmod( resolved_chmod, path(style_name) )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Trailing whitespace detected. Open
# you to use paperclip on filesystems that don't understand unix file permissions, and has the
- Exclude checks
Line is too long. [91/80] Open
break if File.exist?(path) # Ruby 1.9.2 does not raise if the removal failed.
- Exclude checks
Line is too long. [109/80] Open
rescue Errno::EEXIST, Errno::ENOTEMPTY, Errno::ENOENT, Errno::EINVAL, Errno::ENOTDIR, Errno::EACCES
- Exclude checks
Line is too long. [86/80] Open
# added benefit of using the storage directories default umask on those that do.
- Exclude checks
Space after keyword while
is missing. Open
while(true)
- Read upRead up
- Exclude checks
Checks the spacing around the keywords.
Example:
# bad
something 'test'do|x|
end
while(something)
end
something = 123if test
# good
something 'test' do |x|
end
while (something)
end
something = 123 if test
Line is too long. [93/80] Open
# saved by paperclip. If you set this to an explicit octal value (0755, 0644, etc) then
- Exclude checks
Line is too long. [94/80] Open
# If you set :override_file_permissions to false, the chmod will be skipped. This allows
- Exclude checks
Line is too long. [99/80] Open
resolved_chmod = (@options[:override_file_permissions] & ~0111) || (0666 & ~File.umask)
- Exclude checks
Useless assignment to variable - e
. Open
rescue Errno::ENOENT => e
- Read upRead up
- 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
Extra empty line detected at module body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Line is too long. [85/80] Open
# The default place to store attachments is in the filesystem. Files on the local
- Exclude checks
Line is too long. [87/80] Open
log("There was an unexpected error while deleting directories: #{e.class}")
- Exclude checks
Line is too long. [90/80] Open
# By default this places the files in the app's public directory which can be served
- Exclude checks
Put empty method definitions on a single line. Open
def self.extended base
end
- Read upRead up
- Exclude checks
This cop checks for the formatting of empty method definitions.
By default it enforces empty method definitions to go on a single
line (compact style), but it can be configured to enforce the end
to go on its own line (expanded style).
Note: A method definition is not considered empty if it contains comments.
Example: EnforcedStyle: compact (default)
# bad
def foo(bar)
end
def self.foo(bar)
end
# good
def foo(bar); end
def foo(bar)
# baz
end
def self.foo(bar); end
Example: EnforcedStyle: expanded
# bad
def foo(bar); end
def self.foo(bar); end
# good
def foo(bar)
end
def self.foo(bar)
end
Line is too long. [95/80] Open
# * +override_file_permissions+: This allows you to override the file permissions for files
- Exclude checks
Space inside parentheses detected. Open
FileUtils.chmod( resolved_chmod, path(style_name) )
- Read upRead up
- Exclude checks
Checks for spaces inside ordinary round parentheses.
Example:
# bad
f( 3)
g = (a + 3 )
# good
f(3)
g = (a + 3)
Line is too long. [88/80] Open
# make a symlink to the capistrano-created system directory from inside your app's
- Exclude checks
Line is too long. [89/80] Open
# filesystem can be very easily served by Apache without requiring a hit to your app.
- Exclude checks
Line is too long. [85/80] Open
# directly. If you are using capistrano for deployment, a good idea would be to
- Exclude checks
Line is too long. [97/80] Open
# that value will be used to set the permissions for an uploaded file. The default is 0666.
- Exclude checks
Line is too long. [88/80] Open
# * +path+: The location of the repository of attachments on disk. This can (and, in
- Exclude checks