Goldinteractive/js-base

View on GitHub

Showing 22 of 32 total issues

File features.js has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Features module.
 * @module base/features
 */

Severity: Minor
Found in src/features.js - About 7 hrs to fix

Function to has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  to(options = {}) {
    let timeX = 0
    let timeY = 0
    let currentTime = 0
    let rootElement = Array.isArray(this._opts.rootElement)
Severity: Major
Found in src/utils/dom.js - About 2 hrs to fix

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

export async function init(container = document.body, name = null, options = {}) {
  options = Object.assign({}, defaultInitOptions, options)

  const instances = []
  const names = name ? name.split(ATTR_FEATURES_SEPARATOR) : null
Severity: Major
Found in src/features.js - About 2 hrs to fix

Function to has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  to(options = {}) {
    let timeX = 0
    let timeY = 0
    let currentTime = 0
    let rootElement = Array.isArray(this._opts.rootElement)
Severity: Minor
Found in src/utils/dom.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 loadExternals has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function loadExternals(bundles, assetPath) {
  let elements = document.querySelectorAll(`[${ATTR_EXTERNAL_SCRIPT}]`)
  let features = getFeatures()
  let scripts = []
  let scriptsLoaded = []
Severity: Minor
Found in src/features.js - About 1 hr to fix

Function debounce has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export function debounce(func, wait = 60, immediate = false) {
  var timeout, args, context, timestamp, result

  function later() {
    var last = Date.now() - timestamp
Severity: Minor
Found in src/utils/fn.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 lazyload has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function lazyload(bundles, assetPath) {
  if (!bundles || !assetPath) {
    throw Error('Cannot lazyload features without a bundles file or a path!')
  }

Severity: Minor
Found in src/features.js - About 1 hr to fix

Function destroy has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function destroy(container = document.body, name = null, options = {}) {
  options = Object.assign({}, defaultDestroyOptions, options)

  const names = name ? name.split(ATTR_FEATURES_SEPARATOR) : null
  const featureNodes = [...container.querySelectorAll(`[${ATTR_FEATURES}]`)]
Severity: Minor
Found in src/features.js - About 1 hr to fix

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

export function debounce(func, wait = 60, immediate = false) {
  var timeout, args, context, timestamp, result

  function later() {
    var last = Date.now() - timestamp
Severity: Minor
Found in src/utils/fn.js - About 1 hr to fix

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

module.exports = function(env = {}) {
  var entry = path.join(root, process.env.SOURCE_PATH, 'index.js')
  var outputPath = path.join(root, process.env.LIBRARY_PATH)
  var outputFile = LIBRARY_NAME + '.js'

Severity: Minor
Found in .config/webpack.js - About 1 hr to fix

Function getRelevantBundles has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function getRelevantBundles(bundles) {
  const features = getFeatures()
  let extElements = document.querySelectorAll(`[${ATTR_EXTERNAL_SCRIPT}]`)
  let extFeatures = []
  let optimizedBundles = {}
Severity: Minor
Found in src/features.js - About 1 hr to fix

Function lazyload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function lazyload(bundles, assetPath) {
  if (!bundles || !assetPath) {
    throw Error('Cannot lazyload features without a bundles file or a path!')
  }

Severity: Minor
Found in src/features.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 tick has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function tick() {
      currentTime += 1 / 60

      let p = currentTime / time
      let t = easingEquations[opts.easing](p)
Severity: Minor
Found in src/utils/dom.js - About 1 hr to fix

Function removeEventListener has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  removeEventListener(node, type = null, fn = null) {
    if (!isElement(node) && node !== window) {
      let currentNode = node.length
      while (currentNode--) {
        this.removeEventListener(node[currentNode], type, fn)
Severity: Minor
Found in src/features.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (
        nodeInstances.hasOwnProperty(featureName) &&
        (!name || names.indexOf(featureName) > -1) && // name is whitelisted
        (!ignoreFeatures || ignoreFeatures.indexOf(featureName) < 0) && // feature is ignore on this node
        (featureNode._baseFeatureInstances && // feature instance exists
Severity: Major
Found in src/features.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (
        !feature || // feature has not been added yet
        (ignoreFeatures && ignoreFeatures.indexOf(featureName) > -1) || // feature is ignored on this node
        (name && names.indexOf(featureName) < 0) || // name is not whitelisted
        (featureNode._baseFeatureInstances && // feature has already been initalized on this node
Severity: Major
Found in src/features.js - About 1 hr to fix

Function loadExternals has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export async function loadExternals(bundles, assetPath) {
  let elements = document.querySelectorAll(`[${ATTR_EXTERNAL_SCRIPT}]`)
  let features = getFeatures()
  let scripts = []
  let scriptsLoaded = []
Severity: Minor
Found in src/features.js - About 55 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 isEmpty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function isEmpty(value) {
  // compare value with values considered as empty
  for (let i = 0, len = EMPTY_DEFINITIONS.length; i < len; i++) {
    if (value === EMPTY_DEFINITIONS[i]) {
      return true
Severity: Minor
Found in src/utils/check.js - About 55 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 parents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function parents(element, match = null) {
  let parents = []

  for (; element && element !== document; element = element.parentNode) {
    if (match) {
Severity: Minor
Found in src/utils/dom.js - About 45 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 addEventListener has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  addEventListener(node, type, fn, options = {}) {
    if (!isElement(node) && node !== window) {
      let currentNode = node.length
      while (currentNode--) {
        this.addEventListener(node[currentNode], type, fn, options)
Severity: Minor
Found in src/features.js - About 45 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