zxing-js/library

View on GitHub
src/core/pdf417/decoder/PDF417CodewordDecoder.ts

Summary

Maintainability
A
2 hrs
Test Coverage
A
98%

Function getClosestDecodedValue has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  private static getClosestDecodedValue(moduleBitCount: Int32Array): int {
    let bitCountSum: int = MathUtils.sum(moduleBitCount);
    let bitCountRatios: float[] = new Array(PDF417Common.BARS_IN_MODULE);
    if (bitCountSum > 1) {
      for (let /*int*/ i = 0; i < bitCountRatios.length; i++) {
Severity: Minor
Found in src/core/pdf417/decoder/PDF417CodewordDecoder.ts - 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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  static initialize() {
     // Pre-computes the symbol ratio table.
    for (/*int*/let i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) {
      let currentSymbol: int = PDF417Common.SYMBOL_TABLE[i];
      let currentBit: int = currentSymbol & 0x1;
Severity: Minor
Found in src/core/pdf417/decoder/PDF417CodewordDecoder.ts - About 55 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 getBitValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private static getBitValue(moduleBitCount: Int32Array): int {
    let result: /*long*/ number = 0;
    for (let /*int*/ i = 0; i < moduleBitCount.length; i++) {
      for (/*int*/ let bit = 0; bit < moduleBitCount[i]; bit++) {
        result = (result << 1) | (i % 2 === 0 ? 1 : 0);
Severity: Minor
Found in src/core/pdf417/decoder/PDF417CodewordDecoder.ts - About 25 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