Floppy/carbon-diet

View on GitHub

Showing 292 of 292 total issues

Function ajax has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    ajax: function(url, args, method, cb)
    {
        var xhr = new XMLHttpRequest();
        method = method ? method.toUpperCase() : "GET";
        if (args && method == "GET")
Severity: Minor
Found in public/iui/iui.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

            if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
                submit !== false && (!submit || key == submit) && (submitted = true)))) {
              result = accumulator(result, key, value);
            }
    Severity: Critical
    Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if ( match[1] == "nth" ) {
                      var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
                          match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
                          !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
      
      
      Severity: Critical
      Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

        Function request has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          request: function(url) {
            this.url = url;
            this.method = this.options.method;
            var params = Object.isString(this.options.parameters) ?
                  this.options.parameters :
        Severity: Minor
        Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

          Function onKeyPress has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            onKeyPress: function(event) {
              if(this.active)
                switch(event.keyCode) {
                 case Event.KEY_TAB:
                 case Event.KEY_RETURN:
          Severity: Minor
          Found in app/assets/javascripts/standard/controls.js - About 1 hr to fix

            Function selector has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  selector: function(instance) {
                    var ret       = []; // Beginning matches
                    var partial   = []; // Inside matches
                    var entry     = instance.getToken();
                    var count     = 0;
            Severity: Minor
            Found in app/assets/javascripts/standard/controls.js - About 1 hr to fix

              Function draw has 32 lines of code (exceeds 25 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

                Method emissions has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def emissions
                    # Initialise result array
                    emission_array = EmissionArray.new
                    # Create "last reading" trackers
                    last_m3 = 0;
                Severity: Minor
                Found in app/models/gas_account.rb - About 1 hr to fix

                  Function respondToReadyState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    respondToReadyState: function(readyState) {
                      var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
                  
                      if (state == 'Complete') {
                        try {
                  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 updateChoices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    updateChoices: function(choices) {
                      if(!this.changed && this.hasFocus) {
                        this.update.innerHTML = choices;
                        Element.cleanWhitespace(this.update);
                        Element.cleanWhitespace(this.update.down());
                  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 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    Element.Methods.setOpacity = function(element, value) {
                      function stripAlpha(filter){
                        return filter.replace(/alpha\([^\)]*\)/gi,'');
                      }
                      element = $(element);
                  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 createEditField has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    createEditField: function() {
                      var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
                      var fld;
                      if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
                        fld = document.createElement('input');
                  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

                  Method edit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def edit
                      if request.post?      
                        if verify_recaptcha(@group)
                          @group.update_attributes(params[:group])
                          if @group.owner.nil?
                  Severity: Minor
                  Found in app/controllers/groups_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 spbhCB has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function spbhCB(xhr) 
                          {
                              log("xhr.readyState = " + xhr.readyState);
                              if (xhr.readyState == 4)
                              {
                  Severity: Minor
                  Found in public/iui/iui.js - About 1 hr to fix

                    Function slide1 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function slide1(fromPage, toPage, backwards, axis, cb)
                    {
                        if (axis == "y")
                            (backwards ? fromPage : toPage).style.top = "100%";
                        else
                    Severity: Minor
                    Found in public/iui/iui.js - About 1 hr to fix

                      Method emissions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def emissions
                          # Initialise result array
                          emissiondata = EmissionArray.new
                          # Analyse each purchase
                          purchases = vehicle_fuel_purchases.order("purchased_on")
                      Severity: Minor
                      Found in app/models/vehicle.rb - About 1 hr to fix

                        Method post has 30 lines of code (exceeds 25 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 1 hr to fix

                          Function Selector has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          Prototype.Selector = (function() {
                          
                            function select() {
                              throw new Error('Method "Prototype.Selector.select" must be defined.');
                            }
                          Severity: Minor
                          Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

                            Function updateDrag has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              updateDrag: function(event, pointer) {
                                if(!this.dragging) this.startDrag(event);
                            
                                if(!this.options.quiet){
                                  Position.prepare();
                            Severity: Minor
                            Found in app/assets/javascripts/standard/dragdrop.js - About 1 hr to fix

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

                              Form.Element.Observer = Class.create(Abstract.TimedObserver, {
                                getValue: function() {
                                  return Form.Element.getValue(this.element);
                                }
                              });
                              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 5240..5244

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

                              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