Floppy/carbon-diet

View on GitHub

Showing 292 of 292 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
    options.okLink == options.okButton == false ? false : undefined)));
Severity: Minor
Found in app/assets/javascripts/standard/controls.js and 1 other location - About 45 mins to fix
app/assets/javascripts/standard/controls.js on lines 863..864

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 50.

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

Further Reading

Method get_actions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def get_actions(num, offset=0)
    return if @current_user.nil?
    totals = @current_user.calculate_totals(28)
    categories = []
    totals.each do |item|
Severity: Minor
Found in app/controllers/application_controller.rb - About 45 mins to fix

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 _tree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  _tree: function(element, options, parent) {
    var children = Sortable.findElements(element, options) || [];

    for (var i = 0; i < children.length; ++i) {
      var match = children[i].id.match(options.format);
Severity: Minor
Found in app/assets/javascripts/standard/dragdrop.js - About 45 mins to fix

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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    respond_to do |format|
      format.html {
        # Data
        @notes = @current_user.all_notes.paginate :page => params[:page]
Severity: Minor
Found in app/controllers/notes_controller.rb - About 45 mins to fix

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

  fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
    options.cancelLink == options.cancelButton == false ? false : undefined)));
Severity: Minor
Found in app/assets/javascripts/standard/controls.js and 1 other location - About 45 mins to fix
app/assets/javascripts/standard/controls.js on lines 865..866

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 50.

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

Further Reading

Function create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  create: function(element) {
    element = $(element);
    var options = Object.extend({
      element:     element,
      tag:         'li',       // assumes li children, override with tag: 'tagname'
Severity: Minor
Found in app/assets/javascripts/standard/dragdrop.js - About 45 mins to fix

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

Avoid deeply nested control flow statements.
Open

        if session[:next].include? "http://support.carbondiet.org"
          redirect_to "#{session[:next]}?sso=#{CGI.escape(user.multipass)}"
        else
          redirect_to(session[:next])
        end
Severity: Major
Found in app/controllers/user_controller.rb - About 45 mins to fix

    Method set_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_login
        user = @current_user
        if request.post?
          if not params[:user][:login] =~ /^\w+$/i
            flash[:notice] = "Please enter a valid username (letters, numbers and underscores only)"
    Severity: Minor
    Found in app/controllers/user_controller.rb - About 45 mins to fix

    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 (el.className !== 'x') {
          el.setAttribute('class', 'x');
          if (el.className === 'x') {
            classProp = 'class';
          }
    Severity: Minor
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/prototype.js on lines 2561..2566

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if((!this.options.constraint) || (this.options.constraint=='horizontal'))
          style.left = p[0] + "px";
    Severity: Minor
    Found in app/assets/javascripts/standard/dragdrop.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/dragdrop.js on lines 492..493

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    Form.Observer = Class.create(Abstract.TimedObserver, {
      getValue: function() {
        return Form.serialize(this.element);
      }
    });
    Severity: Minor
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/prototype.js on lines 5246..5250

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if((!this.options.constraint) || (this.options.constraint=='vertical'))
          style.top  = p[1] + "px";
    Severity: Minor
    Found in app/assets/javascripts/standard/dragdrop.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/dragdrop.js on lines 490..491

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if (el.htmlFor !== 'x') {
          el.setAttribute('htmlFor', 'x');
          if (el.htmlFor === 'x') {
            forProp = 'htmlFor';
          }
    Severity: Minor
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/prototype.js on lines 2551..2556

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    Form.EventObserver = Class.create(Abstract.EventObserver, {
      getValue: function() {
        return Form.serialize(this.element);
      }
    });
    Severity: Minor
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 40 mins to fix
    app/assets/javascripts/standard/prototype.js on lines 5193..5197

    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

    Further Reading

    Consider simplifying this complex logical expression.
    Open

            if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
                    Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
                var ret = Sizzle.find( parts.shift(), context, contextXML );
                context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
            }
    Severity: Major
    Found in app/assets/javascripts/standard/prototype.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

            if((tag_name = src.tagName.toUpperCase()) && (
              tag_name=='INPUT' ||
              tag_name=='SELECT' ||
              tag_name=='OPTION' ||
              tag_name=='BUTTON' ||
      Severity: Major
      Found in app/assets/javascripts/standard/dragdrop.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

            if (Object.isString(insertions) || Object.isNumber(insertions) ||
                Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
                  insertions = {bottom:insertions};
        Severity: Major
        Found in app/assets/javascripts/standard/prototype.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                  if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
                       (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
                    // "submit" => "emulated:submit"
                    this.eventName = 'emulated:' + this.eventName;
                  }
          Severity: Major
          Found in app/assets/javascripts/rails.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                  if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
                      (classNames && classNames.all(function(name) {
                        return !name.toString().blank() && cn.include(' ' + name + ' ');
                      }))))
                    elements.push(Element.extend(child));
            Severity: Major
            Found in app/assets/javascripts/standard/prototype.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  if (/\d/.test(value) && element && element.runtimeStyle && !(isPercentage && isViewport)) {
                    var style = element.style.left, rStyle = element.runtimeStyle.left;
                    element.runtimeStyle.left = element.currentStyle.left;
                    element.style.left = value || 0;
                    value = element.style.pixelLeft;
              Severity: Major
              Found in app/assets/javascripts/standard/prototype.js - About 40 mins to fix
                Severity
                Category
                Status
                Source
                Language