Method show
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def show
respond_to do |format|
format.html do
if @attachment.container.respond_to?(:attachments)
@attachments = @attachment.container.attachments.to_a
- 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
Class AttachmentsController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class AttachmentsController < ApplicationController
include ActionView::Helpers::NumberHelper
before_action :find_attachment, :only => [:show, :download, :thumbnail, :update, :destroy]
before_action :find_container, :only => [:edit_all, :update_all, :download_all]
File attachments_controller.rb
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
class AttachmentsController < ApplicationController
include ActionView::Helpers::NumberHelper
before_action :find_attachment, :only => [:show, :download, :thumbnail, :update, :destroy]
before_action :find_container, :only => [:edit_all, :update_all, :download_all]
Method show
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
respond_to do |format|
format.html do
if @attachment.container.respond_to?(:attachments)
@attachments = @attachment.container.attachments.to_a
Method upload
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def upload
# Make sure that API users get used to set this content type
# as it won't trigger Rails' automatic parsing of the request body for parameters
unless request.media_type == 'application/octet-stream'
head 406
- 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 find_container
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_container
# object_type is constrained to valid values in routes
klass = params[:object_type].to_s.singularize.classify.constantize
@container = klass.find(params[:object_id])
unless @container.visible?
- 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"