app/controllers/application_controller/session_size.rb
Method get_data_size
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def get_data_size(data, indent = 0)
begin
# TODO: (FB 9144) Determine how the session store handles singleton object so it does not throw errors.
data_size = Marshal.dump(data).size
rescue StandardError => err
- Read upRead up
- Create a ticketCreate a ticket
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 log_data_size
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def log_data_size(el, value, indent)
indentation = ' ' * indent
val_size = if value.kind_of?(Hash) || value.kind_of?(Array) || value.kind_of?(ActiveRecord::Base) || !value.respond_to?("size")
Marshal.dump(value).size
else
- Read upRead up
- Create a ticketCreate a ticket
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
Use :size
instead of "size"
. Open
Open
val_size = if value.kind_of?(Hash) || value.kind_of?(Array) || value.kind_of?(ActiveRecord::Base) || !value.respond_to?("size")
- Create a ticketCreate a ticket
- Exclude checks