NUBIC/surveyor

View on GitHub

Showing 658 of 658 total issues

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

            if (!event.metaKey && !event.ctrlKey) {
                selectee.$element.removeClass("ui-selected");
                selectee.selected = false;
                selectee.$element.addClass("ui-unselecting");
                selectee.unselecting = true;
Severity: Major
Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js and 1 other location - About 2 hrs to fix
lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js on lines 11234..11244

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

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(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
                (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
            }
Severity: Major
Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js and 1 other location - About 2 hrs to fix
lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js on lines 6649..6651

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

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(inst.snapElements[i].snapping) {
                    (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
                }
Severity: Major
Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js and 1 other location - About 2 hrs to fix
lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js on lines 6696..6698

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

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 explode has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.effects.effect.explode = function( o, done ) {

    var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
        cells = rows,
        el = $( this ),
Severity: Major
Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

    Function CHILD has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            "CHILD": function( type, what, argument, first, last ) {
                var simple = type.slice( 0, 3 ) !== "nth",
                    forward = type.slice( -4 ) !== "last",
                    ofType = what === "of-type";
    
    
    Severity: Major
    Found in lib/assets/javascripts/surveyor/jquery-1.9.0.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                              if ( forward && useCache ) {
                                  // Seek `elem` from a previously-cached index
                                  outerCache = parent[ expando ] || (parent[ expando ] = {});
                                  cache = outerCache[ type ] || [];
                                  nodeIndex = cache[0] === dirruns && cache[1];
      Severity: Critical
      Found in lib/assets/javascripts/surveyor/jquery-1.9.0.js - About 2 hrs to fix

        Function init has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            init: function( selector, context, rootjQuery ) {
                var match, elem;
        
                // HANDLE: $(""), $(null), $(undefined), $(false)
                if ( !selector ) {
        Severity: Major
        Found in lib/assets/javascripts/surveyor/jquery-1.9.0.js - About 2 hrs to fix

          Function keydown has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  keydown: function( event ) {
                      /*jshint maxcomplexity:25*/
                      var allowed, curVal, newVal, step,
                          index = $( event.target ).data( "ui-slider-handle-index" );
          
          
          Severity: Major
          Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

            Method update_from_ui_hash has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                  def update_from_ui_hash(ui_hash)
                    transaction do
                      ui_hash.each do |ord, response_hash|
                        api_id = response_hash['api_id']
                        fail "api_id missing from response #{ord}" unless api_id
            Severity: Minor
            Found in lib/surveyor/models/response_set_methods.rb - About 2 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

            Method method_missing has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                def method_missing(missing_method, *args, &block)
                  method_name, reference_identifier = missing_method.to_s.split("_", 2)
                  type = full(method_name)
                  Surveyor::Parser.raise_error( "\"#{type}\" is not a surveyor method." )if !%w(survey survey_translation survey_section question_group question dependency dependency_condition answer validation validation_condition).include?(type)
            
            
            Severity: Minor
            Found in lib/surveyor/parser.rb - About 2 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 createWrapper has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                createWrapper: function( element ) {
            
                    // if the element is already wrapped, return it
                    if ( element.parent().is( ".ui-effects-wrapper" )) {
                        return element.parent();
            Severity: Major
            Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

              Function _generateMonthYearHeader has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
                          secondary, monthNames, monthNamesShort) {
              
                      var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
                          changeMonth = this._get(inst, "changeMonth"),
              Severity: Major
              Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                Function _mouseStart has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _mouseStart: function(event) {
                        var that = this,
                            options = this.options;
                
                        this.opos = [event.pageX, event.pageY];
                Severity: Major
                Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                  Function _generatePosition has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _generatePosition: function(event) {
                  
                          var containment, co, top, left,
                              o = this.options,
                              scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
                  Severity: Major
                  Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                    Function parse has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        parse: function( red, green, blue, alpha ) {
                            if ( red === undefined ) {
                                this._rgba = [ null, null, null, null ];
                                return this;
                            }
                    Severity: Major
                    Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                      Method update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def update
                            question_ids_for_dependencies = (params[:r] || []).map{|k,v| v["question_id"] }.compact.uniq
                            saved = load_and_update_response_set_with_retries
                      
                            return redirect_with_message(surveyor_finish, :notice, t('surveyor.completed_survey')) if saved && params[:finish]
                      Severity: Minor
                      Found in lib/surveyor/surveyor_controller_methods.rb - About 2 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 _processTabs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          _processTabs: function() {
                              var that = this;
                      
                              this.tablist = this._getList()
                                  .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
                      Severity: Major
                      Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                        Function keydown has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                    keydown: function( event ) {
                                        /*jshint maxcomplexity:15*/
                                        if ( this.element.prop( "readOnly" ) ) {
                                            suppressKeyPress = true;
                                            suppressInput = true;
                        Severity: Major
                        Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

                          Function _refreshValue has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              _refreshValue: function() {
                                  var lastValPercent, valPercent, value, valueMin, valueMax,
                                      oRange = this.options.range,
                                      o = this.options,
                                      that = this,
                          Severity: Major
                          Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js - About 2 hrs to fix

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

                                                if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
                            Severity: Major
                            Found in lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js and 1 other location - About 2 hrs to fix
                            lib/assets/javascripts/surveyor/jquery-ui-1.10.0.custom.js on lines 12675..12675

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

                            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