vegantech/sims

View on GitHub

Showing 433 of 433 total issues

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

  def goal_in_range
    if goal.present? and self.probe_definition.present?
      if probe_definition.minimum_score.present? and goal < probe_definition.minimum_score
        errors.add(:goal, "below minimum") and return false
      end
Severity: Minor
Found in app/models/intervention_probe_assignment.rb and 1 other location - About 50 mins to fix
app/models/probe.rb on lines 41..51

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

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(mmE.tagName.toLowerCase() == "input") { mmE.value = m; }
                                else { o.setSelectIndex(mmE, m); /*mmE.selectedIndex = m - 1;*/ };
Severity: Minor
Found in app/assets/javascripts/datepicker.js and 1 other location - About 50 mins to fix
app/assets/javascripts/datepicker.js on lines 860..861

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

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(ddE.tagName.toLowerCase() == "input") { ddE.value = d; }
                                else { o.setSelectIndex(ddE, d); /*ddE.selectedIndex = d - 1;*/ };
Severity: Minor
Found in app/assets/javascripts/datepicker.js and 1 other location - About 50 mins to fix
app/assets/javascripts/datepicker.js on lines 863..864

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

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 deeply nested control flow statements.
Open

                    if( begin_idx == -1 ) break; 
Severity: Major
Found in public/speller/wordWindow.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                                    if(cd == dt) {
                                                            td.setAttribute("id", o.id + "-date-picker-hover");
                                                            cName.push("date-picker-hover");
                                                    };
    Severity: Major
    Found in app/assets/javascripts/datepicker.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                                      for(var cn = workArr[c][i].childNodes.length; cn--;) {
                                                              // Skip image nodes and links created by the filter script.
                                                              if(workArr[c][i].childNodes[cn].nodeType == 1 && (workArr[c][i].childNodes[cn].className == "fdFilterTrigger" || /img/i.test(workArr[c][i].childNodes[cn].nodeName))) {
                                                                      continue;
                                                              };
      Severity: Major
      Found in app/assets/javascripts/tablesort.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        for (j=0; j<o.length; j++) {
                            results[results.length] = o[j];
                        }
        Severity: Major
        Found in app/assets/javascripts/popup.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                                          if(showArrow) workArr[c][i].appendChild(span.cloneNode(false));
          Severity: Major
          Found in app/assets/javascripts/tablesort.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if(( i == text_idx && j >= idx ) || i > text_idx ) {
                                        var origSpell = this.wordWin.originalSpellings[i][j];
                                        if( origSpell == preReplSpell ) {
                                            this._setWordText ( i, j, origSpell, undefined );
                                        }
            Severity: Major
            Found in public/speller/spellChecker.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                              if(!showOnly) {
                                                                      fdTableSort.initSort(false, true);
                                                              } else {
                                                                      fdTableSort.addThNode();
                                                              };
              Severity: Major
              Found in app/assets/javascripts/tablesort.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                                if(o.dateSet != null && o.dateSet.getDate() == dt && o.dateSet.getMonth() == tdm && o.dateSet.getFullYear() == tdy) {
                                                                        cName.push("date-picker-selected-date");
                                                                };
                Severity: Major
                Found in app/assets/javascripts/datepicker.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if(( i == text_idx && j >= idx ) || i > text_idx ) {
                                              var origSpell = this.wordWin.originalSpellings[i][j];
                                              if( origSpell == preReplSpell ) {
                                                  this._setWordText ( i, j, origSpell, undefined );
                                              }
                  Severity: Major
                  Found in app/assets/javascripts/spellerpages/spellChecker.js - About 45 mins to fix

                    Function totalPreviousWords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function totalPreviousWords( textIndex, wordIndex ) {
                        var total_words = 0;
                        for( var i = 0; i <= textIndex; i++ ) {
                            for( var j = 0; j < this.totalWords( i ); j++ ) {
                                if( i == textIndex && j == wordIndex ) {
                    Severity: Minor
                    Found in public/speller/wordWindow.js - 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

                    Avoid deeply nested control flow statements.
                    Open

                                            if(( i == text_idx && j >= idx ) || i > text_idx ) {
                                                var origSpell = this.wordWin.originalSpellings[i][j];
                                                if( origSpell == preReplSpell ) {
                                                    this.wordFlags[i][j] = undefined; 
                                                }
                    Severity: Major
                    Found in app/assets/javascripts/spellerpages/spellChecker.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                                      if(dt == todayD && tdm == todayM && tdy == todayY) {
                                                                              cName.push("date-picker-today");
                                                                      };
                      Severity: Major
                      Found in app/assets/javascripts/datepicker.js - About 45 mins to fix

                        Function totalPreviousWords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function totalPreviousWords( textIndex, wordIndex ) {
                            var total_words = 0;
                            for( var i = 0; i <= textIndex; i++ ) {
                                for( var j = 0; j < this.totalWords( i ); j++ ) {
                                    if( i == textIndex && j == wordIndex ) {
                        Severity: Minor
                        Found in app/assets/javascripts/spellerpages/wordWindow.js - 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

                        Avoid deeply nested control flow statements.
                        Open

                                                if(( i == text_idx && j >= idx ) || i > text_idx ) {
                                                    var origSpell = this.wordWin.originalSpellings[i][j];
                                                    if( origSpell == preReplSpell ) {
                                                        this.wordFlags[i][j] = undefined; 
                                                    }
                        Severity: Major
                        Found in public/speller/spellChecker.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                          if( e.ctrlKey ) {
                                                                  d = new Date( o.date );
                                                                  d.setDate( Math.min(d.getDate(), datePicker.getDaysPerMonth(d.getMonth(),d.getFullYear() - 1)) );
                                                                  d.setFullYear( d.getFullYear() - 1 );
                                                          } else {
                          Severity: Major
                          Found in app/assets/javascripts/datepicker.js - About 45 mins to fix

                            Function show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            Popup.show = function(divObject, referenceObject, position, options, modal) {
                                var popup;
                                if (defined(divObject)) { 
                                    popup = new Popup(divObject);
                                }
                            Severity: Minor
                            Found in app/assets/javascripts/popup.js - 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

                            Avoid deeply nested control flow statements.
                            Open

                                        else if (isObject(o)) {
                                            for (j in o) {
                                                results[results.length] = o[j];
                                            }
                                        }
                            Severity: Major
                            Found in app/assets/javascripts/popup.js - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language