webpro/DOMtastic

View on GitHub

Showing 22 of 22 total issues

Function css has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export const css = function(key, value) {

  let styleProps, prop, val;

  if(typeof key === 'string') {
Severity: Minor
Found in src/css.js - 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 domtastic has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

const domtastic = function domtastic(selector, context = document) {

  let collection;

  if(!selector) {
Severity: Minor
Found in src/selector/index.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 append has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const append = function(element) {
  if(this instanceof Node) {
    if(typeof element === 'string') {
      this.insertAdjacentHTML('beforeend', element);
    } else {
Severity: Minor
Found in src/dom/index.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 before has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const before = function(element) {
  if(this instanceof Node) {
    if(typeof element === 'string') {
      this.insertAdjacentHTML('beforebegin', element);
    } else {
Severity: Minor
Found in src/dom/index.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 after has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const after = function(element) {
  if(this instanceof Node) {
    if(typeof element === 'string') {
      this.insertAdjacentHTML('afterend', element);
    } else {
Severity: Minor
Found in src/dom/index.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 prepend has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const prepend = function(element) {
  if(this instanceof Node) {
    if(typeof element === 'string') {
      this.insertAdjacentHTML('afterbegin', element);
    } else {
Severity: Minor
Found in src/dom/index.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

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

export const removeClass = function(value) {
  if(value && value.length) {
    each(value.split(' '), _each.bind(this, 'remove'));
  }
  return this;
Severity: Major
Found in src/dom/class.js and 1 other location - About 1 hr to fix
src/dom/class.js on lines 18..23

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

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

export const addClass = function(value) {
  if(value && value.length) {
    each(value.split(' '), _each.bind(this, 'add'));
  }
  return this;
Severity: Major
Found in src/dom/class.js and 1 other location - About 1 hr to fix
src/dom/class.js on lines 36..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 63.

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

export const on = function(eventNames, selector, handler, useCapture, once) {

  if(typeof selector === 'function') {
    handler = selector;
    selector = null;
Severity: Minor
Found in src/event/index.js - About 1 hr to fix

    Function off has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const off = function(eventNames = '', selector, handler, useCapture) {
    
      if(typeof selector === 'function') {
        handler = selector;
        selector = null;
    Severity: Minor
    Found in src/event/index.js - About 1 hr to fix

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

      const querySelector = (selector, context) => {
      
        const isSimpleSelector = reSimpleSelector.test(selector);
      
        if(isSimpleSelector) {
      Severity: Minor
      Found in src/selector/index.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 css has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const css = function(key, value) {
      
        let styleProps, prop, val;
      
        if(typeof key === 'string') {
      Severity: Minor
      Found in src/css.js - About 1 hr to fix

        Function closest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const closest = (() => {
        
          const closest = function(selector, context) {
            const nodes = [];
            each(this, node => {
        Severity: Minor
        Found in src/selector/closest.js - About 1 hr to fix

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

                if(element instanceof Node) {
                  this.parentNode.insertBefore(element, this.nextSibling);
                } else {
                  const elements = element instanceof NodeList ? toArray(element) : element;
                  forEach.call(elements.reverse(), after.bind(this));
          Severity: Minor
          Found in src/dom/index.js and 1 other location - About 50 mins to fix
          src/dom/index.js on lines 55..60

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

          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(element instanceof Node) {
                  this.insertBefore(element, this.firstChild);
                } else {
                  let elements = element instanceof NodeList ? toArray(element) : element;
                  forEach.call(elements.reverse(), prepend.bind(this));
          Severity: Minor
          Found in src/dom/index.js and 1 other location - About 50 mins to fix
          src/dom/index.js on lines 112..117

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

          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 on has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export const on = function(eventNames, selector, handler, useCapture, once) {
          Severity: Minor
          Found in src/event/index.js - About 35 mins to fix

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

            const augmentEvent = event => {
              if(!event.isDefaultPrevented || event.stopImmediatePropagation || event.stopPropagation) {
                for(const methodName in eventMethods) {
                  (function(methodName, testMethodName, originalMethod) {
                    event[methodName] = function() {
            Severity: Minor
            Found in src/event/index.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 getEventConstructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const getEventConstructor = type => isSupportsOtherEventConstructors ? (reMouseEvent.test(type) ? MouseEvent : (reKeyEvent.test(type) ? KeyboardEvent : CustomEvent)) : CustomEvent;
            Severity: Minor
            Found in src/event/trigger.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 data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const data = function(key, value) {
            
              if(typeof key === 'string' && typeof value === 'undefined') {
                const element = this.nodeType ? this : this[0];
                return element && DATAKEYPROP in element ? element[DATAKEYPROP][camelize(key)] : undefined;
            Severity: Minor
            Found in src/dom/data.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 delegateHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export const delegateHandler = function(selector, handler, event) {
              const eventTarget = event._target || event.target;
              const currentTarget = closest.call([eventTarget], selector, this)[0];
              if(currentTarget && currentTarget !== this) {
                if(currentTarget === eventTarget || !(event.isPropagationStopped && event.isPropagationStopped())) {
            Severity: Minor
            Found in src/event/index.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