riboseinc/id_pack

View on GitHub

Showing 61 of 61 total issues

Method _compress has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
Open

      def _compress(uncompressed, bits_per_char)
        return "" if uncompressed.nil?

        context_dictionary = {}
        context_dictionary_to_create = {}
Severity: Minor
Found in lib/id_pack/lz_string.rb - About 2 days 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

Method _decompress has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
Open

      def _decompress(length, reset_value)
        dictionary = []
        enlarge_in = 4
        dict_size = 4
        num_bits = 3
Severity: Minor
Found in lib/id_pack/lz_string.rb - About 1 day 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

Method _compress has 202 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def _compress(uncompressed, bits_per_char)
        return "" if uncompressed.nil?

        context_dictionary = {}
        context_dictionary_to_create = {}
Severity: Major
Found in lib/id_pack/lz_string.rb - About 1 day 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 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

              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

    File lz_string.rb has 452 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module IdPack
      module LZString
        KEY_STR_BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".freeze
        KEY_STR_URI_SAFE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$".freeze
    
    
    Severity: Minor
    Found in lib/id_pack/lz_string.rb - About 6 hrs to fix

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

                  if context_dictionary_to_create[context_w]
                    if context_w[0].ord < 256
                      context_num_bits.times do |_i|
                        context_data_val = (context_data_val << 1)
      
      
      Severity: Major
      Found in lib/id_pack/lz_string.rb and 1 other location - About 6 hrs to fix
      lib/id_pack/lz_string.rb on lines 253..338

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

      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 context_dictionary_to_create[context_w]
                  if context_w[0].ord < 256
                    context_num_bits.times do |_i|
                      context_data_val = context_data_val << 1
      
      
      Severity: Major
      Found in lib/id_pack/lz_string.rb and 1 other location - About 6 hrs to fix
      lib/id_pack/lz_string.rb on lines 150..235

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

      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

          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

      Function range has 146 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          range: function(start, length) {
      
            /** convert arguments to numbers */
            if (typeof start != 'number') {
              start     = parseInt(start, 10);
      Severity: Major
      Found in app/assets/javascripts/lib/id-packer.js - About 5 hrs to fix

        Method _decompress has 146 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def _decompress(length, reset_value)
                dictionary = []
                enlarge_in = 4
                dict_size = 4
                num_bits = 3
        Severity: Major
        Found in lib/id_pack/lz_string.rb - About 5 hrs to fix

          Method alphanum_compress has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              def alphanum_compress(arr, alphanum_string, order)
                # length of UUID in bits
                uuid_bit_length = 128
          
                # compress without delta
          Severity: Minor
          Found in lib/id_pack/uuid_packer.rb - About 4 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

          Method alphanum_decompress has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def alphanum_decompress(str, alphanum_string)
                # length of UUID in bits
                uuid_bit_length = 128
          
                result = []
          Severity: Minor
          Found in lib/id_pack/uuid_packer.rb - About 4 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

          Method encode has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

              def encode(array, window_size = WINDOW_SIZE, _exclude_nil = EXCLUDE_NIL, output_charset = ENCODED_NUMBER_CHARS)
                encoded_array = ''
          
                ranges = convert_numbers_to_ranges array.uniq.sort
                prev_end = 0
          Severity: Minor
          Found in lib/id_pack/id_packer.rb - 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

          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

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

          /** vim: et:ts=2:sw=2:sts=2
           * @license (c) 2017 Ribose Inc.
           *
           * IdPacker is a library provides encoding support for Number collections (Arrays or Objects).
           *
          Severity: Minor
          Found in app/assets/javascripts/lib/id-packer.js - About 3 hrs to fix

            Function encodeHashKeys has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                encodeHashKeys: function(hash, windowSize, isExcludeNull, outputCharset) {
                  // set default values
                  windowSize    = typeof  windowSize   === "number"  ? windowSize    : this.windowSize;
                  isExcludeNull = typeof isExcludeNull === "boolean" ? isExcludeNull : this.isExcludeNull;
                  outputCharset = typeof outputCharset === "string"  ? outputCharset : this.outputCharset;
            Severity: Major
            Found in app/assets/javascripts/lib/id-packer.js - About 3 hrs to fix

              Method encode has 85 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def encode(array, window_size = WINDOW_SIZE, _exclude_nil = EXCLUDE_NIL, output_charset = ENCODED_NUMBER_CHARS)
                    encoded_array = ''
              
                    ranges = convert_numbers_to_ranges array.uniq.sort
                    prev_end = 0
              Severity: Major
              Found in lib/id_pack/id_packer.rb - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language