smugglys/translatomatic

View on GitHub
lib/translatomatic/translation/munging.rb

Summary

Maintainability
A
25 mins
Test Coverage

Complex method Translatomatic::Translation::Munging#restore_preserved_text (23.8)
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

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

      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

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

      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|
Severity: Minor
Found in lib/translatomatic/translation/munging.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

There are no issues that match your filters.

Category
Status