vegantech/sims

View on GitHub

Showing 433 of 433 total issues

Function formatResult has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    formatResult: function(result) {
        var type = IEConsole.getType(result);
        try {
            // DOM Element
            if (type == 'DOMElement') {
Severity: Minor
Found in app/assets/javascripts/ie-console.js - About 4 hrs 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 Position has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Position = (function() {
    // Resolve a string identifier to an object
    // ========================================
    function resolveObject(s) {
        if (document.getElementById && document.getElementById(s)!=null) {
Severity: Major
Found in app/assets/javascripts/popup.js - About 4 hrs to fix

    Function Sort has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    })();var Sort = (function(){
        var sort = {};
        sort.AlphaNumeric = function(a,b) {
            if (a==b) { return 0; }
            if (a<b) { return -1; }
    Severity: Minor
    Found in app/assets/javascripts/popup.js - About 4 hrs 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 updateTable has 105 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            o.updateTable = function(noCallback) {
    
                    if(o.timerSet) {
                            var d = new Date(o.date);
                            d.setDate( Math.min(d.getDate()+o.dayInc, datePicker.getDaysPerMonth(d.getMonth()+o.monthInc,d.getFullYear()+o.yearInc)) );
    Severity: Major
    Found in app/assets/javascripts/datepicker.js - About 4 hrs to fix

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

          screen.getScrollTop = function() {
              if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) {
                  return document.documentElement.scrollTop;
              }
              if (document.body && defined(document.body.scrollTop)) {
      Severity: Major
      Found in app/assets/javascripts/popup.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/popup.js on lines 466..474

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

      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

          screen.getScrollLeft = function() {
              if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) {
                  return document.documentElement.scrollLeft;
              }
              if (document.body && defined(document.body.scrollLeft)) {
      Severity: Major
      Found in app/assets/javascripts/popup.js and 1 other location - About 4 hrs to fix
      app/assets/javascripts/popup.js on lines 454..462

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

      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

      File spellChecker.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      ////////////////////////////////////////////////////
      // spellChecker.js
      //
      // spellChecker object
      //
      Severity: Minor
      Found in app/assets/javascripts/spellerpages/spellChecker.js - About 4 hrs to fix

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

                        if( obj.attachEvent ) {
                                obj["e"+type+fn] = fn;
                                obj[type+fn] = function(){obj["e"+type+fn]( window.event );};
                                obj.attachEvent( "on"+type, obj[type+fn] );
                        } else {
        Severity: Major
        Found in app/assets/javascripts/tablesort.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/datepicker.js on lines 1208..1214

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

        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

                        if( obj.attachEvent ) {
                                obj["e"+type+fn] = fn;
                                obj[type+fn] = function(){obj["e"+type+fn]( window.event );};
                                obj.attachEvent( "on"+type, obj[type+fn] );
                        } else {
        Severity: Major
        Found in app/assets/javascripts/datepicker.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/tablesort.js on lines 51..57

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

        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

        function setSuggestedText() {
            var slct = this.suggestionList;
            var txt = this.replacementText;
            var str = "";
            if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) {
        Severity: Major
        Found in app/assets/javascripts/spellerpages/controlWindow.js and 1 other location - About 3 hrs to fix
        public/speller/controlWindow.js on lines 33..41

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

        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

        function setSuggestedText() {
            var slct = this.suggestionList;
            var txt = this.replacementText;
            var str = "";
            if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) {
        Severity: Major
        Found in public/speller/controlWindow.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/spellerpages/controlWindow.js on lines 33..41

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

        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 group_by_cluster_and_objective has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.group_by_cluster_and_objective(params ={})
            #This will work better
        
            #refactor this to use recommended monitors?
            probes = find(:all, :order =>"active desc, custom, position", :include => [{:intervention_definitions=>{:intervention_cluster=>:objective_definition}},:intervention_probe_assignments, :recommended_monitors])
        Severity: Minor
        Found in app/models/probe_definition.rb - About 3 hrs 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 setPosition has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        Popup.prototype.setPosition = function() {
            if (this.position!=null) {
                var m = this.position.match(/^(\S+)\s+(\S+)/); 
                if (m!=null && m.length==3) {
                    var v = m[1];
        Severity: Minor
        Found in app/assets/javascripts/popup.js - About 3 hrs 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 writeBody has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function writeBody() {
            var d = window.document;
            var is_html = false;
        
            d.open();
        Severity: Minor
        Found in app/assets/javascripts/spellerpages/wordWindow.js - About 3 hrs 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 writeBody has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function writeBody() {
            var d = window.document;
            var is_html = false;
        
            d.open();
        Severity: Minor
        Found in public/speller/wordWindow.js - About 3 hrs 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

        File spellChecker.js has 329 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        ////////////////////////////////////////////////////
        // spellChecker.js
        //
        // spellChecker object
        //
        Severity: Minor
        Found in public/speller/spellChecker.js - About 3 hrs to fix

          Class User has 30 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class User < ActiveRecord::Base
            # Include default devise modules. Others available are:
            # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
            devise :database_authenticatable, :omniauthable, :recoverable#, :registerable
          #        :recoverable, :rememberable, :trackable, :validatable
          Severity: Minor
          Found in app/models/user.rb - About 3 hrs to fix

            Function initSort has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    initSort: function(noCallback, ident) {
                            var thNode      = fdTableSort.thNode;
                            var tableElem   = document.getElementById(fdTableSort.tableId);
            
                            if(!(fdTableSort.tableId in fdTableSort.tableCache)) { fdTableSort.prepareTableData(document.getElementById(fdTableSort.tableId)); };
            Severity: Major
            Found in app/assets/javascripts/tablesort.js - About 3 hrs to fix

              Identical blocks of code found in 2 locations. 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: Major
              Found in public/speller/wordWindow.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/spellerpages/wordWindow.js on lines 64..76

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

              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

              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: Major
              Found in app/assets/javascripts/spellerpages/wordWindow.js and 1 other location - About 3 hrs to fix
              public/speller/wordWindow.js on lines 64..76

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

              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