Floppy/carbon-diet

View on GitHub

Showing 215 of 292 total issues

Method auth has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def auth
    # Find user and check password
    result = User.authenticate(params[:user][:login], params[:user][:password])
    if result == :no_such_user
      if mobile?
Severity: Minor
Found in app/controllers/user_controller.rb - About 1 hr to fix

    Function setOptions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      setOptions: function(options) {
        this.options = Object.extend({
          choices: 10,
          partialSearch: true,
          partialChars: 2,
    Severity: Minor
    Found in app/assets/javascripts/standard/controls.js - About 1 hr to fix

      Function _begin has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _begin: function() {
            if (this._prepared) return;
      
            var element = this.element;
            if (isDisplayed(element)) {
      Severity: Minor
      Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

        Function select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          select: function(element, value) {
            if (Object.isUndefined(value))
              return this[element.type == 'select-one' ?
                'selectOne' : 'selectMany'](element);
            else {
        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 setRequestHeaders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          setRequestHeaders: function() {
            var headers = {
              'X-Requested-With': 'XMLHttpRequest',
              'X-Prototype-Version': Prototype.Version,
              'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
        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 setStyle has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          setStyle: function(element, styles) {
            element = $(element);
            var elementStyle = element.style, match;
            if (Object.isString(styles)) {
              element.style.cssText += ';' + styles;
        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 getElementsByClassName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
          function iter(name) {
            return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
          }
        
        
        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

        Method amline_settings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def amline_settings(period)
            case period
            when 0..90
              avg_period = 3
            when 91..365
        Severity: Minor
        Found in app/controllers/reports_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

        Method wml_select has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def wml_select(name, values, default=nil, value_func = nil, value_text = nil)
            ivalue = values.index(default)
            wml = "<select name='#{name}'"
            wml << " ivalue='#{ivalue+1}'" if ivalue
            wml << ">"
        Severity: Minor
        Found in app/helpers/wml_helper.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

        Method currentcost has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def currentcost
            # Receives data from my currentcost daemon
            authenticate_with_http_basic do |username, password|
              # Authenticate
              result = User.authenticate(username, password)
        Severity: Minor
        Found in app/controllers/electricity_readings_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 baseInitialize has 39 lines of code (exceeds 25 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 1 hr to fix

          Function encode has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function encode(inputs)
              {
                  for (var i = 0; i < inputs.length; ++i)
                  {
                      log("input[" + i + "]: " + inputs[i].name + " = " + inputs[i].value);
          Severity: Minor
          Found in public/iui/iui.js - About 1 hr to fix

            Function showPage has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                showPage: function(page, backwards)
                {
                    if (page)
                    {
            //            if (window.iui_ext)    window.iui_ext.injectEventMethods(page);    // TG -- why was this comment left here??
            Severity: Minor
            Found in public/iui/iui.js - About 1 hr to fix

              Function setup has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                setup: function(){
                  function parseColor(color){
                    if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff';
                    color = color.parseColor();
                    return $R(0,2).map(function(i){
              Severity: Minor
              Found in app/assets/javascripts/standard/effects.js - About 1 hr to fix

                Function CHILD has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        CHILD: function(elem, match){
                            var type = match[1], node = elem;
                            switch (type) {
                                case 'only':
                                case 'first':
                Severity: Minor
                Found in app/assets/javascripts/standard/prototype.js - About 1 hr to fix

                  Function start has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    start: function(options) {
                      if (options && options.transition === false) options.transition = Effect.Transitions.linear;
                      this.options      = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
                      this.currentFrame = 0;
                      this.state        = 'idle';
                  Severity: Minor
                  Found in app/assets/javascripts/standard/effects.js - About 1 hr to fix

                    Function stopObserving has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

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

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

                        Function finishDrag has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Method import_from_partow_net_db has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.import_from_partow_net_db   
                              file = open("GlobalAirportDatabase.txt")          
                              # For each line in the file
                              file.each do |line|
                                # Split into data fields
                          Severity: Minor
                          Found in app/models/airport.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

                          Severity
                          Category
                          Status
                          Source
                          Language