ivmartel/dwv

View on GitHub
decoders/pdfjs/arithmetic_decoder.js

Summary

Maintainability
D
1 day
Test Coverage

Function ArithmeticDecoderClosure has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
  // Table C-2
  var QeTable = [
    {qe: 0x5601, nmps: 1, nlps: 1, switchFlag: 1},
    {qe: 0x3401, nmps: 2, nlps: 6, switchFlag: 0},
Severity: Minor
Found in decoders/pdfjs/arithmetic_decoder.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

Function ArithmeticDecoderClosure has 138 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
  // Table C-2
  var QeTable = [
    {qe: 0x5601, nmps: 1, nlps: 1, switchFlag: 1},
    {qe: 0x3401, nmps: 2, nlps: 6, switchFlag: 0},
Severity: Major
Found in decoders/pdfjs/arithmetic_decoder.js - About 5 hrs to fix

    Function ArithmeticDecoder_readBit has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        readBit: function ArithmeticDecoder_readBit(contexts, pos) {
          // contexts are packed into 1 byte:
          // highest 7 bits carry cx.index, lowest bit carries cx.mps
          var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
          var qeTableIcx = QeTable[cx_index];
    Severity: Minor
    Found in decoders/pdfjs/arithmetic_decoder.js - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status