audiojs/audio

View on GitHub

Showing 32 of 32 total issues

Function parseArgs has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

function parseArgs (audio, time, duration, options) {
    // no args at all
    if (time == null && duration == null && options == null) {
        options = {}
        time = 0
Severity: Minor
Found in src/util.js - About 5 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

File manipulations.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Extend audio with manipulations functionality
 *
 * @module  audio/src/manipulations
 */
Severity: Minor
Found in src/manipulations.js - About 4 hrs to fix

    Function parseArgs has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function parseArgs (audio, time, duration, options) {
        // no args at all
        if (time == null && duration == null && options == null) {
            options = {}
            time = 0
    Severity: Major
    Found in src/util.js - About 3 hrs to fix

      Function insert has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      Audio.prototype.insert = function (value, time, duration, options) {
          let toEnd = false
          if (time == null || isPlainObj(time)) {
              toEnd = true
          }
      Severity: Minor
      Found in src/manipulations.js - About 3 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 Audio has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      function Audio(source, options) {
          if (!(this instanceof Audio)) return new Audio(source, options)
      
          // handle channels-only options
          if (typeof options === 'number') options = {channels: options}
      Severity: Minor
      Found in index.js - About 3 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 load has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Audio.load = function load (source, callback) {
          let promise
      
          if (typeof source === 'string') {
              source = resolvePath(source, 2)
      Severity: Major
      Found in src/core.js - About 2 hrs to fix

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

        Audio.load = function load (source, callback) {
            let promise
        
            if (typeof source === 'string') {
                source = resolvePath(source, 2)
        Severity: Minor
        Found in src/core.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

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

                return Promise.all(items).then((list) => {
                    callback && callback(null, list)
                    return Promise.resolve(list)
                }, error => {
                    callback && callback(error)
        Severity: Major
        Found in src/core.js and 1 other location - About 2 hrs to fix
        src/core.js on lines 201..207

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

        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

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

                promise = Promise.all(items).then((list) => {
                    callback && callback(null, list)
                    return Promise.resolve(list)
                }, error => {
                    callback && callback(error)
        Severity: Major
        Found in src/core.js and 1 other location - About 2 hrs to fix
        src/core.js on lines 244..250

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

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

        Audio.prototype.shift = function shift (amount, options) {
            let {rotate, channels} = parseArgs(this, options)
        
            if (typeof amount !== 'number') throw Error('First argument should be a number')
            let length = this.offset(Math.abs(amount))
        Severity: Minor
        Found in src/manipulations.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 from has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        Audio.from = function from (...sources) {
            let items = [], channels = 1
        
            let options = sources[sources.length - 1]
        
        
        Severity: Minor
        Found in src/core.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 Audio has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Audio(source, options) {
            if (!(this instanceof Audio)) return new Audio(source, options)
        
            // handle channels-only options
            if (typeof options === 'number') options = {channels: options}
        Severity: Minor
        Found in index.js - About 1 hr to fix

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

          Audio.equal = function (a, ...sources) {
              for (let i = 0; i < sources.length; i++) {
                  let b = sources[i]
          
                  if (a === b) return true
          Severity: Minor
          Found in src/core.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

          for (let alias in protoAlias) {
              let orig = protoAlias[alias]
          
              Audio.prototype[alias] = () => {
                  throw Error('Use `audio.' + orig + '(...)` instead of `audio.' + alias + '(...)`')
          Severity: Major
          Found in src/alias.js and 1 other location - About 1 hr to fix
          src/alias.js on lines 92..98

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

          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

          for (let alias in classAlias) {
              let orig = classAlias[alias]
          
              Audio.prototype[alias] = () => {
                  throw Error('Use `Audio.' + orig + '(...)` instead of `Audio.' + alias + '(...)`')
          Severity: Major
          Found in src/alias.js and 1 other location - About 1 hr to fix
          src/alias.js on lines 55..61

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

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

          Audio.prototype.loudness = function (time, duration, options) {
              if (typeof options === 'string') options = {method: options}
          
              options = parseArgs(this, time, duration, options)
          
          
          Severity: Minor
          Found in src/metrics.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 pad has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          Audio.prototype.pad = function pad (duration, options) {
              if (typeof options === 'number') {
                  options = {value: options}
              }
          
          
          Severity: Minor
          Found in src/manipulations.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 read has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          Audio.prototype.read = function (t, d, options) {
              let {start, end, from, to, duration, format, channels, destination, channel, length} = parseArgs(this, t, d, options)
          
              //transfer data for indicated channels
              let data = []
          Severity: Minor
          Found in src/manipulations.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 trim has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Audio.prototype.trim = function trim (options) {
              let {threshold, left, right} = parseArgs(this, options)
          
              if (threshold == null) threshold = -40
          
          
          Severity: Minor
          Found in src/manipulations.js - About 1 hr to fix

            Function decode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Audio.decode = function decode (source, options, callback) {
                if (typeof options === 'function') {
                    callback = options
                    options = {context: this.context}
                }
            Severity: Minor
            Found in src/core.js - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language