rpanachi/core_ext

View on GitHub
lib/core_ext/multibyte/unicode.rb

Summary

Maintainability
D
2 days
Test Coverage

Method compose has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

      def compose(codepoints)
        pos = 0
        eoa = codepoints.length - 1
        starter_pos = 0
        starter_char = codepoints[0]
Severity: Minor
Found in lib/core_ext/multibyte/unicode.rb - About 5 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 unicode.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module CoreExt
  module Multibyte
    module Unicode

      extend self
Severity: Minor
Found in lib/core_ext/multibyte/unicode.rb - About 2 hrs to fix

    Method compose has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def compose(codepoints)
            pos = 0
            eoa = codepoints.length - 1
            starter_pos = 0
            starter_char = codepoints[0]
    Severity: Major
    Found in lib/core_ext/multibyte/unicode.rb - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                if (
                    # CR X LF
                    ( previous == database.boundary[:cr] and current == database.boundary[:lf] ) or
                    # L X (L|V|LV|LVT)
                    ( database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or
      Severity: Critical
      Found in lib/core_ext/multibyte/unicode.rb - About 1 hr to fix

        Method decompose has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def decompose(type, codepoints)
                codepoints.inject([]) do |decomposed, cp|
                  # if it's a hangul syllable starter character
                  if HANGUL_SBASE <= cp and cp < HANGUL_SLAST
                    sindex = cp - HANGUL_SBASE
        Severity: Minor
        Found in lib/core_ext/multibyte/unicode.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 unpack_graphemes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def unpack_graphemes(string)
                codepoints = string.codepoints.to_a
                unpacked = []
                pos = 0
                marker = 0
        Severity: Minor
        Found in lib/core_ext/multibyte/unicode.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 reorder_characters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def reorder_characters(codepoints)
                length = codepoints.length- 1
                pos = 0
                while pos < length do
                  cp1, cp2 = database.codepoints[codepoints[pos]], database.codepoints[codepoints[pos+1]]
        Severity: Minor
        Found in lib/core_ext/multibyte/unicode.rb - About 55 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 tidy_bytes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def tidy_bytes(string, force = false)
                  return string if string.empty?
                  return recode_windows1252_chars(string) if force
        
                  # We can't transcode to the same format, so we choose a nearly-identical encoding.
        Severity: Minor
        Found in lib/core_ext/multibyte/unicode.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

        There are no issues that match your filters.

        Category
        Status