Floppy/carbon-diet

View on GitHub

Showing 292 of 292 total issues

Function Class has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

var Class = (function() {

  var IS_DONTENUM_BUGGY = (function(){
    for (var p in { toString: 1 }) {
      if (p === 'toString') return false;
Severity: Minor
Found in app/assets/javascripts/standard/prototype.js - About 3 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 Hash has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Hash = Class.create(Enumerable, (function() {
  function initialize(object) {
    this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
  }

Severity: Major
Found in app/assets/javascripts/standard/prototype.js - About 3 hrs to fix

    Function create has 87 lines of code (exceeds 25 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: Major
    Found in app/assets/javascripts/standard/dragdrop.js - About 3 hrs to fix

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

            if(dropon.previousSibling != element) {
              var oldParentNode = element.parentNode;
              element.style.visibility = "hidden"; // fix gecko rendering
              dropon.parentNode.insertBefore(element, dropon);
              if(dropon.parentNode!=oldParentNode)
      Severity: Major
      Found in app/assets/javascripts/standard/dragdrop.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/standard/dragdrop.js on lines 770..777

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

      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(nextElement != element) {
              var oldParentNode = element.parentNode;
              element.style.visibility = "hidden"; // fix gecko rendering
              dropon.parentNode.insertBefore(element, nextElement);
              if(dropon.parentNode!=oldParentNode)
      Severity: Major
      Found in app/assets/javascripts/standard/dragdrop.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/standard/dragdrop.js on lines 759..766

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

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

        Element.Methods.getStyle = function(element, style) {
          element = $(element);
          style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
          var value = element.style[style];
          if (!value && element.currentStyle) value = element.currentStyle[style];
      Severity: Minor
      Found in app/assets/javascripts/standard/prototype.js - About 3 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 addMethods has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Element.addMethods = function(methods) {
        var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
      
        if (!methods) {
          Object.extend(Form, Form.Methods);
      Severity: Major
      Found in app/assets/javascripts/standard/prototype.js - About 3 hrs to fix

        Function _attributeTranslations has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Element._attributeTranslations = (function(){
        
            var classProp = 'className',
                forProp = 'for',
                el = document.createElement('div');
        Severity: Major
        Found in app/assets/javascripts/standard/prototype.js - About 3 hrs to fix

          Function update has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            update: (function(){
          
              var SELECT_ELEMENT_INNERHTML_BUGGY = (function(){
                var el = document.createElement("select"),
                    isBuggy = true;
          Severity: Major
          Found in app/assets/javascripts/standard/prototype.js - About 2 hrs to fix

            Function Enumerable has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            var Enumerable = (function() {
              function each(iterator, context) {
                var index = 0;
                try {
                  this._each(function(value) {
            Severity: Minor
            Found in app/assets/javascripts/standard/prototype.js - 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

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

              function min(iterator, context) {
                iterator = iterator || Prototype.K;
                var result;
                this.each(function(value, index) {
                  value = iterator.call(context, value, index);
            Severity: Major
            Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/standard/prototype.js on lines 933..942

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

            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

              function max(iterator, context) {
                iterator = iterator || Prototype.K;
                var result;
                this.each(function(value, index) {
                  value = iterator.call(context, value, index);
            Severity: Major
            Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 2 hrs to fix
            app/assets/javascripts/standard/prototype.js on lines 944..953

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

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

            Element.extend = (function() {
            
              function checkDeficiency(tagName) {
                if (typeof window.Element != 'undefined') {
                  var proto = window.Element.prototype;
            Severity: Minor
            Found in app/assets/javascripts/standard/prototype.js - 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 _attributeTranslations has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

              Element._attributeTranslations = (function(){
            
                var classProp = 'className',
                    forProp = 'for',
                    el = document.createElement('div');
            Severity: Minor
            Found in app/assets/javascripts/standard/prototype.js - 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 Grow has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              InPlaceEditor has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              Ajax.InPlaceEditor = Class.create({
                initialize: function(element, url, options) {
                  this.url = url;
                  this.element = element = $(element);
                  this.prepareOptions();
              Severity: Minor
              Found in app/assets/javascripts/standard/controls.js - About 2 hrs to fix

                Method news_feed has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                  def news_feed(user, limit=10)
                    feed = []
                    # Get electricity reading data
                    user.electricity_readings.limit(limit).order("taken_on DESC").where(:automatic => false).each do |reading|
                      feed << {:image => 'electricity.png', 
                Severity: Minor
                Found in app/helpers/profile_helper.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

                Method news_feed has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def news_feed(user, limit=10)
                    feed = []
                    # Get electricity reading data
                    user.electricity_readings.limit(limit).order("taken_on DESC").where(:automatic => false).each do |reading|
                      feed << {:image => 'electricity.png', 
                Severity: Major
                Found in app/helpers/profile_helper.rb - About 2 hrs to fix

                  Base has 23 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  Autocompleter.Base = Class.create({
                    baseInitialize: function(element, update, options) {
                      element          = $(element);
                      this.element     = element;
                      this.update      = $(update);
                  Severity: Minor
                  Found in app/assets/javascripts/standard/controls.js - About 2 hrs to fix

                    Function parseColor has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    String.prototype.parseColor = function() {
                      var color = '#';
                      if (this.slice(0,4) == 'rgb(') {
                        var cols = this.slice(4,this.length-1).split(',');
                        var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
                    Severity: Minor
                    Found in app/assets/javascripts/standard/effects.js - 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

                    Severity
                    Category
                    Status
                    Source
                    Language