Possible command injection Open
var node = #{dom_node};
- Read upRead up
- Exclude checks
Injection is #1 on the 2010 OWASP Top Ten web security risks. Command injection occurs when shell commands unsafely include user-manipulatable values.
There are many ways to run commands in Ruby:
`ls #{params[:file]}`
system("ls #{params[:dir]}")
exec("md5sum #{params[:input]}")
Brakeman will warn on any method like these that uses user input or unsafely interpolates variables.
See the Ruby Security Guide for details.
Possible command injection Open
var node = #{dom_node};
- Read upRead up
- Exclude checks
Injection is #1 on the 2010 OWASP Top Ten web security risks. Command injection occurs when shell commands unsafely include user-manipulatable values.
There are many ways to run commands in Ruby:
`ls #{params[:file]}`
system("ls #{params[:dir]}")
exec("md5sum #{params[:input]}")
Brakeman will warn on any method like these that uses user input or unsafely interpolates variables.
See the Ruby Security Guide for details.
Possible command injection Open
var node = #{dom_node};
- Read upRead up
- Exclude checks
Injection is #1 on the 2010 OWASP Top Ten web security risks. Command injection occurs when shell commands unsafely include user-manipulatable values.
There are many ways to run commands in Ruby:
`ls #{params[:file]}`
system("ls #{params[:dir]}")
exec("md5sum #{params[:input]}")
Brakeman will warn on any method like these that uses user input or unsafely interpolates variables.
See the Ruby Security Guide for details.
Method run_blocks_to_load
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.run_blocks_to_load(fetch_id, failure = nil)
if @blocks_to_load
blocks_to_load_now = @blocks_to_load.select { |data| data.first == fetch_id }
@blocks_to_load = @blocks_to_load.reject { |data| data.first == fetch_id }
@load_stack ||= []
- 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 reactive_record_link_set_while_loading_container_class
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reactive_record_link_set_while_loading_container_class
%x{
var node = #{dom_node};
Method load
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.load(&block)
promise = Promise.new
@load_stack ||= []
@load_stack << @loads_pending
@loads_pending = nil
- 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
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
React::IsomorphicHelpers.log "ReactiveRecord.load exception raised during retry: #{e}", :error
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end
Useless assignment to variable - id
. Use _
or _id
as a variable name to indicate that it won't be used. Open
id, promise, block = data
- 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
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
React::IsomorphicHelpers.log "ReactiveRecord.load exception raised during initial load: #{e}", :error
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end