drhenner/ror_ecommerce

View on GitHub
app/assets/javascripts/zepto.js

Summary

Maintainability
F
2 wks
Test Coverage

Function Zepto has a Cognitive Complexity of 301 (exceeds 5 allowed). Consider refactoring.
Open

var Zepto = (function() {
  var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
    document = window.document,
    elementDisplay = {}, classCache = {},
    getComputedStyle = document.defaultView.getComputedStyle,
Severity: Minor
Found in app/assets/javascripts/zepto.js - About 6 days 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 zepto.js has 1530 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* Zepto v1.0-1-ga3cab6c - polyfill zepto detect event ajax form fx - zeptojs.com/license */


;(function(undefined){
  if (String.prototype.trim === undefined) // fix for iOS 3.2
Severity: Major
Found in app/assets/javascripts/zepto.js - About 4 days to fix

    Function Zepto has 647 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var Zepto = (function() {
      var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
        document = window.document,
        elementDisplay = {}, classCache = {},
        getComputedStyle = document.defaultView.getComputedStyle,
    Severity: Major
    Found in app/assets/javascripts/zepto.js - About 3 days to fix

      Function ajax has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        $.ajax = function(options){
          var settings = $.extend({}, options || {})
          for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]
      
          ajaxStart(settings)
      Severity: Major
      Found in app/assets/javascripts/zepto.js - About 2 hrs to fix

        Function anim has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          $.fn.anim = function(properties, duration, ease, callback){
            var key, cssValues = {}, cssProperties, transforms = '',
                that = this, wrappedCallback, endEvent = $.fx.transitionEnd
        
            if (duration === undefined) duration = 0.4
        Severity: Minor
        Found in app/assets/javascripts/zepto.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                if (this.nodeName.toLowerCase() != 'fieldset' &&
                  !this.disabled && type != 'submit' && type != 'reset' && type != 'button' &&
                  ((type != 'radio' && type != 'checkbox') || this.checked))
                  result.push({
                    name: el.attr('name'),
          Severity: Critical
          Found in app/assets/javascripts/zepto.js - About 1 hr to fix

            Function detect has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function detect(ua){
                var os = this.os = {}, browser = this.browser = {},
                  webkit = ua.match(/WebKit\/([\d.]+)/),
                  android = ua.match(/(Android)\s+([\d.]+)/),
                  ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
            Severity: Minor
            Found in app/assets/javascripts/zepto.js - About 1 hr to fix

              Function ajaxJSONP has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                $.ajaxJSONP = function(options){
                  if (!('type' in options)) return $.ajax(options)
              
                  var callbackName = 'jsonp' + (++jsonpID),
                    script = document.createElement('script'),
              Severity: Minor
              Found in app/assets/javascripts/zepto.js - About 1 hr to fix

                Function add has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function add(element, events, fn, selector, getDelegate, capture){
                Severity: Minor
                Found in app/assets/javascripts/zepto.js - About 45 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) {
                            dataType = dataType || mimeToDataType(xhr.getResponseHeader('content-type'))
                            result = xhr.responseText
                  
                            try {
                  Severity: Major
                  Found in app/assets/javascripts/zepto.js - About 40 mins to fix

                    Function anim has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function anim(el, speed, opacity, scale, callback) {
                    Severity: Minor
                    Found in app/assets/javascripts/zepto.js - About 35 mins to fix

                      Function remove has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        function remove(element, events, fn, selector, capture){
                      Severity: Minor
                      Found in app/assets/javascripts/zepto.js - About 35 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return zepto.Z(dom, selector)
                        Severity: Major
                        Found in app/assets/javascripts/zepto.js - About 30 mins to fix

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

                            $.fn.on = function(event, selector, callback){
                              return !selector || $.isFunction(selector) ?
                                this.bind(event, selector || callback) : this.delegate(selector, event, callback)
                            }
                          Severity: Major
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/zepto.js on lines 1055..1058

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

                          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

                            $.fn.off = function(event, selector, callback){
                              return !selector || $.isFunction(selector) ?
                                this.unbind(event, selector || callback) : this.undelegate(selector, event, callback)
                            }
                          Severity: Major
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 1 hr to fix
                          app/assets/javascripts/zepto.js on lines 1051..1054

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

                          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

                            $.fn.live = function(event, callback){
                              $(document.body).delegate(this.selector, event, callback)
                              return this
                            }
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 45 mins to fix
                          app/assets/javascripts/zepto.js on lines 1046..1049

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

                          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

                                (_base = $.fn)[_name = "inner" + Dimension] || (_base[_name] = function(includeMargin) {
                                  return ioDim(this, Dimension, dimension, false, includeMargin);
                                });
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 45 mins to fix
                          app/assets/javascripts/zepto.js on lines 1869..1871

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

                          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

                            $.fn.die = function(event, callback){
                              $(document.body).undelegate(this.selector, event, callback)
                              return this
                            }
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 45 mins to fix
                          app/assets/javascripts/zepto.js on lines 1042..1045

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

                          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

                                return (_base1 = $.fn)[_name1 = "outer" + Dimension] || (_base1[_name1] = function(includeMargin) {
                                  return ioDim(this, Dimension, dimension, true, includeMargin);
                                });
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 45 mins to fix
                          app/assets/javascripts/zepto.js on lines 1866..1868

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

                          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 (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 35 mins to fix
                          app/assets/javascripts/zepto.js on lines 851..851

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

                          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

                            $.fn.bind = function(event, callback){
                              return this.each(function(){
                                add(this, event, callback)
                              })
                            }
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 35 mins to fix
                          app/assets/javascripts/zepto.js on lines 971..975

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

                          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 (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 35 mins to fix
                          app/assets/javascripts/zepto.js on lines 850..850

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

                          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

                            $.fn.unbind = function(event, callback){
                              return this.each(function(){
                                remove(this, event, callback)
                              })
                            }
                          Severity: Minor
                          Found in app/assets/javascripts/zepto.js and 1 other location - About 35 mins to fix
                          app/assets/javascripts/zepto.js on lines 966..970

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status