rubinius/rubinius

View on GitHub
core/encoding.rb

Summary

Maintainability
F
4 days
Test Coverage

Method initialize has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(from, to, options=undefined)
      @source_encoding = Rubinius::Type.coerce_to_encoding from
      @destination_encoding = Rubinius::Type.coerce_to_encoding to

      if options.kind_of? Fixnum
Severity: Minor
Found in core/encoding.rb - About 6 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 encoding.rb has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class EncodingError < StandardError
end

class Encoding
  class UndefinedConversionError < EncodingError
Severity: Minor
Found in core/encoding.rb - About 6 hrs to fix

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

        def last_error
          error = Rubinius.invoke_primitive :encoding_converter_last_error, self
          return if error.nil?
    
          result = error[:result]
    Severity: Minor
    Found in core/encoding.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 search has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.search(source, target)
            if entry = TranscodingMap[source]
              if entry[target]
                return [source, target]
              else
    Severity: Minor
    Found in core/encoding.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 last_error has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def last_error
          error = Rubinius.invoke_primitive :encoding_converter_last_error, self
          return if error.nil?
    
          result = error[:result]
    Severity: Major
    Found in core/encoding.rb - About 2 hrs to fix

      Method initialize has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(from, to, options=undefined)
            @source_encoding = Rubinius::Type.coerce_to_encoding from
            @destination_encoding = Rubinius::Type.coerce_to_encoding to
      
            if options.kind_of? Fixnum
      Severity: Major
      Found in core/encoding.rb - About 2 hrs to fix

        Method primitive_convert has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def primitive_convert(source, target, offset=nil, size=nil, options=0)
              source = StringValue(source) if source
              target = StringValue(target)
        
              if offset.nil?
        Severity: Minor
        Found in core/encoding.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

        Method primitive_convert has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def primitive_convert(source, target, offset=nil, size=nil, options=0)
              source = StringValue(source) if source
              target = StringValue(target)
        
              if offset.nil?
        Severity: Minor
        Found in core/encoding.rb - About 1 hr to fix

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

              def primitive_convert(source, target, offset=nil, size=nil, options=0)
          Severity: Minor
          Found in core/encoding.rb - About 35 mins to fix

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

                  def self.[](source, target)
                    key = "[#{source}, #{target}]"
            
                    path, converters = paths[key]
            
            
            Severity: Minor
            Found in core/encoding.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 convpath has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def convpath
                  path = []
                  a = 0
                  b = @convpath.size - 1
            
            
            Severity: Minor
            Found in core/encoding.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 asciicompat_encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.asciicompat_encoding(string_or_encoding)
                  encoding = Rubinius::Type.try_convert_to_encoding string_or_encoding
            
                  return if not encoding or undefined.equal? encoding
                  return if encoding.ascii_compatible?
            Severity: Minor
            Found in core/encoding.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

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

              def self.aliases
                aliases = {}
                EncodingMap.each do |n, r|
                  index = r.last
                  next unless index
            Severity: Minor
            Found in core/encoding.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

            There are no issues that match your filters.

            Category
            Status