ivmartel/dwv

View on GitHub
decoders/pdfjs/jpg.js

Summary

Maintainability
F
3 wks
Test Coverage

Function jpegImage has a Cognitive Complexity of 480 (exceeds 5 allowed). Consider refactoring.
Open

var JpegImage = (function jpegImage() {
  var dctZigZag = new Uint8Array([
     0,
     1,  8,
    16,  9,  2,
Severity: Minor
Found in decoders/pdfjs/jpg.js - About 1 wk 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 jpegImage has 902 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var JpegImage = (function jpegImage() {
  var dctZigZag = new Uint8Array([
     0,
     1,  8,
    16,  9,  2,
Severity: Major
Found in decoders/pdfjs/jpg.js - About 4 days to fix

    File jpg.js has 905 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    
    /* Copyright 2014 Mozilla Foundation
     *
     * Licensed under the Apache License, Version 2.0 (the 'License');
     * you may not use this file except in compliance with the License.
    Severity: Major
    Found in decoders/pdfjs/jpg.js - About 2 days to fix

      Function decodeScan has 243 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function decodeScan(data, offset, frame, components, resetInterval,
                            spectralStart, spectralEnd, successivePrev, successive) {
          var mcusPerLine = frame.mcusPerLine;
          var progressive = frame.progressive;
      
      
      Severity: Major
      Found in decoders/pdfjs/jpg.js - About 1 day to fix

        Function parse has 237 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            parse: function parse(data) {
        
              function readUint16() {
                var value = (data[offset] << 8) | data[offset + 1];
                offset += 2;
        Severity: Major
        Found in decoders/pdfjs/jpg.js - About 1 day to fix

          Function quantizeAndInverse has 143 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function quantizeAndInverse(component, blockBufferOffset, p) {
              var qt = component.quantizationTable, blockData = component.blockData;
              var v0, v1, v2, v3, v4, v5, v6, v7;
              var p0, p1, p2, p3, p4, p5, p6, p7;
              var t;
          Severity: Major
          Found in decoders/pdfjs/jpg.js - About 5 hrs to fix

            Function decodeACSuccessive has 62 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function decodeACSuccessive(component, offset) {
                  var k = spectralStart;
                  var e = spectralEnd;
                  var r = 0;
                  var s;
            Severity: Major
            Found in decoders/pdfjs/jpg.js - About 2 hrs to fix

              Function convertCmykToRgb has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  _convertCmykToRgb: function convertCmykToRgb(data) {
                    var c, m, y, k;
                    var offset = 0;
                    var min = -255 * 255 * 255;
                    var scale = 1 / 255 / 255;
              Severity: Minor
              Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                Function getLinearizedBlockData has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
                      var scaleX = this.width / width, scaleY = this.height / height;
                
                      var component, componentScaleX, componentScaleY, blocksPerScanline;
                      var x, y, i, j, k;
                Severity: Minor
                Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                  Function convertYcckToRgb has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      _convertYcckToRgb: function convertYcckToRgb(data) {
                        var Y, Cb, Cr, k;
                        var offset = 0;
                        for (var i = 0, length = data.length; i < length; i += 4) {
                          Y  = data[i];
                  Severity: Minor
                  Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                    Function buildHuffmanTable has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      function buildHuffmanTable(codeLengths, values) {
                        var k = 0, code = [], i, j, length = 16;
                        while (length > 0 && !codeLengths[length - 1]) {
                          length--;
                        }
                    Severity: Minor
                    Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                      Function getData has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          getData: function getData(width, height, forceRGBoutput) {
                            if (this.numComponents > 4) {
                              throw 'Unsupported color mode';
                            }
                            // type of data: Uint8Array(width * height * numComponents)
                      Severity: Minor
                      Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                        Function decodeScan has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          function decodeScan(data, offset, frame, components, resetInterval,
                                              spectralStart, spectralEnd, successivePrev, successive) {
                        Severity: Major
                        Found in decoders/pdfjs/jpg.js - About 1 hr to fix

                          Avoid deeply nested control flow statements.
                          Open

                                          for (j = 0; j < 64; j++) {
                                            z = dctZigZag[j];
                                            tableData[z] = data[offset++];
                                          }
                          Severity: Major
                          Found in decoders/pdfjs/jpg.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          } else if ((quantizationTableSpec >> 4) === 1) { //16 bit
                                            for (j = 0; j < 64; j++) {
                                              z = dctZigZag[j];
                                              tableData[z] = readUint16();
                                            }
                            Severity: Major
                            Found in decoders/pdfjs/jpg.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          for (j = 0; j < v; j++) {
                                            for (k = 0; k < h; k++) {
                                              decodeMcu(component, decodeFn, mcu, j, k);
                                            }
                                          }
                              Severity: Major
                              Found in decoders/pdfjs/jpg.js - About 45 mins to fix

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

                                    function decodeMcu(component, decode, mcu, row, col) {
                                Severity: Minor
                                Found in decoders/pdfjs/jpg.js - About 35 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return data;
                                  Severity: Major
                                  Found in decoders/pdfjs/jpg.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                              return this._convertCmykToRgb(data);
                                    Severity: Major
                                    Found in decoders/pdfjs/jpg.js - About 30 mins to fix

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

                                              var r = -122.67195406894 +
                                                Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr -
                                                      5.4080610064599e-5 * Y + 0.00048449797120281 * k -
                                                      0.154362151871126) +
                                                Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y -
                                      Severity: Major
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 4 hrs to fix
                                      decoders/pdfjs/jpg.js on lines 955..963

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

                                      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 b = -20.810012546947 +
                                                Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr +
                                                      0.0020741088115012 * Y - 0.00288260236853442 * k +
                                                      0.814272968359295) +
                                                Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y +
                                      Severity: Major
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 4 hrs to fix
                                      decoders/pdfjs/jpg.js on lines 935..943

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

                                      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

                                                    if (appData[0] === 0x4A && appData[1] === 0x46 &&
                                                        appData[2] === 0x49 && appData[3] === 0x46 &&
                                                        appData[4] === 0) { // 'JFIF\x00'
                                                      jfif = {
                                                        version: { major: appData[5], minor: appData[6] },
                                      Severity: Major
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 1 hr to fix
                                      decoders/pdfjs/jpg.js on lines 682..691

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

                                      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

                                                    if (appData[0] === 0x41 && appData[1] === 0x64 &&
                                                        appData[2] === 0x6F && appData[3] === 0x62 &&
                                                        appData[4] === 0x65) { // 'Adobe'
                                                      adobe = {
                                                        version: (appData[5] << 8) | appData[6],
                                      Severity: Major
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 1 hr to fix
                                      decoders/pdfjs/jpg.js on lines 665..678

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

                                      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 blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines  / 8) *
                                                                                component.v / frame.maxV);
                                      Severity: Minor
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 35 mins to fix
                                      decoders/pdfjs/jpg.js on lines 613..614

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

                                      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 blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) *
                                                                              component.h / frame.maxH);
                                      Severity: Minor
                                      Found in decoders/pdfjs/jpg.js and 1 other location - About 35 mins to fix
                                      decoders/pdfjs/jpg.js on lines 615..616

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

                                      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 3 locations. Consider refactoring.
                                      Open

                                              data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
                                      Severity: Minor
                                      Found in decoders/pdfjs/jpg.js and 2 other locations - About 30 mins to fix
                                      decoders/pdfjs/jpg.js on lines 1025..1025
                                      decoders/pdfjs/jpg.js on lines 1026..1026

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

                                      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 3 locations. Consider refactoring.
                                      Open

                                              data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
                                      Severity: Minor
                                      Found in decoders/pdfjs/jpg.js and 2 other locations - About 30 mins to fix
                                      decoders/pdfjs/jpg.js on lines 1026..1026
                                      decoders/pdfjs/jpg.js on lines 1027..1027

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

                                      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 3 locations. Consider refactoring.
                                      Open

                                              data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
                                      Severity: Minor
                                      Found in decoders/pdfjs/jpg.js and 2 other locations - About 30 mins to fix
                                      decoders/pdfjs/jpg.js on lines 1025..1025
                                      decoders/pdfjs/jpg.js on lines 1027..1027

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

                                      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