SuperSephy/imb

View on GitHub

Showing 30 of 49 total issues

Function promptForSpecifics has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

async function promptForSpecifics(options) {
    const questions = [];

    if (options.type === 'decode' && !options.barcode) {
        questions.push({
Severity: Minor
Found in cli.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 promptForSpecifics has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function promptForSpecifics(options) {
    const questions = [];

    if (options.type === 'decode' && !options.barcode) {
        questions.push({
Severity: Major
Found in cli.js - About 4 hrs to fix

    Function decodeCharacters has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function decodeCharacters(chars) {
        // decode characters to codewords.
        // this is the core of the barcode processing.
    
        let fcs = 0;
    Severity: Minor
    Found in src/_decode.js - About 3 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 check_encode_input has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function check_encode_input(encode_input, callback) {
        _.mapObject(encode_input, cleanString);
    
        // Zip Code is optional, but must be 5 | 9 digits
        if (encode_input.zip) {
    Severity: Minor
    Found in src/_encode.js - About 3 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_barcode has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    function decode_barcode(barcode, callback) {
        let chars, decoded_imb;
    
        barcode = cleanString(barcode);
    
    
    Severity: Minor
    Found in src/_decode.js - 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 decodeCharacters has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function decodeCharacters(chars) {
        // decode characters to codewords.
        // this is the core of the barcode processing.
    
        let fcs = 0;
    Severity: Major
    Found in src/_decode.js - About 2 hrs to fix

      Function encode_fields has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function encode_fields(imb_fields, callback) {
          let n;
          let num     = [0,0,0,0,0,0,0,0,0,0];
          let marker  = 0;
      
      
      Severity: Minor
      Found in src/_encode.js - About 1 hr to fix

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

        function repairCharacters(chars) {
            let prod = 1;
            let possible = new Array(10);
        
            for (let n = 0; n < 10; n++) {
        Severity: Minor
        Found in src/_decode.js - 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 showBarCode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            showBarCode: function showBarCode(barcode) {
                const top = document.getElementById('row0').cells;
                const mid = document.getElementById('row1').cells;
                const btm = document.getElementById('row2').cells;
        
        
        Severity: Minor
        Found in src/lib/formatting.js - About 1 hr to fix

          Function repairBarcode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function repairBarcode(barcode) {
              let longer;
          
              if (barcode.length === 64) {
                  longer = true;
          Severity: Minor
          Found in src/_decode.js - 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 tryRepair has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function tryRepair(possible, chars, pos) {
              let inf = null, newinf;
          
              for (let n = 0; n < possible[pos].length; n++) {
                  chars[pos] = possible[pos][n];
          Severity: Minor
          Found in src/_decode.js - 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 check_encode_input has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function check_encode_input(encode_input, callback) {
              _.mapObject(encode_input, cleanString);
          
              // Zip Code is optional, but must be 5 | 9 digits
              if (encode_input.zip) {
          Severity: Minor
          Found in src/_encode.js - About 1 hr to fix

            Function decode_barcode has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function decode_barcode(barcode, callback) {
                let chars, decoded_imb;
            
                barcode = cleanString(barcode);
            
            
            Severity: Minor
            Found in src/_decode.js - About 1 hr to fix

              Function build_codewords has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  buildCodeWords: function build_codewords(bits, low, hi) {
              
                      // loop through all possible 13-bit codewords
                      for (let fwd = 0; fwd < 8192; fwd++) {
                          // build reversed codeword and count population of 1-bits
              Severity: Minor
              Found in src/lib/formatting.js - About 1 hr to fix

                Function encode_fields has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function encode_fields(imb_fields, callback) {
                    let n;
                    let num     = [0,0,0,0,0,0,0,0,0,0];
                    let marker  = 0;
                
                
                Severity: Minor
                Found in src/_encode.js - 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 charactersToText has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    charactersToText: function charactersToText(chars) {
                        let barcode = "";
                
                        for (let n = 0; n < 65; n++) {
                            if (chars[desc_char[n]] & desc_bit[n]) {
                Severity: Minor
                Found in src/lib/formatting.js - 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 repairBarcode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function repairBarcode(barcode) {
                    let longer;
                
                    if (barcode.length === 64) {
                        longer = true;
                Severity: Minor
                Found in src/_decode.js - About 1 hr to fix

                  Function build_codewords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      buildCodeWords: function build_codewords(bits, low, hi) {
                  
                          // loop through all possible 13-bit codewords
                          for (let fwd = 0; fwd < 8192; fwd++) {
                              // build reversed codeword and count population of 1-bits
                  Severity: Minor
                  Found in src/lib/formatting.js - About 45 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

                  Avoid too many return statements within this function.
                  Open

                          return "Mailer ID must be 6 or 9 digits";
                  Severity: Major
                  Found in src/_encode.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        if (callback) return callback("Invalid barcode");
                    Severity: Major
                    Found in src/_decode.js - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language