Showing 119 of 119 total issues
Method acts_as_content_block
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
def acts_as_content_block(options={})
defaults = {
# Set default values here.
allow_attachments: true,
content_module: true,
- 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 ContentBlockController
has 52 methods (exceeds 20 allowed). Consider refactoring. Open
class ContentBlockController < Cms::BaseController
include Cms::ContentRenderingSupport
allow_guests_to [:show_via_slug]
Class Page
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class Cms::Page < ActiveRecord::Base
def actual_path
path
end
Method menu_items
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def menu_items(options = {})
# Intialize parameters
selected_page = options[:page] || @page
return nil unless selected_page
- 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
Function tagList
has 117 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.tagList = function(tags) {
var tagListInput = this;
var tagSeparator = " ";
var getTagList = function() {
Class Attachment
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class Attachment < ActiveRecord::Base
MULTIPLE = 'multiple'
SANITIZATION_REGEXES = [[/\s/, '_'], [/[&+()]/, '-'], [/[=?!'"{}\[\]#<>%]/, '']]
File content_block_controller.rb
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'cms/category_type'
# This is not called directly
# This is the base class for other content blocks
module Cms
class ContentBlockController < Cms::BaseController
Class Section
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Section < ActiveRecord::Base
flush_cache_on_change
is_addressable no_dynamic_path: true, destroy_if: :deletable?
# Cannot use dependent => :destroy to do this. Ancestry's callbacks trigger before the before_destroy callback.
Class Portlet
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
class Portlet < ActiveRecord::Base
validates_presence_of :name
is_searchable
uses_soft_delete
has_content_type :module => :core
File page.rb
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Cms::Page < ActiveRecord::Base
def actual_path
path
end
Class ContentType
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ContentType
attr_accessor :name
def initialize(options)
Method content_blocks
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def content_blocks(content_block_name, options = {}, &block)
options = DEFAULT_CONTENT_BLOCKS_OPTIONS.merge options
model_class = guess_model_class(content_block_name)
# options to
- 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 copy_connectors
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def copy_connectors(options={})
logger.debug { "Copying connectors from Page #{id} v#{options[:from_version_number]} to v#{options[:to_version_number]}." }
c_found = connectors.for_page_version(options[:from_version_number]).order("#{Cms::Connector.table_name}.container, #{Cms::Connector.table_name}.position").to_a
logger.debug { "Found connectors #{c_found}" }
- 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 publish!
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def publish!
did_publish = false
if new_record?
ActiveSupport::Deprecation.warn "Calling .publish! on a new record no longer saves the record. Call '.save' to persist and publish the record.", caller
else
- 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 input
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def input(_wrapper_options = nil)
# New blocks will not have their attachments created yet.
object.ensure_attachment_exists if object.respond_to?(:ensure_attachment_exists)
# Need to explictly use correct id (i.e. image_block_file) rather than the autogenerated one (i.e. image_block_attachments_attributes_0_attachment_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
var selectNextTag = function() {
if(getSelectedTag().length > 0 && getSelectedTag().next().length > 0) {
selectTag(getSelectedTag().next())
} else {
selectTag(getFirstTag())
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 83.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
var selectPrevTag = function() {
if(getSelectedTag().length > 0 && getSelectedTag().prev().length > 0) {
selectTag(getSelectedTag().prev())
} else {
selectTag(getFirstTag())
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 83.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function cmsContentToolbar
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.cmsContentToolbar = function () {
var content_type = this.data('content_type')
var is_versioned = this.data('versioned')
var can_publish = this.data('can_publish')
var plural_title = this.data('plural_title')
Method create_content_table
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def create_content_table(table_name, options={}, &block)
defaults = {
versioned: true,
name: true
}
- 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 complete
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def complete
if params[:task_ids]
Task.where(["id in (?)", params[:task_ids]]).each do |t|
if t.assigned_to == current_user
t.mark_as_complete!
- 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"