Floppy/carbon-diet

View on GitHub

Showing 292 of 292 total issues

Method post has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def post
    # Create comment
    comment = Comment.new
    comment.commentable_type =  params[:comment][:commentable_type]
    case comment.commentable_type
Severity: Minor
Found in app/controllers/comments_controller.rb - About 2 hrs 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 initialize has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  initialize: function(element) {
    var defaults = {
      handle: false,
      reverteffect: function(element, top_offset, left_offset) {
        var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
Severity: Minor
Found in app/assets/javascripts/standard/dragdrop.js - About 2 hrs to fix

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

          'margin-box-height': function(element) {
            var bHeight = this.get('border-box-height'),
             mTop = this.get('margin-top'),
             mBottom = this.get('margin-bottom');
    
    
    Severity: Major
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/standard/prototype.js on lines 3460..3468

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

    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

          'margin-box-width': function(element) {
            var bWidth = this.get('border-box-width'),
             mLeft = this.get('margin-left'),
             mRight = this.get('margin-right');
    
    
    Severity: Major
    Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/standard/prototype.js on lines 3450..3458

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

    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 Shrink has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Effect.Shrink = function(element) {
      element = $(element);
      var options = Object.extend({
        direction: 'center',
        moveTransition: Effect.Transitions.sinoidal,
    Severity: Minor
    Found in app/assets/javascripts/standard/effects.js - About 1 hr to fix

      Function Str has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function Str(key, holder, stack) {
          var value = holder[key],
              type = typeof value;
      
          if (Type(value) === OBJECT_TYPE && typeof value.toJSON === 'function') {
      Severity: Minor
      Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

        Function getStyle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            function(proceed, element, style) {
              switch (style) {
                case 'left': case 'top': case 'right': case 'bottom':
                  if (proceed(element, 'position') === 'static') return null;
                case 'height': case 'width':
        Severity: Minor
        Found in app/assets/javascripts/standard/prototype.js - About 1 hr 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 dealWithDeprecatedOptions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
          if (!options) return;
          function fallback(name, expr) {
            if (name in options || expr === undefined) return;
            options[name] = expr;
        Severity: Minor
        Found in app/assets/javascripts/standard/controls.js - About 1 hr 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 setOpacity has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          Element.Methods.setOpacity = function(element, value) {
            element = $(element);
            element.style.opacity = (value == 1 || value === '') ? '' :
              (value < 0.00001) ? 0 : value;
        
        
        Severity: Minor
        Found in app/assets/javascripts/standard/prototype.js - About 1 hr 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 draw has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          draw: function(point) {
            var pos = this.element.cumulativeOffset();
            if(this.options.ghosting) {
              var r   = Position.realOffset(this.element);
              pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
        Severity: Minor
        Found in app/assets/javascripts/standard/dragdrop.js - About 1 hr 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 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            if not @current_user.nil? and (params[:login] == @current_user.login or params[:login].nil?)
              @profile = @current_user
            else
              @profile = User.find_by_login_and_public(params[:login], true)
        Severity: Minor
        Found in app/controllers/profile_controller.rb - About 1 hr 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 onHover has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          onHover: function(element, dropon, overlap) {
            if(Element.isParent(dropon, element)) return;
        
            if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) {
              return;
        Severity: Minor
        Found in app/assets/javascripts/standard/dragdrop.js - About 1 hr 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 (key in hash) {
                  if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
                  hash[key].push(value);
                }
                else hash[key] = value;
        Severity: Major
        Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/standard/prototype.js on lines 4909..4912

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

        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 (key in result) {
                  if (!Object.isArray(result[key])) result[key] = [result[key]];
                  result[key].push(value);
                } else result[key] = value;
        Severity: Major
        Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/standard/prototype.js on lines 628..632

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

        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 encodeForm has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function encodeForm(form)
        {
            function encode(inputs)
            {
                for (var i = 0; i < inputs.length; ++i)
        Severity: Minor
        Found in public/iui/iui.js - About 1 hr to fix

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

            var oldStyle = {
              top: element.style.top,
              left: element.style.left,
              height: element.style.height,
              width: element.style.width,
          Severity: Major
          Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/standard/effects.js on lines 833..838

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

          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

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

            var oldStyle = {
              top: element.style.top,
              left: element.style.left,
              height: element.style.height,
              width: element.style.width,
          Severity: Major
          Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/standard/effects.js on lines 759..764

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

          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 getPixelValue has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function getPixelValue(value, property, context) {
              var element = null;
              if (Object.isElement(value)) {
                element = value;
                value = element.getStyle(property);
          Severity: Minor
          Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

            Function _createResponder has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function _createResponder(element, eventName, handler) {
                var registry = Element.retrieve(element, 'prototype_event_registry');
            
                if (Object.isUndefined(registry)) {
                  CACHE.push(element);
            Severity: Minor
            Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

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

                  if (!this.options.sync)
                    Effect.Queues.get(Object.isString(this.options.queue) ?
                      'global' : this.options.queue.scope).add(this);
              Severity: Major
              Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
              app/assets/javascripts/standard/effects.js on lines 291..293

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

              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

              Severity
              Category
              Status
              Source
              Language