SuperSephy/imb

View on GitHub

Showing 45 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

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

                              case 'F':
                                  top[j].style.backgroundColor = '#000';
                                  mid[j].style.backgroundColor = '#000';
                                  btm[j].style.backgroundColor = '#000';
                                  break;
              Severity: Major
              Found in src/lib/formatting.js and 3 other locations - About 1 hr to fix
              src/lib/formatting.js on lines 242..246
              src/lib/formatting.js on lines 247..251
              src/lib/formatting.js on lines 258..262

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

              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 4 locations. Consider refactoring.
              Open

                              case 'S':
                                  top[j].style.backgroundColor = 'transparent';
                                  mid[j].style.backgroundColor = '#000';
                                  btm[j].style.backgroundColor = 'transparent';
                                  break;
              Severity: Major
              Found in src/lib/formatting.js and 3 other locations - About 1 hr to fix
              src/lib/formatting.js on lines 242..246
              src/lib/formatting.js on lines 247..251
              src/lib/formatting.js on lines 252..256

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

              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 4 locations. Consider refactoring.
              Open

                              case 'A':
                                  top[j].style.backgroundColor = '#000';
                                  mid[j].style.backgroundColor = '#000';
                                  btm[j].style.backgroundColor = 'transparent';
                                  break;
              Severity: Major
              Found in src/lib/formatting.js and 3 other locations - About 1 hr to fix
              src/lib/formatting.js on lines 247..251
              src/lib/formatting.js on lines 252..256
              src/lib/formatting.js on lines 258..262

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

              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 4 locations. Consider refactoring.
              Open

                              case 'D':
                                  top[j].style.backgroundColor = 'transparent';
                                  mid[j].style.backgroundColor = '#000';
                                  btm[j].style.backgroundColor = '#000';
                                  break;
              Severity: Major
              Found in src/lib/formatting.js and 3 other locations - About 1 hr to fix
              src/lib/formatting.js on lines 242..246
              src/lib/formatting.js on lines 252..256
              src/lib/formatting.js on lines 258..262

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

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

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

                    } else {
                        decoded_imb.mailer_id = track.slice(5,11).join('');
                        decoded_imb.serial_num = track.slice(11,20).join('');
                    }
                Severity: Major
                Found in src/_decode.js and 1 other location - About 1 hr to fix
                src/_decode.js on lines 158..162

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

                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