twitter/twitter-cldr-rb

View on GitHub
lib/twitter_cldr/collation/implicit_collation_elements.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method swapCJK has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        def swapCJK(code_point)
          if code_point >= CJK_BASE
            return code_point - CJK_BASE                                      if code_point < CJK_LIMIT
            return code_point + NON_CJK_OFFSET                                if code_point < CJK_COMPAT_USED_BASE
            return code_point - CJK_COMPAT_USED_BASE + (CJK_LIMIT - CJK_BASE) if code_point < CJK_COMPAT_USED_LIMIT
Severity: Minor
Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 2 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

Avoid too many return statements within this method.
Open

            return code_point                                                 if code_point < CJK_D_LIMIT # non-BMP-CJK
Severity: Major
Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

              return code_point - CJK_A_BASE + (CJK_LIMIT - CJK_BASE) + (CJK_COMPAT_USED_LIMIT - CJK_COMPAT_USED_BASE) if code_point < CJK_A_LIMIT
    Severity: Major
    Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return code_point + NON_CJK_OFFSET if code_point < CJK_A_BASE
      Severity: Major
      Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return code_point + NON_CJK_OFFSET # non-CJK
        Severity: Major
        Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return code_point                                                 if code_point < CJK_C_LIMIT # non-BMP-CJK
          Severity: Major
          Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return code_point                                                 if code_point < CJK_B_LIMIT # non-BMP-CJK
            Severity: Major
            Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return code_point + NON_CJK_OFFSET                                if code_point < CJK_D_BASE
              Severity: Major
              Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return code_point + NON_CJK_OFFSET                                if code_point < CJK_C_BASE
                Severity: Major
                Found in lib/twitter_cldr/collation/implicit_collation_elements.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status