Showing 12 of 12 total issues
Method pagelet
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pagelet path, p_options = {}
Rails.logger.info "Rendering pagelet #{path}"
p_params = p_options.delete(:params) { {} }.with_indifferent_access
Method pagelet
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def pagelet path, p_options = {}
Rails.logger.info "Rendering pagelet #{path}"
p_params = p_options.delete(:params) { {} }.with_indifferent_access
- 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 pagelet_cache
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def pagelet_cache &block
# puts 'pagelet_cache'.blue
cache_enabled = pagelet_options.cache || pagelet_options.cache_path || pagelet_options.expires_in
if !cache_enabled
- 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 around
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def around(controller)
cache_layout = @cache_layout.respond_to?(:call) ? @cache_layout.call(controller) : @cache_layout
path_options = if @cache_path.is_a?(Proc)
controller.instance_exec(controller, &@cache_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
Function processDataRemoteTags
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
root.processDataRemoteTags = function() {
$('form[data-remote]').each(function(index, elem){
var $el = $(elem);
var container = $el.closest('[data-pagelet-container]');
Method pagelet_cache
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def pagelet_cache &block
# puts 'pagelet_cache'.blue
cache_enabled = pagelet_options.cache || pagelet_options.cache_path || pagelet_options.expires_in
if !cache_enabled
Function loadPagelets
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
root.loadPagelets = function(selector) {
selector = selector || '[data-pagelet-load]';
var groups = {};
$(selector).each(function(index, elem) {
Method render_remote_load
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render_remote_load
# puts 'render_remote_load'.blue
render_remotely = pagelet_render_remotely?
if render_remotely && pagelet_options.has_cache
render_remotely = false
- 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
if (!hidden_field) {
$("<input/>", {
name: "target_container",
type: "hidden",
value: container.attr('id')
- 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 49.
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
if (!hidden_field) {
$("<input/>", {
name: "original_pagelet_options",
type: "hidden",
value: container.data('pagelet-options')
- 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 49.
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 process_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def process_action *args
super.tap do
if params[:target_container] &&
action_has_layout? &&
request.format.js? # wrap to js only if requested js
- 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 expire_action
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def expire_action(options = {})
return unless cache_configured?
if options.is_a?(Hash) && options[:action].is_a?(Array)
options[:action].each { |action| expire_action(options.merge(action: action)) }
- 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"