Showing 80 of 80 total issues
Function createToolbar
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
createToolbar: function(el, options) {
var self = this;
var toolbar = $("<ul/>", {
'class' : "wysihtml5-toolbar",
'style': "display:none"
Function initInsertImage
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
initInsertImage: function(toolbar) {
var self = this;
var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
var insertButton = insertImageModal.find('a.btn-primary');
Method process_content
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.process_content(page, content = '', parent_tag = nil)
tokens = content.to_s.scan(TOKENIZER_REGEX)
tokens.collect do |tag_signature, text|
if tag_signature
if tag = self.initialize_tag(page, tag_signature)
- 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 export_pages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.export_pages(from_site, to_folder = nil)
return unless site = Cms::Site.find_by_identifier(from_site)
path = File.join(ComfyPress.config.fixtures_path, (to_folder || site.identifier), 'pages')
FileUtils.rm_rf(path)
FileUtils.mkdir_p(path)
- 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 admin
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.admin(options = {})
options[:path] ||= 'cms-admin'
Rails.application.routes.draw do
namespace :cms_admin, :path => options[:path], :except => :show do
Method cms_snippet_content
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def cms_snippet_content(identifier, cms_site = nil)
unless cms_site
host, path = request.host.downcase, request.fullpath if respond_to?(:request) && request
cms_site ||= (@cms_site || Cms::Site.find_site(host, path))
end
- 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 import_snippets
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import_snippets(to_site, from_folder = nil, force_import = false)
site = Cms::Site.find_or_create_by_identifier(to_site)
unless path = find_fixtures_path((from_folder || to_site), 'snippets')
ComfyPress.logger.warn('Cannot find Snippet fixtures')
return []
Method sync_mirror
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_mirror
return if self.is_mirrored || !self.site.is_mirrored?
(Cms::Site.mirrored - [self.site]).each do |site|
mirror = case self
Method sync_mirror
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def sync_mirror
return if self.is_mirrored || !self.site.is_mirrored?
(Cms::Site.mirrored - [self.site]).each do |site|
mirror = case self
- 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 create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@slides = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
- 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 create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@files = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
Method initialize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
@cms_title = 'ComfyPress CMS Engine'
@admin_auth = 'ComfyPress::HttpAuth'
@public_auth = 'ComfyPress::DummyAuth'
@seed_data_path = nil
Method create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@slides = []
# Sometimes params[:file] comes in as a single file object
unless params[:file].is_a?(Hash)
Method render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def render
files = block.files
case self.type
when 'url'
return '' if files.blank?
Method initialize_tag
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize_tag(page, tag_signature)
if match = tag_signature.match(regex_tag_signature)
params = begin
(CSV.parse_line(match[2].to_s, :col_sep => ':') || []).compact
- 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 import_pages
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.import_pages(to_site, from_folder = nil, path = nil, root = true, parent = nil, page_ids = [], force_import = false)
Method import_layouts
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.import_layouts(to_site, from_folder = nil, path = nil, root = true, parent = nil, layout_ids = [], force_import = false)
Method options_for_select
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ')
Similar blocks of code found in 7 locations. Consider refactoring. Open
def update
@slide.update_attributes!(params[:file])
flash[:success] = I18n.t('cms.slides.updated')
redirect_to :action => :edit, :id => @slide
rescue ActiveRecord::RecordInvalid
- 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 39.
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 7 locations. Consider refactoring. Open
def update
@tab.update_attributes!(params[:tab])
flash[:success] = I18n.t('cms.tabs.updated')
redirect_to :action => :edit, :id => @tab
rescue ActiveRecord::RecordInvalid
- 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 39.
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