Method index
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def index
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
model = nil
if (model_desc = params[:model])
- 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 public
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def public
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
if (data_type = Setup::FileDataType.where(id: params[:data_type_id]).first)
if data_type.public_read
- 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 index
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if (tenant = Tenant.where(id: params[:tenant_id]).first)
tenant.switch do
model = nil
if (model_desc = params[:model])
Avoid deeply nested control flow statements. Open
if (filename.nil? || (uploader = find_version(uploader, uploader.path_for(record, field, filename)))) &&
(content = uploader.read)
send_data content,
filename: uploader.identifier,
type: uploader.file.content_type,
Avoid deeply nested control flow statements. Open
if (filename = params[:file])
filename = "#{filename}.#{params[:format]}" if params[:format]
end
Method find_version
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_version(uploader, path)
if uploader.path == path
uploader
else
uploader.versions.values.each do |uploader_version|
- 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"