Floppy/carbon-diet

View on GitHub

Showing 215 of 292 total issues

Method emissions has a Cognitive Complexity of 7 (exceeds 5 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 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

Method send_invitations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def send_invitations
    unless verify_recaptcha
      flash[:notice] = 'Incorrect word verification! Please try again.'
      params[:recaptcha_response_field] = ""
      render :action => 'invite'
Severity: Minor
Found in app/controllers/friends_controller.rb - 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

Method do_change has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def do_change
    if params[:user][:code].blank? 
      flash[:notice] = "No password change code provided!"
    else
      user = User.find_by_password_change_code(params[:user][:code])
Severity: Minor
Found in app/controllers/user_controller.rb - 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

Method emissions has a Cognitive Complexity of 7 (exceeds 5 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 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

Method authenticate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.authenticate(login, passwd)
    user = User.where(:login => login.downcase).first
    if user.nil?
      user = User.where(:email => login).first
    end
Severity: Minor
Found in app/models/user.rb - 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

Method has_enough_data_to_analyse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def has_enough_data_to_analyse
    electricity_accounts.each do |account|
      return true if account.has_enough_data_to_analyse
    end
    gas_accounts.each do |account|
Severity: Minor
Found in app/models/user.rb - 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

Avoid too many return statements within this function.
Open

                        return diff == 0;
Severity: Major
Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        if (!responder) return element;
    Severity: Major
    Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return 0;
      Severity: Major
      Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                                return ( diff % first == 0 && diff / first >= 0 );
        Severity: Major
        Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return element;
          Severity: Major
          Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return $(document.body);
            Severity: Major
            Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return value;
              Severity: Major
              Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                        return true;
                Severity: Major
                Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return true
                  Severity: Major
                  Found in app/models/user.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return false
                    Severity: Major
                    Found in app/models/user.rb - About 30 mins to fix

                      Function initDrag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        initDrag: function(event) {
                          if(!Object.isUndefined(Draggable._dragging[this.element]) &&
                            Draggable._dragging[this.element]) return;
                          if(Event.isLeftClick(event)) {
                            // abort on form elements, fixes a Firefox issue
                      Severity: Minor
                      Found in app/assets/javascripts/standard/dragdrop.js - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        initialize: function(element) {
                          this.element = $(element);
                          if (!this.element) throw(Effect._elementDoesNotExistError);
                          var options = Object.extend({
                            style: { }
                      Severity: Minor
                      Found in app/assets/javascripts/standard/effects.js - About 25 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 next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        next: function(element, expression, index) {
                          element = $(element);
                          if (Object.isNumber(expression)) index = expression, expression = false;
                          if (!Object.isNumber(index)) index = 0;
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/standard/prototype.js - About 25 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 createForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        createForm: function() {
                          var ipe = this;
                          function addText(mode, condition) {
                            var text = ipe.options['text' + mode + 'Controls'];
                            if (!text || condition === false) return;
                      Severity: Minor
                      Found in app/assets/javascripts/standard/controls.js - About 25 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