Showing 3,976 of 3,976 total issues
Assignment Branch Condition size for validate_photo_size is too high. [18.44/15] Open
def validate_photo_size
errors[:photo] << "should be less than 3MB" if photo and photo.size and photo.size > 3.megabytes
pictures.each do |picture|
if picture.image_file_size > 3.megabytes
errors[:pictures] << "should be less than 3MB"
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Cyclomatic complexity for edit is too high. [9/6] Open
def edit
flash[:notice] = "All information added here will be visible to other members."
if @current_user.dogs.empty?
flash[:notice] = "Please update your zipcode to add a dog. All information added here will be visible to other members."
end
- Read upRead up
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Assignment Branch Condition size for create is too high. [18.71/15] Open
def create
@event = Event.new(params_hash)
@event.dogs << params["event"]["dogs"].map { |id| Dog.where(:id => id) }
@event.user_id = @current_user.id
@user = @current_user
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for all_info is too high. [18.87/15] Open
def all_info
filtered_dogs_hash = Dog.all.select { |dog|
valid_dog = true
if params[:available] == "true" && !dog.available then valid_dog = false end
if params[:available] == "false" && dog.available then valid_dog = false end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Perceived complexity for edit is too high. [10/7] Open
def edit
flash[:notice] = "All information added here will be visible to other members."
if @current_user.dogs.empty?
flash[:notice] = "Please update your zipcode to add a dog. All information added here will be visible to other members."
end
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Consider simplifying this complex logical expression. Open
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
Function close
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
close: function(query) {
var
$activeTitle = (query !== undefined)
? (typeof query === 'number')
? $title.eq(query)
Consider simplifying this complex logical expression. Open
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
Function translate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function translate(number, withoutSuffix, key) {
var result = number + ' ';
switch (key) {
case 'm':
return withoutSuffix ? 'jedna minuta' : 'jedne minute';
Function translate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function translate(number, withoutSuffix, key) {
var result = number + ' ';
switch (key) {
case 'm':
return withoutSuffix ? 'jedna minuta' : 'jedne minute';
Function translate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function translate(number, withoutSuffix, key, isFuture) {
var result = number + ' ';
switch (key) {
case 's': // a few seconds / in a few seconds / a few seconds ago
return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
Function translate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function translate(number, withoutSuffix, key, isFuture) {
var result = number + ' ';
switch (key) {
case 's': // a few seconds / in a few seconds / a few seconds ago
return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
Consider simplifying this complex logical expression. Open
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector ||
selector === "**" && handleObj.selector ) ) {
Function prepareElementRoot
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function prepareElementRoot() {
P.$root.
on({
Function validate
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
DatePicker.prototype.validate = function( type, dateObject, options ) {
var calendar = this,
// Keep a reference to the original date.
Function onKeyDown
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
onKeyDown = function(e){
// TAB - switch to another input
if(e.which == 9){
$newSelect.trigger('close');
return;
Function animateClass
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.effects.animateClass = function( value, duration, easing, callback ) {
var o = $.speed( duration, easing, callback );
return this.queue( function() {
var animated = $( this ),
Consider simplifying this complex logical expression. Open
if ( !options || !options.nav ) if (
/* 1 */ ( !isFlippedBase && calendar.disabled( dateObject ) ) ||
/* 2 */ ( isFlippedBase && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
/* 3 */ ( !isFlippedBase && (dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick) )
) {
Function animateClass
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.effects.animateClass = function( value, duration, easing, callback ) {
var o = $.speed( duration, easing, callback );
return this.queue( function() {
var animated = $( this ),
Function animateClass
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.effects.animateClass = function( value, duration, easing, callback ) {
var o = $.speed( duration, easing, callback );
return this.queue( function() {
var animated = $( this ),