zxing-js/library

View on GitHub

Showing 958 of 958 total issues

RSSExpandedReader has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class RSSExpandedReader extends AbstractRSSReader {
  private static readonly SYMBOL_WIDEST = [7, 5, 4, 3, 1];
  private static readonly EVEN_TOTAL_SUBSET = [4, 20, 52, 104, 204];
  private static readonly GSUM = [0, 348, 1388, 2948, 3988];

Severity: Minor
Found in src/core/oned/rss/expanded/RSSExpandedReader.ts - About 2 hrs to fix

    Function getC40Words has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getC40Words(c40: boolean, fnc1: number): Uint8Array {
        const c40Values = [];
        for (let i = 0; i < this.characterLength; i++) {
          const ci = this.input.charAt(this.fromPosition + i);
          if (
    Severity: Major
    Found in src/core/datamatrix/encoder/MinimalEncoder.ts - About 2 hrs to fix

      Function selectBestPatterns has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private selectBestPatterns(): FinderPattern[] /*throws NotFoundException */ {
      
              const startSize = this.possibleCenters.length;
              if (startSize < 3) {
                  // Couldn't find enough finder patterns
      Severity: Major
      Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

        Function encodeHighLevel has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static encodeHighLevel(
            msg: string,
            shape = SymbolShapeHint.FORCE_NONE,
            minSize: Dimension = null,
            maxSize: Dimension = null,
        Severity: Major
        Found in src/core/datamatrix/encoder/HighLevelEncoder.ts - About 2 hrs to fix

          Function encode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public encode(context: EncoderContext) {
              // step B
              const n = HighLevelEncoder.determineConsecutiveDigitCount(
                context.getMessage(),
                context.pos
          Severity: Major
          Found in src/core/datamatrix/encoder/ASCIIEncoder.ts - About 2 hrs to fix

            Function crossCheckVertical has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private crossCheckVertical(startI: number /*int*/, centerJ: number /*int*/, maxCount: number /*int*/,
                    originalStateCountTotal: number /*int*/): number/*float*/ {
                    const image: BitMatrix = this.image;
            
                    const maxI = image.getHeight();
            Severity: Major
            Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

              Function decode has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static decode(codewords: Int32Array, ecLevel: string): DecoderResult {
                  // pass encoding to result (will be used for decode symbols in byte mode)
                  let result: StringBuilder = new StringBuilder('');
                  // let encoding: Charset = StandardCharsets.ISO_8859_1;
                  let encoding = CharacterSetECI.ISO8859_1;
              Severity: Major
              Found in src/core/pdf417/decoder/DecodedBitStreamParser.ts - About 2 hrs to fix

                Function crossCheckHorizontal has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private crossCheckHorizontal(startJ: number /*int*/, centerI: number /*int*/, maxCount: number /*int*/,
                        originalStateCountTotal: number /*int*/): number/*float*/ {
                        const image: BitMatrix = this.image;
                
                        const maxJ = image.getWidth();
                Severity: Major
                Found in src/core/qrcode/detector/FinderPatternFinder.ts - About 2 hrs to fix

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

                          if (outsideChar) {
                              if (oddSum > 12) {
                                  decrementOdd = true;
                              }
                              else if (oddSum < 4) {
                  Severity: Major
                  Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 2 hrs to fix
                  src/core/oned/rss/RSS14Reader.ts on lines 336..349

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

                  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

                          else {
                              if (oddSum > 11) {
                                  decrementOdd = true;
                              }
                              else if (oddSum < 5) {
                  Severity: Major
                  Found in src/core/oned/rss/RSS14Reader.ts and 1 other location - About 2 hrs to fix
                  src/core/oned/rss/RSS14Reader.ts on lines 322..335

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

                  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

                  File Encoder.ts has 254 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import BitArray from '../../common/BitArray';
                  import IllegalArgumentException from '../../IllegalArgumentException';
                  import StringUtils from '../../common/StringUtils';
                  import BitMatrix from '../../common/BitMatrix';
                  import AztecCode from './AztecCode';
                  Severity: Minor
                  Found in src/core/aztec/encoder/Encoder.ts - About 2 hrs to fix

                    Function extractDataRegion has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private extractDataRegion(bitMatrix: BitMatrix): BitMatrix {
                        const symbolSizeRows = this.version.getSymbolSizeRows();
                        const symbolSizeColumns = this.version.getSymbolSizeColumns();
                    
                        if (bitMatrix.getHeight() !== symbolSizeRows) {
                    Severity: Minor
                    Found in src/core/datamatrix/decoder/BitMatrixParser.ts - About 2 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 decodeAnsiX12Segment has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private static decodeAnsiX12Segment(bits: BitSource,
                                                               result: StringBuilder): void {
                        // Three ANSI X12 values are encoded in a 16-bit value as
                        // (1600 * C1) + (40 * C2) + C3 + 1
                    
                    
                    Severity: Minor
                    Found in src/core/datamatrix/decoder/DecodedBitStreamParser.ts - About 2 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 encode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public encode(context: EncoderContext): void {
                        // step C
                        const buffer = new StringBuilder();
                        while (context.hasMoreCharacters()) {
                          const c = context.getCurrentChar();
                    Severity: Minor
                    Found in src/core/datamatrix/encoder/C40Encoder.ts - About 2 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 interleaveWithECBytes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static interleaveWithECBytes(bits: BitArray,
                            numTotalBytes: number /*int*/,
                            numDataBytes: number /*int*/,
                            numRSBlocks: number /*int*/): BitArray /*throws WriterException*/ {
                    
                    
                    Severity: Minor
                    Found in src/core/qrcode/encoder/Encoder.ts - About 2 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 addMissingRows has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      addMissingRows(missingStartRows: int, missingEndRows: int, isLeft: boolean): BoundingBox {
                        let newTopLeft: ResultPoint = this.topLeft;
                        let newBottomLeft: ResultPoint = this.bottomLeft;
                        let newTopRight: ResultPoint = this.topRight;
                        let newBottomRight: ResultPoint = this.bottomRight;
                    Severity: Minor
                    Found in src/core/pdf417/decoder/BoundingBox.ts - About 2 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 getBlackRow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public getBlackRow(y: number /*int*/, row: BitArray): BitArray /*throws NotFoundException*/ {
                            const source = this.getLuminanceSource();
                            const width = source.getWidth();
                            if (row === undefined || row === null || row.getSize() < width) {
                                row = new BitArray(width);
                    Severity: Minor
                    Found in src/core/common/GlobalHistogramBinarizer.ts - About 2 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 decodeRow has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public decodeRow(rowNumber: number, row: BitArray, hints?: Map<DecodeHintType, any>): Result {
                        let theCounters = this.counters;
                        theCounters.fill(0);
                        this.decodeRowResult = '';
                    
                    
                    Severity: Minor
                    Found in src/core/oned/Code39Reader.ts - About 2 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 decode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public decode(image: BinaryBitmap, hints?: Map<DecodeHintType, any>): Result {
                            try {
                                return this.doDecode(image, hints);
                            } catch (nfe) {
                                const tryHarder = hints && (hints.get(DecodeHintType.TRY_HARDER) === true);
                    Severity: Minor
                    Found in src/core/oned/OneDReader.ts - About 2 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 getRSSvalue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public static getRSSvalue(widths: number[], maxWidth: number, noNarrow: boolean): number {
                        let n = 0;
                        for (let width of widths) {
                          n += width;
                        }
                    Severity: Minor
                    Found in src/core/oned/rss/RSSUtils.ts - About 2 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

                    Severity
                    Category
                    Status
                    Source
                    Language