Floppy/carbon-diet

View on GitHub

Showing 292 of 292 total issues

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

    if (!this.options.sync)
      Effect.Queues.get(Object.isString(this.options.queue) ?
        'global' : this.options.queue.scope).add(this);
Severity: Major
Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
app/assets/javascripts/standard/effects.js on lines 291..293

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

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 options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.none
Severity: Major
Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
app/assets/javascripts/standard/effects.js on lines 753..758

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

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 options = Object.extend({
    direction: 'center',
    moveTransition: Effect.Transitions.sinoidal,
    scaleTransition: Effect.Transitions.sinoidal,
    opacityTransition: Effect.Transitions.full
Severity: Major
Found in app/assets/javascripts/standard/effects.js and 1 other location - About 1 hr to fix
app/assets/javascripts/standard/effects.js on lines 827..832

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

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

Method show has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    respond_to do |format|
      format.html {
        @comments = @group.comments
        # Generate league table
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

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

        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

        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

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

            enterHover: function(e) {
              if (this.options.hoverClassName)
                this.element.addClassName(this.options.hoverClassName);
              if (this._saving) return;
              this.triggerCallback('onEnterHover');
          Severity: Major
          Found in app/assets/javascripts/standard/controls.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/standard/controls.js on lines 662..667

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

          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

            leaveHover: function(e) {
              if (this.options.hoverClassName)
                this.element.removeClassName(this.options.hoverClassName);
              if (this._saving) return;
              this.triggerCallback('onLeaveHover');
          Severity: Major
          Found in app/assets/javascripts/standard/controls.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/standard/controls.js on lines 602..607

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

          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

          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

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

                  'border-box-width': function(element) {
                    if (!this._preComputing) this._begin();
                    var width = element.offsetWidth;
                    if (!this._preComputing) this._end();
                    return width;
            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 3436..3441

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

            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

                  'border-box-height': function(element) {
                    if (!this._preComputing) this._begin();
                    var height = element.offsetHeight;
                    if (!this._preComputing) this._end();
                    return height;
            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 3443..3448

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

            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