browsejs/browse.js

View on GitHub

Showing 12 of 12 total issues

Function _ajaxNonce has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function _ajaxNonce(url, options) {
  if(false === options.cache && options.method.match(__methods_with_response__)) {
    if(!url.match(/_=/)) {
      url += !url.match(/\?/)
        ? '?_='
Severity: Minor
Found in lib/ajax-request.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 _scrollYTick has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function _scrollYTick(obj, toY, duration, mode, callback) {
Severity: Minor
Found in lib/animation.js - About 35 mins to fix

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

    function _getAnimationStep(beginTime, duration, beginVal, endVal, mode) {
    Severity: Minor
    Found in lib/animation.js - About 35 mins to fix

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

      browse.prototype.lastChild = function() {
        if('lastElementChild' in this.element) {
          return browse(this.element.lastElementChild)
        }
        var child = this.element.lastChild
      Severity: Minor
      Found in lib/relatives.js and 2 other locations - About 35 mins to fix
      lib/relatives.js on lines 38..47
      lib/relatives.js on lines 49..58

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

      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 3 locations. Consider refactoring.
      Open

      browse.prototype.next = function() {
        if('nextElementSibling' in this.element) {
          return browse(this.element.nextElementSibling)
        }
        var next = this.element.nextSibling
      Severity: Minor
      Found in lib/relatives.js and 2 other locations - About 35 mins to fix
      lib/relatives.js on lines 27..36
      lib/relatives.js on lines 49..58

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

      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 3 locations. Consider refactoring.
      Open

      browse.prototype.previous = function() {
        if('previousElementSibling' in this.element) {
          return browse(this.element.previousElementSibling)
        }
        var previous = this.element.previousSibling
      Severity: Minor
      Found in lib/relatives.js and 2 other locations - About 35 mins to fix
      lib/relatives.js on lines 27..36
      lib/relatives.js on lines 38..47

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

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

      function _readyInit(callback) {
        var done = false
        var init = function(e) {
          if(e.type === 'readystatechange' && document.readyState !== 'complete') {
            return
      Severity: Minor
      Found in lib/ready.js - About 35 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

      Function _eventDataFromDefsAndParams has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      function _eventDataFromDefsAndParams(defs, allowed, params) {
        var input = { }
        /* eslint-disable guard-for-in */
        for(var key in defs) {
          input[key] = defs[key]
      Severity: Minor
      Found in lib/events.js - About 35 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

      Function _getOpacity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function _getOpacity(style) {
        if('opacity' in style) {
          return style.opacity !== '' ? parseFloat(style.opacity) : 1.0
        }
        else /*if('filter' in style)*/ {
      Severity: Minor
      Found in lib/opacity.js - About 25 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

      Function _nonIeKbEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function _nonIeKbEvent(type, input) {
        var e
        try {
          e = new window.KeyboardEvent(type, input)
          var keys = ['keyCode', 'location']
      Severity: Minor
      Found in lib/keyboard-events.js - About 25 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

      Function _setOpacity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function _setOpacity(style, value) {
        value = parseFloat(value)
        if(isNaN(value) || value < 0 || value > 1) {
          throw Error('Opacity value must be >= 0 and <= 1')
        }
      Severity: Minor
      Found in lib/opacity.js - About 25 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

      Function _noFilesInForm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function _noFilesInForm(form) {
        var elements = form.elements
        for(var idx = 0; idx < elements.length; ++idx) {
          if('file' === elements[idx].type.toLowerCase()) {
            if(elements[idx].files && elements[idx].files.length) {
      Severity: Minor
      Found in lib/ajax-multipart.js - About 25 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

      Severity
      Category
      Status
      Source
      Language