smugglys/translatomatic

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

Summary

Maintainability
A
50 mins
Test Coverage

Method save_database_translations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def save_database_translations(translations)
        return unless @use_db
        ActiveRecord::Base.transaction do
          from = db_locale(@from_locale)
          to = db_locale(@to_locale)
Severity: Minor
Found in lib/translatomatic/translation/fetcher.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

Method texts_to_translations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def texts_to_translations(db_texts, texts)
        db_text_map = hashify(db_texts, proc { |i| i.from_text.value })
        texts.collect do |text|
          next unless (db_text = db_text_map[text.to_s])
          @listener.update_progress(1) if @listener
Severity: Minor
Found in lib/translatomatic/translation/fetcher.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