zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

    public static applyMaskPenaltyRule2(matrix: ByteMatrix): number /*int*/ {
        let penalty = 0;
        const array: Array<Uint8Array> = matrix.getArray();
        const width: number /*int*/ = matrix.getWidth();
        const height: number /*int*/ = matrix.getHeight();
Severity: Minor
Found in src/core/qrcode/encoder/MaskUtil.ts - 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

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

  private static decodeFallback(bytes: Uint8Array, encoding: string | CharacterSetECI): string {

    const characterSet = this.encodingCharacterSet(encoding);

    if (StringEncoding.isDecodeFallbackSupported(characterSet)) {
Severity: Minor
Found in src/core/util/StringEncoding.ts - 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

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

  getRowHeights(): Int32Array {
    let barcodeMetadata: BarcodeMetadata = this.getBarcodeMetadata();
    if (barcodeMetadata == null) {
      return null;
    }
Severity: Minor
Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - 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

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

    public readFormatInformation(): FormatInformation /*throws FormatException*/ {

        if (this.parsedFormatInfo !== null && this.parsedFormatInfo !== undefined) {
            return this.parsedFormatInfo;
        }
Severity: Minor
Found in src/core/qrcode/decoder/BitMatrixParser.ts - 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

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

  public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
    let decoderResult: DecoderResult;
    let points: Array<ResultPoint>;
    if (hints !== undefined && hints !== null && undefined !== hints.get(DecodeHintType.PURE_BARCODE)) {
      const bits = QRCodeReader.extractPureBits(image.getBlackMatrix());
Severity: Minor
Found in src/core/qrcode/QRCodeReader.ts - 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

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

  private static detectCodeword(image: BitMatrix,
    minColumn: int,
    maxColumn: int,
    leftToRight: boolean,
    startColumn: int,
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - 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

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

  private static patternMatchVariance( counters: Int32Array,  pattern: Int32Array,  maxIndividualVariance: float): float {
    let numCounters = counters.length;
    let total = 0;
    let patternLength = 0;
    for (let i = 0; i < numCounters; i++) {
Severity: Minor
Found in src/core/pdf417/detector/Detector.ts - 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

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

    private decodeInternal(image: BinaryBitmap): Result {

        if (this.readers === null) {
            throw new ReaderException('No readers where selected, nothing can be read.');
        }
Severity: Minor
Found in src/core/MultiFormatReader.ts - 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

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

  private static getBarcodeMetadata(leftRowIndicatorColumn: DetectionResultRowIndicatorColumn,
    rightRowIndicatorColumn: DetectionResultRowIndicatorColumn): BarcodeMetadata {
    let leftBarcodeMetadata: BarcodeMetadata;
    if (leftRowIndicatorColumn == null ||
      (leftBarcodeMetadata = leftRowIndicatorColumn.getBarcodeMetadata()) == null) {
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - 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

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

  public static toString(barcodeMatrix: BarcodeValue[][]): String {
    let formatter = new Formatter();
    // try (let formatter = new Formatter()) {
    for (let row /*int*/ = 0; row < barcodeMatrix.length; row++) {
      formatter.format('Row %2d: ', row);
Severity: Minor
Found in src/core/pdf417/decoder/PDF417ScanningDecoder.ts - 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

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

    public decode(received: Int32Array, twoS: number /*int*/): void /*throws ReedSolomonException*/ {
        const field = this.field;
        const poly = new GenericGFPoly(field, received);
        const syndromeCoefficients = new Int32Array(twoS);
        let noError: boolean = true;
Severity: Minor
Found in src/core/common/reedsolomon/ReedSolomonDecoder.ts - 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

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

  constructor(stringToEncode: string, priorityCharset: Charset, fnc1: number) {
    this.fnc1 = fnc1;
    const encoderSet = new ECIEncoderSet(stringToEncode, priorityCharset, fnc1);

    if (encoderSet.length() === 1) {
Severity: Minor
Found in src/core/common/MinimalECIInput.ts - 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

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

    protected static patternMatchVariance(counters: Int32Array, pattern: Int32Array, maxIndividualVariance: number): number {
        const numCounters = counters.length;
        let total = 0;
        let patternLength = 0;
        for (let i = 0; i < numCounters; i++) {
Severity: Minor
Found in src/core/oned/OneDReader.ts - 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

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

  addBinaryShiftChar(index: int): State {
    let token: Token = this.token;
    let mode: int = this.mode;
    let bitCount: int = this.bitCount;
    if (this.mode === C.MODE_PUNCT || this.mode === C.MODE_DIGIT) {
Severity: Minor
Found in src/core/aztec/encoder/State.ts - 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

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

    private codaBarDecodeRow(row: Array<number>): string {
        const code = [];
        const barThreshold = Math.ceil(
            row.reduce((pre, item) => (pre + item) / 2, 0)
        );
Severity: Minor
Found in src/core/oned/CodaBarReader.ts - 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

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

export function static_CHAR_MAP(CHAR_MAP: Int32Array[]): Int32Array[] {
  const spaceCharCode = StringUtils.getCharCode(' ');
  const pointCharCode = StringUtils.getCharCode('.');
  const commaCharCode = StringUtils.getCharCode(',');

Severity: Minor
Found in src/core/aztec/encoder/CharMap.ts - 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

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

  public encodeWithHints(contents: string, format: BarcodeFormat, width: int, height: int, hints: Map<EncodeHintType, any>): BitMatrix {
    let charset: Charset = StandardCharsets.ISO_8859_1;
    let eccPercent: int = Encoder.DEFAULT_EC_PERCENT;
    let layers: int = Encoder.DEFAULT_AZTEC_LAYERS;
    if (hints != null) {
Severity: Minor
Found in src/core/aztec/AztecWriter.ts - 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

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

  private static renderResult(code: AztecCode, width: int, height: int): BitMatrix {
    let input: BitMatrix = code.getMatrix();
    if (input == null) {
      throw new IllegalStateException();
    }
Severity: Minor
Found in src/core/aztec/AztecWriter.ts - 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

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

    if (incrementOdd) {
      if (decrementOdd) {
        throw new NotFoundException();
      }
      RSSExpandedReader.increment(
Severity: Major
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts and 3 other locations - About 35 mins to fix
src/core/oned/rss/RSS14Reader.ts on lines 404..409
src/core/oned/rss/RSS14Reader.ts on lines 413..418
src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 902..910

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

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

        const stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] +
            stateCount[4];
Severity: Minor
Found in src/core/qrcode/detector/FinderPatternFinder.ts and 2 other locations - About 35 mins to fix
src/core/qrcode/detector/FinderPatternFinder.ts on lines 320..320
src/core/qrcode/detector/FinderPatternFinder.ts on lines 394..395

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

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

Severity
Category
Status
Source
Language