Floppy/carbon-diet

View on GitHub

Showing 292 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 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

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

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

    if self.current and not emissiondata.empty?
      co2_per_day = emissiondata.last[:co2_per_day]
      days = Date::today - last_date
      emissiondata << { :start => last_date, 
                        :end => Date::today,
Severity: Minor
Found in app/models/electricity_account.rb and 1 other location - About 35 mins to fix
app/models/gas_account.rb on lines 59..67

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

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 self.current and not emission_array.empty?
      co2_per_day = emission_array.last[:co2_per_day]
      days = Date::today - last_date
      emission_array << { :start => last_date, 
                          :end => Date::today,
Severity: Minor
Found in app/models/gas_account.rb and 1 other location - About 35 mins to fix
app/models/electricity_account.rb on lines 63..71

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

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

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

        running_avg.each do |datum|
          unless datum.nil?
            if total[:values][offset].nil?
              total[:values][offset] = 0
            end
Severity: Minor
Found in app/controllers/reports_controller.rb and 1 other location - About 30 mins to fix
app/controllers/reports_controller.rb on lines 125..133

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

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

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

        running_avg.each do |datum|
          unless datum.nil?
            if total[:values][offset].nil?
              total[:values][offset] = 0
            end
Severity: Minor
Found in app/controllers/reports_controller.rb and 1 other location - About 30 mins to fix
app/controllers/reports_controller.rb on lines 183..191

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

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

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

            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 true;
            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 element;
                Severity: Major
                Found in app/assets/javascripts/standard/prototype.js - About 30 mins to fix

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

                      if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update);
                  Severity: Minor
                  Found in app/assets/javascripts/standard/controls.js and 1 other location - About 30 mins to fix
                  app/assets/javascripts/standard/controls.js on lines 95..95

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

                  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

                        var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
                         args.join(' ').split(' ');
                  Severity: Minor
                  Found in app/assets/javascripts/standard/prototype.js and 1 other location - About 30 mins to fix
                  app/assets/javascripts/standard/prototype.js on lines 3355..3356

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

                  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