ubcsanskrit/sanscript.rb

View on GitHub
lib/sanscript/transliterate.rb

Summary

Maintainability
D
2 days
Test Coverage

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

        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

            There are no issues that match your filters.

            Category
            Status