lib/twitter_cldr/collation/implicit_collation_elements.rb
Method swapCJK
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
return code_point + NON_CJK_OFFSET # non-CJK
Avoid too many return
statements within this method. Open
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
Avoid too many return
statements within this method. Open
Open
return code_point if code_point < CJK_C_LIMIT # non-BMP-CJK
Avoid too many return
statements within this method. Open
Open
return code_point if code_point < CJK_D_LIMIT # non-BMP-CJK
Avoid too many return
statements within this method. Open
Open
return code_point + NON_CJK_OFFSET if code_point < CJK_C_BASE
Avoid too many return
statements within this method. Open
Open
return code_point + NON_CJK_OFFSET if code_point < CJK_D_BASE
Avoid too many return
statements within this method. Open
Open
return code_point + NON_CJK_OFFSET if code_point < CJK_A_BASE
Avoid too many return
statements within this method. Open
Open
return code_point if code_point < CJK_B_LIMIT # non-BMP-CJK