Showing 119 of 119 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'input-append' do |append|
- 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 54.
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
config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'input-prepend' do |prepend|
- 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 54.
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
Method publish!
has 30 lines of code (exceeds 25 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
Method update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
content_block = Content.find_draft(params[:content_name], params[:id])
content_block.update_attributes(filtered_content(content_block))
@page = Page.find_draft(params[:page_id].to_i)
if (!@page.live?)
Function init
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
init:function (editor) {
editor.ui.addButton('DeleteContent', {
label:'Remove this content from the page (It will remain in Content Library)',
command:'deleteContent',
toolbar:'tools'
Function saveChanges
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveChanges: function(currentEditor, afterSave) {
var block_id = currentEditor.name;
var block = $("#" + block_id);
var attribute = block.data('attribute');
var content_name = block.data('content-name');
Method is_versioned
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def is_versioned(options={})
@is_versioned = true
@version_table_name = (options[:version_table_name] || "#{table_name.singularize}_versions").to_s
Method acts_as_content_block
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def acts_as_content_block(options={})
defaults = {
# Set default values here.
allow_attachments: true,
content_module: true,
Method input
has 26 lines of code (exceeds 25 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)
Method inherited
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.inherited(subclass)
super if defined? super
ensure
subclass.class_eval do
extend Cms::PolymorphicSingleTableInheritance
Method copy_connectors
has 26 lines of code (exceeds 25 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}" }
Method index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def index
@have_external_users = Cms::ExternalUser.count > 0
query, conditions = [], []
- 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 update_connected_pages
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_connected_pages
# If this is versioned, then we need make new versions of all the pages this is connected to
if self.class.versioned?
#logger.info "..... Updating connected pages for #{self.class} #{id} v#{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"
Further reading
Similar blocks of code found in 2 locations. Consider refactoring. Open
config.wrappers :bootstrap, tag: 'div', class: 'control-group row-fluid', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input
- 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 45.
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
Method move_connector
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def move_connector(connector, direction)
transaction do
raise "Connector is nil" unless connector
raise "Direction is nil" unless direction
orientation = direction[/_/] ? "#{direction.sub('_', ' the ')} of" : "#{direction} within"
- 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 assign_parent_if_needed
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def assign_parent_if_needed
unless parent || parent_id
new_parent = Cms::Section.with_path(self.class.path).first
unless new_parent
- 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 render_portlet
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render_portlet(name)
portlets = Portlet.all(:conditions => ["name = ?", name.to_s])
if portlets.size > 1
edit_mode? ? "ERROR: Multiple Portlets with name '#{name}'" : nil
elsif portlets.empty?
- 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
config.wrappers :browsercms, tag: 'div', class: 'control-group row-fluid', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input
- 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 45.
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
Method set_template
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.set_template(args)
if args.include?("-m")
index = args.index("-m")
if args[index + 1] == "demo"
args[index + 1] = template("demo.rb")
- 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 menu_button
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def menu_button(label, path, options={})
return '' unless path.present?
defaults = {
enabled: 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"