SleeplessByte/ruby-multibase

View on GitHub

Showing 8 of 46 total issues

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

    def encode(plain)
      return EncodedByteArray::EMPTY if plain.empty?

      plain = plain.bytes unless plain.is_a?(Array)
      expected_length = @table.encoded_length(plain)
Severity: Minor
Found in lib/multibases/base_x.rb - About 1 hr to fix

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

        def encode(plain)
          return EncodedByteArray::EMPTY if plain.empty?
    
          plain = plain.bytes unless plain.is_a?(Array)
          expected_length = @table.encoded_length(plain)
    Severity: Minor
    Found in lib/multibases/base_x.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method implement has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def implement(encoding, code, implementation = nil, alphabet = nil, alphabet_encoding = nil)
    Severity: Minor
    Found in lib/multibases/registry.rb - About 35 mins to fix

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

          def decode(encoded)
            return DecodedByteArray::EMPTY if encoded.empty?
      
            unless encoded.is_a?(Array)
              encoded = encoded.force_encoding(@table.encoding).bytes
      Severity: Minor
      Found in lib/multibases/base2.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def decode(encoded)
            return DecodedByteArray::EMPTY if encoded.empty?
      
            unless encoded.is_a?(Array)
              encoded = encoded.force_encoding(@table.encoding).bytes
      Severity: Minor
      Found in lib/multibases/base16.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method calculate_encoding has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def calculate_encoding(encoding:)
            invalid_ord = @ords.find { |ord| ord > 255 }
            raise AlphabetOutOfBoundary, invalid_ord if invalid_ord
      
            if encoding
      Severity: Minor
      Found in lib/multibases/ord_table.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def decode(encoded)
            return DecodedByteArray::EMPTY if encoded.empty?
      
            unless encoded.is_a?(Array)
              encoded = encoded.force_encoding(@table.encoding).bytes
      Severity: Minor
      Found in lib/multibases/base64.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

          def decode(encoded)
            return DecodedByteArray::EMPTY if encoded.empty?
      
            unless encoded.is_a?(Array)
              encoded = encoded.force_encoding(@table.encoding).bytes
      Severity: Minor
      Found in lib/multibases/base_x.rb - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language