ampache/ampache

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

Summary

Maintainability
F
5 days
Test Coverage

File alac.js has 651 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){
// Generated by CoffeeScript 1.7.1
(function() {
  var Aglib;

Severity: Major
Found in public/lib/modules/aurora.js/alac.js - About 5 hrs to fix

    Function 3 has 250 lines of code (exceeds 200 allowed). Consider refactoring.
    Open

    },{"./ag_dec":1,"./dp_dec":3,"./matrix_dec":4}],3:[function(require,module,exports){
    // Generated by CoffeeScript 1.7.1
    (function() {
      var Dplib;
    
    
    Severity: Major
    Found in public/lib/modules/aurora.js/alac.js - About 3 hrs to fix

      Function unpc_block has 232 lines of code (exceeds 200 allowed). Consider refactoring.
      Open

          Dplib.unpc_block = function(pc1, out, num, coefs, active, chanbits, denshift) {
            var a0, a1, a2, a3, a4, a5, a6, a7, b0, b1, b2, b3, b4, b5, b6, b7, chanshift, dd, del, del0, denhalf, i, j, lim, offset, prev, sg, sgn, sum1, top, _i, _j, _k, _l, _m, _n, _o, _p, _ref, _ref1;
            chanshift = 32 - chanbits;
            denhalf = 1 << (denshift - 1);
            out[0] = pc1[0];
      Severity: Major
      Found in public/lib/modules/aurora.js/alac.js - About 2 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/alac.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 2 has 207 lines of code (exceeds 200 allowed). Consider refactoring.
        Open

        },{}],2:[function(require,module,exports){
        // Generated by CoffeeScript 1.7.1
        (function() {
          var ALACDecoder, AV, Aglib, Dplib, Matrixlib,
            __hasProp = {}.hasOwnProperty,
        Severity: Major
        Found in public/lib/modules/aurora.js/alac.js - About 1 hr to fix

          Function unmix16 has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              Matrixlib.unmix16 = function(u, v, out, stride, samples, mixbits, mixres) {
          Severity: Major
          Found in public/lib/modules/aurora.js/alac.js - About 50 mins to fix

            Function unpc_block has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                Dplib.unpc_block = function(pc1, out, num, coefs, active, chanbits, denshift) {
            Severity: Major
            Found in public/lib/modules/aurora.js/alac.js - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          if (del0 >= 0) {
                            continue;
                          }
              Severity: Major
              Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                for (ch = _m = 0; _m < channels; ch = _m += 1) {
                                  val = (data.read(chanBits) << shift) >> shift;
                                  this.mixBuffers[ch][i] = val;
                                }
                Severity: Major
                Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    for (i = _o = 0; _o < samples; i = _o += 1) {
                                      out16[j] = buf[i];
                                      j += numChannels;
                                    }
                  Severity: Major
                  Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                    Function ag_params has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        Aglib.ag_params = function(m, p, k, f, s, maxrun) {
                    Severity: Minor
                    Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      for (i = _j = 0, _ref = num[ch]; _j < _ref; i = _j += 1) {
                                        table[i] = data.read(16);
                                      }
                      Severity: Major
                      Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        if (mode[ch] === 0) {
                                          Dplib.unpc_block(this.predictor, this.mixBuffers[ch], samples, coefs[ch], num[ch], chanBits, denShift[ch]);
                                        } else {
                                          Dplib.unpc_block(this.predictor, this.predictor, samples, null, 31, chanBits, 0);
                                          Dplib.unpc_block(this.predictor, this.mixBuffers[ch], samples, coefs[ch], num[ch], chanBits, denShift[ch]);
                        Severity: Major
                        Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          if (!status) {
                                            throw new Error('Error in Aglib.dyn_decomp');
                                          }
                          Severity: Major
                          Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                        if (del0 >= 0) {
                                          continue;
                                        }
                            Severity: Major
                            Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (del0 >= 0) {
                                            continue;
                                          }
                              Severity: Major
                              Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (del0 <= 0) {
                                              continue;
                                            }
                                Severity: Major
                                Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                            } else if (sg < 0) {
                                              sgn = -((-b7 >>> 31) | (b7 >> 31));
                                              a7 -= sgn;
                                              del0 -= 1 * ((sgn * b7) >> denshift);
                                              if (del0 >= 0) {
                                  Severity: Major
                                  Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                if (del0 <= 0) {
                                                  continue;
                                                }
                                    Severity: Major
                                    Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if (del0 <= 0) {
                                                    continue;
                                                  }
                                      Severity: Major
                                      Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                    if (del0 <= 0) {
                                                      continue;
                                                    }
                                        Severity: Major
                                        Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                      if (del0 <= 0) {
                                                        continue;
                                                      }
                                          Severity: Major
                                          Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                        for (j = _o = _ref = active - 1; _o >= 0; j = _o += -1) {
                                                          dd = top - out[offset - j];
                                                          sgn = (-dd >>> 31) | (dd >> 31);
                                                          coefs[j] -= sgn;
                                                          del0 -= (active - j) * ((sgn * dd) >> denshift);
                                            Severity: Major
                                            Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                          if (del0 <= 0) {
                                                            continue;
                                                          }
                                              Severity: Major
                                              Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                            if (del0 <= 0) {
                                                              continue;
                                                            }
                                                Severity: Major
                                                Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                            } else if (sg < 0) {
                                                              for (j = _p = _ref1 = active - 1; _p >= 0; j = _p += -1) {
                                                                dd = top - out[offset - j];
                                                                sgn = (-dd >>> 31) | (dd >> 31);
                                                                coefs[j] += sgn;
                                                  Severity: Major
                                                  Found in public/lib/modules/aurora.js/alac.js - About 45 mins to fix

                                                    Function dyn_decomp has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                                    Open

                                                        Aglib.dyn_decomp = function(params, data, pc, samples, maxSize) {
                                                    Severity: Minor
                                                    Found in public/lib/modules/aurora.js/alac.js - About 35 mins to fix

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

                                                      },{}],2:[function(require,module,exports){
                                                      // Generated by CoffeeScript 1.7.1
                                                      (function() {
                                                        var ALACDecoder, AV, Aglib, Dplib, Matrixlib,
                                                          __hasProp = {}.hasOwnProperty,
                                                      Severity: Minor
                                                      Found in public/lib/modules/aurora.js/alac.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

                                                      Avoid too many return statements within this function.
                                                      Open

                                                            return output + 4;
                                                      Severity: Major
                                                      Found in public/lib/modules/aurora.js/alac.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/alac.js - About 30 mins to fix

                                                          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){
                                                          // Generated by CoffeeScript 1.7.1
                                                          (function() {
                                                            var Aglib;
                                                          
                                                          
                                                          Severity: Major
                                                          Found in public/lib/modules/aurora.js/alac.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/flac.js on lines 1..790
                                                          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

                                                              var BITOFF, KB0, MAX_DATATYPE_BITS_16, MAX_PREFIX_16, MAX_PREFIX_32, MAX_RUN_DEFAULT, MB0, MDENSHIFT, MMULSHIFT, MOFF, N_MAX_MEAN_CLAMP, N_MEAN_CLAMP_VAL, PB0, QB, QBSHIFT, dyn_get_16, dyn_get_32, lead;
                                                          Severity: Major
                                                          Found in public/lib/modules/aurora.js/alac.js and 1 other location - About 1 hr to fix
                                                          public/lib/modules/aurora.js/aurora.js on lines 1540..1540

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

                                                          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