ubcsanskrit/sanscript.rb

View on GitHub

Showing 11 of 22 total issues

Method transliterate_roman has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

      def transliterate_roman(data, map, options = {})
        data = data.to_str.chars
        buf = []
        token_buffer = []
        had_consonant = false
Severity: Minor
Found in lib/sanscript/transliterate.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 transliterate_brahmic has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

      def transliterate_brahmic(data, map)
        data = data.to_str.chars
        buf = []
        had_roman_consonant = false
        transliteration_enabled = true
Severity: Minor
Found in lib/sanscript/transliterate.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

Method transliterate_roman has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def transliterate_roman(data, map, options = {})
        data = data.to_str.chars
        buf = []
        token_buffer = []
        had_consonant = false
Severity: Major
Found in lib/sanscript/transliterate.rb - About 2 hrs to fix

    Method transliterate_brahmic has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def transliterate_brahmic(data, map)
            data = data.to_str.chars
            buf = []
            had_roman_consonant = false
            transliteration_enabled = true
    Severity: Major
    Found in lib/sanscript/transliterate.rb - About 2 hrs to fix

      Method make_map has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def make_map(from, to)
              @cache[:"#{from}_#{to}"] ||= begin
                alternates = @all_alternates[from] || {}
                consonants = {}
                from_scheme = @schemes[from]
      Severity: Minor
      Found in lib/sanscript/transliterate.rb - About 1 hr to fix

        Method transliterate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def transliterate(data, from, to, **opts)
              from = from.to_sym
              to = to.to_sym
              return data if from == to
              raise SchemeNotSupportedError, from unless @schemes.key?(from)
        Severity: Minor
        Found in lib/sanscript/transliterate.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 ruby_detect_scheme has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def ruby_detect_scheme(text) # rubocop:disable AbcSize, PerceivedComplexity
                text = text.to_str.gsub(RE_CONTROL_BLOCK, "")
        
                # Brahmic schemes are all within a specific range of code points.
                brahmic_char = text[RE_BRAHMIC_RANGE]
        Severity: Minor
        Found in lib/sanscript/detect/ruby2x.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 ruby_detect_scheme has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def ruby_detect_scheme(text) # rubocop:disable AbcSize, PerceivedComplexity
                text = text.to_str.gsub(RE_CONTROL_BLOCK, "")
        
                # Brahmic schemes are all within a specific range of code points.
                brahmic_char = text[RE_BRAHMIC_RANGE]
        Severity: Minor
        Found in lib/sanscript/detect/ruby24.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

        Avoid deeply nested control flow statements.
        Open

                        buf << map[:virama] unless options[:syncope]
        Severity: Major
        Found in lib/sanscript/transliterate.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                            if (temp_mark = map[:marks][token])
                              buf << temp_mark
                            elsif token != "a"
                              buf.push(map[:virama], temp_letter)
                            end
          Severity: Major
          Found in lib/sanscript/transliterate.rb - About 45 mins to fix

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

              def rust_load!
                # :nocov:
                return RUST_AVAILABLE if defined?(RUST_AVAILABLE)
                require "thermite/fiddle"
                Thermite::Fiddle.load_module("init_rusty_sanscript",
            Severity: Minor
            Found in lib/sanscript/rust.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