Showing 336 of 336 total issues
Method model=
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def model=(val)
if val.is_a?(Promise)
# Resolve the promise before setting
self.last_promise = val
- 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 set
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def set(attribute_name, value, &block)
# Assign, without the =
attribute_name = attribute_name.to_sym
check_valid_field_name(attribute_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
Method getter_to_setter
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def getter_to_setter(getter)
getter = getter.strip.gsub(/\(\s*\)/, '')
# Check to see if this can be converted to a setter
if getter[0] =~ /^[A-Z]/ && getter[-1] != ')'
- 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 dispatch_in_thread
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def dispatch_in_thread(channel, message)
callback_id, class_name, method_name, meta_data, *args = message
method_name = method_name.to_sym
# Get the class
- 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 access
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
length = elems.length,
bulk = key == null;
Function dispatch
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
dispatch: function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
Method item_added
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def item_added(position)
item_context = nil
binding_name = @@binding_number
@@binding_number += 1
Method add_linking_in_asset_path
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_linking_in_asset_path
app_path = @volt_app.app_path
@env.context_class.class_eval do
# We "freedom-patch" sprockets-helpers asset_path method to
# automatically link assets.
Method validate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.validate(model, field_name, args)
errors = {}
value = model.get(field_name)
type_restriction = args.is_a?(Hash) ? (args[:type] || args[:types]) : args
Method update
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update(path, section_or_arguments = nil, options = {})
Computation.run_without_tracking do
@options = options
# A blank path needs to load a missing template, otherwise it tries to load
Consider simplifying this complex logical expression. Open
} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
diff = cache[1];
// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
} else {
Consider simplifying this complex logical expression. Open
if ( start && start[ 3 ] !== unit ) {
// Trust units reported by jQuery.css
unit = unit || start[ 3 ];
// Make sure we update the tween properties later on
Function setOffset
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
setOffset: function( elem, options, i ) {
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
position = jQuery.css( elem, "position" ),
curElem = jQuery( elem ),
props = {};
Method parse
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse
loop do
if last && SPECIAL[last]
# In a script or style tag, just look for the first end
close_tag = "</#{last}>"
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).addClass( value.call( this, j, this.className ) );
});
}
- 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 61.
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 ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).removeClass( value.call( this, j, this.className ) );
});
}
- 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 61.
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 load
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
jQuery.fn.load = function( url, params, callback ) {
if ( typeof url !== "string" && _load ) {
return _load.apply( this, arguments );
}
Function style
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return;
}
Method update_binding_anchors!
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_binding_anchors!(nodes)
new_bindings = {}
@binding_anchors.each_pair do |name, anchors|
new_name = @@binding_number
Method server
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def server
move_to_root
if ENV['PROFILE_BOOT']
begin
require 'ruby-prof'