zxing-js/library

View on GitHub

Showing 958 of 958 total issues

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

      if ((i & 0x01) === 0) {
        oddCounts[offset] = count;
        oddRoundingErrors[offset] = value - count;
      } else {
        evenCounts[offset] = count;
Severity: Major
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts and 1 other location - About 1 hr to fix
src/core/oned/rss/RSS14Reader.ts on lines 185..191

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

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 ((i & 0x01) === 0) {
                oddCounts[offset] = count;
                oddRoundingErrors[offset] = value - count;
            } else {
                evenCounts[offset] = count;
Severity: Major
Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 1 hr to fix
src/core/oned/rss/expanded/RSSExpandedReader.ts on lines 758..764

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

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

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

    public static quadrilateralToSquare(
        x0: number/*float*/, y0: number/*float*/,
        x1: number/*float*/, y1: number/*float*/,
        x2: number/*float*/, y2: number/*float*/,
        x3: number/*float*/, y3: number/*float*/
Severity: Major
Found in src/core/common/PerspectiveTransform.ts and 1 other location - About 1 hr to fix
src/core/common/PerspectiveTransform.ts on lines 96..128

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

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

Function default has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (config) {
    config.set({

        basePath: '',

Severity: Minor
Found in karma.conf.js - About 1 hr to fix

    Function adjustCompleteIndicatorColumnRowNumbers has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      adjustCompleteIndicatorColumnRowNumbers(barcodeMetadata: BarcodeMetadata): void {
        let codewords: Codeword[] = this.getCodewords();
        this.setRowNumbers();
        this.removeIncorrectCodewords(codewords, barcodeMetadata);
        let boundingBox: BoundingBox = this.getBoundingBox();
    Severity: Minor
    Found in src/core/pdf417/decoder/DetectionResultRowIndicatorColumn.ts - About 1 hr to fix

      Function getMinSymbolSize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        getMinSymbolSize(minimum: number): number {
          switch (this.input.getShapeHint()) {
            case SymbolShapeHint.FORCE_SQUARE:
              for (const capacity of this.squareCodewordCapacities) {
                if (capacity >= minimum) {
      Severity: Minor
      Found in src/core/datamatrix/encoder/MinimalEncoder.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 toGrayscaleBuffer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          private static toGrayscaleBuffer(imageBuffer: Uint8ClampedArray, width: number, height: number): Uint8ClampedArray {
              const grayscaleBuffer = new Uint8ClampedArray(width * height);
              HTMLCanvasElementLuminanceSource.FRAME_INDEX = !HTMLCanvasElementLuminanceSource.FRAME_INDEX;
              if(HTMLCanvasElementLuminanceSource.FRAME_INDEX)
              {
      Severity: Minor
      Found in src/browser/HTMLCanvasElementLuminanceSource.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 handleEOD has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        private handleEOD(context: EncoderContext, buffer: StringBuilder) {
          try {
            const count = buffer.length();
            if (count === 0) {
              return; // Already finished
      Severity: Minor
      Found in src/core/datamatrix/encoder/EdifactEncoder.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 findGuardPattern has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        private static findGuardPattern( matrix: BitMatrix,
                                               column: /*int*/ number,
                                               row: /*int*/ number,
                                               width: /*int*/ number,
                                               whiteFirst: boolean,
      Severity: Minor
      Found in src/core/pdf417/detector/Detector.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 encode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public encode(context: EncoderContext) {
          const buffer = new StringBuilder();
          buffer.append(0o0); // Initialize length field
          while (context.hasMoreCharacters()) {
            const c = context.getCurrentChar();
      Severity: Minor
      Found in src/core/datamatrix/encoder/Base256Encoder.ts - About 1 hr to fix

        Function getLatchBytes has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getLatchBytes(): Uint8Array {
            switch (this.getPreviousMode()) {
              case Mode.ASCII:
              case Mode.B256: // after B256 ends (via length) we are back to ASCII
                switch (this.mode) {
        Severity: Minor
        Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 1 hr to fix

          Function getEnclosingRectangle has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public getEnclosingRectangle(): Int32Array {
                  const width = this.width;
                  const height = this.height;
                  const rowSize = this.rowSize;
                  const bits = this.bits;
          Severity: Minor
          Found in src/core/common/BitMatrix.ts - About 1 hr to fix

            Function constructor has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public constructor(hints?: Map<DecodeHintType, any>) {
                super();
                const possibleFormats = !hints ? null : <BarcodeFormat[]>hints.get(DecodeHintType.POSSIBLE_FORMATS);
                const useCode39CheckDigit = hints && hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) !== undefined;
                const useCode39ExtendedMode = hints && hints.get(DecodeHintType.ENABLE_CODE_39_EXTENDED_MODE) !== undefined;
            Severity: Minor
            Found in src/core/oned/MultiFormatOneDReader.ts - About 1 hr to fix

              Function estimateBlackPoint has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static estimateBlackPoint(buckets: Int32Array): number /*int*/ /*throws NotFoundException*/ {
                      // Find the tallest peak in the histogram.
                      const numBuckets = buckets.length;
                      let maxBucketCount = 0;
                      let firstPeak = 0;
              Severity: Minor
              Found in src/core/common/GlobalHistogramBinarizer.ts - About 1 hr to fix

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

                    private distanceResultPoint(a: ResultPoint, b: ResultPoint): number {
                        return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
                    }
                Severity: Major
                Found in src/core/aztec/detector/Detector.ts and 1 other location - About 1 hr to fix
                src/core/aztec/detector/Detector.ts on lines 594..596

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

                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

                    public rotateCounterClockwise(): BinaryBitmap {
                        const newSource: LuminanceSource = this.binarizer.getLuminanceSource().rotateCounterClockwise();
                        return new BinaryBitmap(this.binarizer.createBinarizer(newSource));
                    }
                Severity: Major
                Found in src/core/BinaryBitmap.ts and 1 other location - About 1 hr to fix
                src/core/BinaryBitmap.ts on lines 137..140

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

                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 (result[4] != null) {
                      startColumn = <int> Math.trunc(result[4].getX());
                      startRow = <int> Math.trunc(result[4].getY());
                    }
                Severity: Major
                Found in src/core/pdf417/detector/Detector.ts and 1 other location - About 1 hr to fix
                src/core/pdf417/detector/Detector.ts on lines 137..143

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

                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 (codewordsRow > 1) {
                      otherCodewords[8] = codewords[codewordsRow - 2];
                      otherCodewords[10] = previousColumnCodewords[codewordsRow - 2];
                      otherCodewords[11] = nextColumnCodewords[codewordsRow - 2];
                    }
                Severity: Major
                Found in src/core/pdf417/decoder/DetectionResult.ts and 1 other location - About 1 hr to fix
                src/core/pdf417/decoder/DetectionResult.ts on lines 215..219

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

                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 (codewordsRow > 0) {
                      otherCodewords[0] = codewords[codewordsRow - 1];
                      otherCodewords[4] = previousColumnCodewords[codewordsRow - 1];
                      otherCodewords[5] = nextColumnCodewords[codewordsRow - 1];
                    }
                Severity: Major
                Found in src/core/pdf417/decoder/DetectionResult.ts and 1 other location - About 1 hr to fix
                src/core/pdf417/decoder/DetectionResult.ts on lines 220..224

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

                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 (vertices[2] != null) {
                        column = <int> Math.trunc(vertices[2].getX());
                        row = <int> Math.trunc(vertices[2].getY());
                      } else {
                        column = <int> Math.trunc(vertices[4].getX());
                Severity: Major
                Found in src/core/pdf417/detector/Detector.ts and 1 other location - About 1 hr to fix
                src/core/pdf417/detector/Detector.ts on lines 172..175

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

                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