audiojs/audio

View on GitHub
src/manipulations.js

Summary

Maintainability
D
2 days
Test Coverage

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

      Audio.prototype.write = function write (value, time, duration, options) {
          let {start, end, length, channels, format} = parseArgs(this, time, duration, options)
      
          // fill with value
          if (typeof value === 'number') {
      Severity: Minor
      Found in src/manipulations.js - About 1 hr to fix

        Function insert has 31 lines of code (exceeds 25 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 1 hr to fix

          Function shift has 28 lines of code (exceeds 25 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

            Function fade has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Audio.prototype.fade = function (time, duration, options) {
                //first arg goes duration by default
                if (typeof duration != 'number' || duration == null) {
                    duration = time;
                    time = 0;
            Severity: Minor
            Found in src/manipulations.js - About 1 hr to fix

              Function read has 27 lines of code (exceeds 25 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

                Function pad has 26 lines of code (exceeds 25 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

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

                  Audio.prototype.write = function write (value, time, duration, options) {
                      let {start, end, length, channels, format} = parseArgs(this, time, duration, options)
                  
                      // fill with value
                      if (typeof value === 'number') {
                  Severity: Minor
                  Found in src/manipulations.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 fade has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Audio.prototype.fade = function (time, duration, options) {
                      //first arg goes duration by default
                      if (typeof duration != 'number' || duration == null) {
                          duration = time;
                          time = 0;
                  Severity: Minor
                  Found in src/manipulations.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 slice has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Audio.prototype.slice = function slice (time, duration, options) {
                      let {start, end, channels, copy} = parseArgs(this, time, duration, options)
                  
                      if (copy == null) copy = true
                  
                  
                  Severity: Minor
                  Found in src/manipulations.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

                  There are no issues that match your filters.

                  Category
                  Status