riboseinc/id_pack

View on GitHub

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

    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

      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

          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

                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

                  Method alphanum_decompress has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def alphanum_decompress(str, alphanum_string)
                        # length of UUID in bits
                        uuid_bit_length = 128
                  
                        result = []
                  Severity: Major
                  Found in lib/id_pack/uuid_packer.rb - About 3 hrs to fix

                    Method alphanum_compress has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def alphanum_compress(arr, alphanum_string, order)
                          # length of UUID in bits
                          uuid_bit_length = 128
                    
                          # compress without delta
                    Severity: Major
                    Found in lib/id_pack/uuid_packer.rb - 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 id_packer.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module IdPack
                        
                          # This is a module to encode an integer array into our compressed format.
                          # Basically there are only 2 methods in this module, encode and decode.
                          #
                        Severity: Minor
                        Found in lib/id_pack/id_packer.rb - 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

                            Method decode has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def decode(encoded_caches)
                                  curr_encoded_string_prefix = nil
                            
                                  ids = []
                                  start_id = 0
                            Severity: Minor
                            Found in lib/id_pack/id_packer.rb - 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

                            Method alphanum_to_array has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def alphanum_to_array(alphanum_string, del)
                            
                                  alphanum_array = []
                                  el = alphanum_string.length
                            
                            
                            Severity: Minor
                            Found in lib/id_pack/uuid_packer.rb - 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

                            Severity
                            Category
                            Status
                            Source
                            Language