lib/translatomatic/translation/munging.rb
Complex method Translatomatic::Translation::Munging#restore_preserved_text (23.8) Open
Open
def restore_preserved_text(tr)
preserve_regex = tr.original.preserve_regex
return true unless preserve_regex
# find parts to preserve in the original string
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Translatomatic::Translation::Munging#remove_notranslate (22.5) Open
Open
def remove_notranslate(tr)
return tr unless tr.original.preserve_regex
original_spacing = find_notranslate_spacing(tr.original)
result_spacing = find_notranslate_spacing(tr.result)
if original_spacing.length != result_spacing.length
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method wrap_notranslate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def wrap_notranslate(texts)
return texts unless use_notranslate? && texts.any?(&:preserve_regex)
texts.collect do |text|
if text.preserve_regex
text.gsub(text.preserve_regex) do |i|
- 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"