ampache/ampache

View on GitHub
public/lib/modules/aurora.js/flac.js

Summary

Maintainability
F
1 wk
Test Coverage

Function 2 has a Cognitive Complexity of 284 (exceeds 5 allowed). Consider refactoring.
Open

},{"./src/decoder":2,"./src/demuxer":3,"./src/ogg":4}],2:[function(require,module,exports){
/*
 * FLAC.js - Free Lossless Audio Codec decoder in JavaScript
 * Original C version from FFmpeg (c) 2003 Alex Beregszaszi
 * JavaScript port by Devon Govett and Jens Nockert of Official.fm Labs
Severity: Minor
Found in public/lib/modules/aurora.js/flac.js - About 5 days 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 3 has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

},{}],3:[function(require,module,exports){
/*
 * FLAC.js - Free Lossless Audio Codec decoder in JavaScript
 * By Devon Govett and Jens Nockert of Official.fm Labs
 *
Severity: Minor
Found in public/lib/modules/aurora.js/flac.js - About 1 day 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 2 has 390 lines of code (exceeds 200 allowed). Consider refactoring.
Open

},{"./src/decoder":2,"./src/demuxer":3,"./src/ogg":4}],2:[function(require,module,exports){
/*
 * FLAC.js - Free Lossless Audio Codec decoder in JavaScript
 * Original C version from FFmpeg (c) 2003 Alex Beregszaszi
 * JavaScript port by Devon Govett and Jens Nockert of Official.fm Labs
Severity: Major
Found in public/lib/modules/aurora.js/flac.js - About 1 day to fix

    Function FLACDecoder has 386 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    var FLACDecoder = AV.Decoder.extend(function() {
        AV.Decoder.register('flac', this);
    
        this.prototype.setCookie = function(cookie) {
            this.cookie = cookie;
    Severity: Major
    Found in public/lib/modules/aurora.js/flac.js - About 1 day to fix

      File flac.js has 556 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
      exports.FLACDemuxer = require('./src/demuxer');
      exports.FLACDecoder = require('./src/decoder');
      require('./src/ogg');
      
      
      Severity: Major
      Found in public/lib/modules/aurora.js/flac.js - About 3 hrs to fix

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

        (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
        Severity: Minor
        Found in public/lib/modules/aurora.js/flac.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

        Avoid deeply nested control flow statements.
        Open

                                        if(stream.readUInt32() > 0)
                                        {
                                            this.emit('error', 'Seek points with stream offset >UInt32 not supported');
                                        }
        Severity: Major
        Found in public/lib/modules/aurora.js/flac.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                          if(stream.readUInt32() > 0)
                                          {
                                              this.emit('error', 'Seek points with sample number >UInt32 not supported');
                                          }
          Severity: Major
          Found in public/lib/modules/aurora.js/flac.js - About 45 mins to fix

            Function 4 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            },{}],4:[function(require,module,exports){
            var AV = (window.AV);
            
            // if ogg.js exists, register a plugin
            try {
            Severity: Minor
            Found in public/lib/modules/aurora.js/flac.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

            Avoid too many return statements within this function.
            Open

                    return output + 4;
            Severity: Major
            Found in public/lib/modules/aurora.js/flac.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                      return this.emit('error', 'STREAMINFO size is wrong.');
              Severity: Major
              Found in public/lib/modules/aurora.js/flac.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return output + 3;
                Severity: Major
                Found in public/lib/modules/aurora.js/flac.js - About 30 mins to fix

                  TODO found
                  Open

                                      // TODO: standardize field names across formats
                  Severity: Minor
                  Found in public/lib/modules/aurora.js/flac.js by fixme

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

                  (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
                  exports.FLACDemuxer = require('./src/demuxer');
                  exports.FLACDecoder = require('./src/decoder');
                  require('./src/ogg');
                  
                  
                  Severity: Major
                  Found in public/lib/modules/aurora.js/flac.js and 3 other locations - About 1 day to fix
                  public/lib/modules/aurora.js/aac.js on lines 1..4652
                  public/lib/modules/aurora.js/alac.js on lines 1..722
                  public/lib/modules/aurora.js/mp3.js on lines 1..7748

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

                  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 (var k = 0; k < blockSize; k++) {
                                      for (var i = 0; i < channels; i++) {
                                          buf[j++] = decoded[i][k];
                                      }
                                  }
                  Severity: Major
                  Found in public/lib/modules/aurora.js/flac.js and 1 other location - About 1 hr to fix
                  public/lib/modules/aurora.js/mp3.js on lines 58..62

                  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

                  There are no issues that match your filters.

                  Category
                  Status