Floppy/carbon-diet

View on GitHub

Showing 215 of 292 total issues

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

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

  def calculate_total_over_period(days)
    return { :total => 0, :days => 0, :perday => 0, :perannum => 0 } if self.empty? 
    total = 0.0
    dayscounted = 0
    firstday = Date::today - days
Severity: Minor
Found in app/models/emission_array.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

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

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

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 ( !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 (/\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

        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((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 (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

              Function showPageByHref has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  showPageByHref: function(href, args, method, replace, cb)
              Severity: Minor
              Found in public/iui/iui.js - About 35 mins to fix

                Function showPageByHrefExt has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    showPageByHrefExt: function(href, args, method, replace, cb)
                Severity: Minor
                Found in public/iui/iui.js - About 35 mins to fix

                  Function initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                        function(init, element, eventName, selector, callback) {
                  Severity: Minor
                  Found in app/assets/javascripts/rails.js - About 35 mins to fix

                    Function PSEUDO has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            PSEUDO: function(match, curLoop, inplace, result, not){
                    Severity: Minor
                    Found in app/assets/javascripts/standard/prototype.js - About 35 mins to fix

                      Function slide1 has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function slide1(fromPage, toPage, backwards, axis, cb)
                      Severity: Minor
                      Found in public/iui/iui.js - About 35 mins to fix

                        Method wml_select has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def wml_select(name, values, default=nil, value_func = nil, value_text = nil)
                        Severity: Minor
                        Found in app/helpers/wml_helper.rb - About 35 mins to fix

                          Function baseInitialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            baseInitialize: function(element, update, options) {
                              element          = $(element);
                              this.element     = element;
                              this.update      = $(update);
                              this.hasFocus    = false;
                          Severity: Minor
                          Found in app/assets/javascripts/standard/controls.js - About 35 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 onKeyPress has a Cognitive Complexity of 7 (exceeds 5 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 35 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            initialize: function(element, url, options) {
                              this.url = url;
                              this.element = element = $(element);
                              this.prepareOptions();
                              this._controls = { };
                          Severity: Minor
                          Found in app/assets/javascripts/standard/controls.js - About 35 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 request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            request: function(form, options) {
                              form = $(form), options = Object.clone(options || { });
                          
                              var params = options.parameters, action = form.readAttribute('action') || '';
                              if (action.blank()) action = window.location.href;
                          Severity: Minor
                          Found in app/assets/javascripts/standard/prototype.js - About 35 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

                          Severity
                          Category
                          Status
                          Source
                          Language