glebm/i18n-tasks

View on GitHub
lib/i18n/tasks/references.rb

Summary

Maintainability
A
3 hrs
Test Coverage
A
97%

Method process_references has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def process_references(usages,
                           data_refs = merge_reference_trees(data_forest.select_keys { |_, node| node.reference? }))
      fail ArgumentError, 'usages must be a Data::Tree::Instance' unless usages.is_a?(Data::Tree::Siblings)
      fail ArgumentError, 'all_references must be a Data::Tree::Instance' unless data_refs.is_a?(Data::Tree::Siblings)

Severity: Minor
Found in lib/i18n/tasks/references.rb - About 1 hr 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 process_non_leaf! has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def process_non_leaf!(ref, usage, raw_refs, resolved_refs, refs)
Severity: Minor
Found in lib/i18n/tasks/references.rb - About 35 mins to fix

    Method process_leaf! has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def process_leaf!(ref, usage, raw_refs, resolved_refs, refs)
    Severity: Minor
    Found in lib/i18n/tasks/references.rb - About 35 mins to fix

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

          def merge_reference_trees(roots)
            roots.inject(empty_forest) do |forest, root|
              root.keys do |full_key, node|
                if full_key == node.value.to_s
                  log_warn(
      Severity: Minor
      Found in lib/i18n/tasks/references.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