riboseinc/id_pack

View on GitHub
app/assets/javascripts/lib/uuid-packer.js

Summary

Maintainability
F
1 wk
Test Coverage

Function alpCompress has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    alpCompress: function(arr, alpStr, order) {
      // declare starting values
      var
      alpArr  = alptoArr(alpStr, false), // get alphabet array without delimiter
      nresult = '', // without delta we starting with only one bit
Severity: Major
Found in app/assets/javascripts/lib/uuid-packer.js - About 3 hrs to fix

    Function alpDecompress has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        alpDecompress: function (str, alpStr) {
          // declare starting values
          var
          result = [],
          alpArr = alptoArr(alpStr, false), // get alphabet array without delimiter
    Severity: Major
    Found in app/assets/javascripts/lib/uuid-packer.js - About 2 hrs to fix

      File uuid-packer.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /** vim: et:ts=2:sw=2:sts=2
       * @license (c) 2017 Ribose Inc.
       */
      (function (factory) {
        'use strict';
      Severity: Minor
      Found in app/assets/javascripts/lib/uuid-packer.js - About 2 hrs to fix

        Function alptoArr has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            alptoArr: function(alpStr, del) {
              var
              alpArr = [],
              el     = alpStr.length,
              charItem,
        Severity: Minor
        Found in app/assets/javascripts/lib/uuid-packer.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                        if (code >= lowhi) { powC += 1; } // if we get code of long length symbols
          Severity: Major
          Found in app/assets/javascripts/lib/uuid-packer.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if (code < lowhi) { rest -= 1; }
            Severity: Major
            Found in app/assets/javascripts/lib/uuid-packer.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            while (rest >= 4) { // add new UUID caracters to buffer
                              rest  -= 4; // decrease number of bits in BBC
                              item   = (achr & 15).toString(16) + item; // add new UUID character
                              achr >>= 4; // remove used bits from BBC
                            }
              Severity: Major
              Found in app/assets/javascripts/lib/uuid-packer.js - About 45 mins to fix

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

                          while (rest >= pow) { // create symbols to compressed string
                            powC = pow - 1; // try with a short symbol length
                            code = parseInt(revString(((achr & ((1 << powC) - 1)) + (1 << powC)).toString(2)), 2) >> 1;
                
                            if (code >= lowhi) {powC += 1; } // if we get code of long length symbols
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 7 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 238..248

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

                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

                            while (rest >= pow) { // create symbols to compressed string 
                              powC = pow - 1; // try with a short symbol length
                              code = parseInt(revString(((achr & ((1 << powC) - 1)) + (1 << powC)).toString(2)), 2) >> 1;
                
                              if (code >= lowhi) { powC += 1; } // if we get code of long length symbols
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 7 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 187..197

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

                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

                    subHexStr: function(fnum, snum) {
                      var
                      delta  = 0,
                      result = '',
                      i, sum;
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 5 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 76..93

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

                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

                    addHexStr: function(fnum, snum) {
                      var
                      delta  = 0,
                      result = '',
                      i, sum;
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 5 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 96..113

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

                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 (rest > 0) { // check if we have tail of BBC for current UUID
                            code   = parseInt(revString(((achr & ((1 << rest) - 1)) + (1 << rest)).toString(2)), 2) >> 1; // try with a short symbol length
                            code <<= (pow - rest - 1); // add zeros to get valid symbol code
                
                            if (code >= lowhi) { code <<= 1; } // if we get code of long length symbols
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 201..208

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

                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 (rest > 0) { // check if we have tail of BBC
                        code   = parseInt(revString(((achr & ((1 << rest) - 1)) + (1 << rest)).toString(2)), 2) >> 1; // get reverse bits of BBC to create new symbol
                        code <<= (pow - rest - 1); // add zeros to get valid symbol code
                
                        if (code >= lowhi) { code <<= 1; } // if we get code of long length symbols
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 250..257

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

                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

                (function (factory) {
                  'use strict';
                
                  /* AMD. Register as an anonymous module. */
                  if (typeof define === 'function' && define.amd) {
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/lib/id-packer.js on lines 73..591

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

                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

                            if (UNIT_LEN === 32) { // add '-' characters if we work with UUID
                              curr = curr.substr(0, 8) + '-' + curr.substr(8, 4) + '-' + curr.substr(12, 4) + '-' + curr.substr(16, 4) + '-' + curr.substr(20, 12);
                            }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 339..341

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

                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

                            if (UNIT_LEN === 32) { // add '-' characters if we work with UUID
                              curr = curr.substr(0, 8) + '-' + curr.substr(8, 4) + '-' + curr.substr(12, 4) + '-' + curr.substr(16, 4) + '-' + curr.substr(20, 12);
                            }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 312..314

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

                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

                    rassoc: function(arr, value) {
                      var i;
                      for (i = 0; i < arr.length; i += 1) {
                        if (arr[i][1] === value) { return arr[i][0]; }
                      }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 52..57

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

                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

                    assoc: function(arr, value) {
                      var i;
                      for (i = 0; i < arr.length; i += 1) {
                        if (arr[i][0] === value) { return arr[i][1]; }
                      }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 2 hrs to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 60..65

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

                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

                          code  = parseInt(revString((rassoc(alpArr, str.charAt(i)) + (1 << tassoc(alpArr, str.charAt(i)))).toString(2)), 2) >> 1; // reverse symbol code to BBC bits
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 352..352

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

                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

                              code  = parseInt(revString((rassoc(alpArr, str.charAt(i)) + (1 << tassoc(alpArr, str.charAt(i)))).toString(2)), 2) >> 1; // reverse symbol code to BBC bits
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 294..294

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

                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

                          while (rest >= 4) { // add new UUID caracters to buffer
                            rest -= 4; // decrease BBC length
                            item = (achr & 15).toString(16) + item; // add new UUID character
                            achr >>= 4; // remove used bits from BBC
                          }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 358..362

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

                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

                              while (rest >= 4) { // add new UUID caracters to buffer
                                rest  -= 4; // decrease number of bits in BBC
                                item   = (achr & 15).toString(16) + item; // add new UUID character
                                achr >>= 4; // remove used bits from BBC
                              }
                Severity: Major
                Found in app/assets/javascripts/lib/uuid-packer.js and 1 other location - About 1 hr to fix
                app/assets/javascripts/lib/uuid-packer.js on lines 304..308

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

                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

                There are no issues that match your filters.

                Category
                Status