openjaf/cenit

View on GitHub
app/models/setup/deletion.rb

Summary

Maintainability
C
1 day
Test Coverage

Method run has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    def run(message)
      data_type = data_type_from(message)
      if data_type
        if data_type.bulkable_deletable?
          if (model = data_type.records_model)
Severity: Minor
Found in app/models/setup/deletion.rb - About 5 hrs 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 run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(message)
      data_type = data_type_from(message)
      if data_type
        if data_type.bulkable_deletable?
          if (model = data_type.records_model)
Severity: Minor
Found in app/models/setup/deletion.rb - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                    next unless step_count >= step_size
    Severity: Major
    Found in app/models/setup/deletion.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      record.destroy unless record == self
      Severity: Major
      Found in app/models/setup/deletion.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if scope.is_a?(Mongoid::Criteria)
                        scope.delete_all
                      else
                        scope.delete_many
                      end
        Severity: Major
        Found in app/models/setup/deletion.rb - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status