znamenica/dneslov

View on GitHub
app/models/concerns/total_size.rb

Summary

Maintainability
C
1 day
Test Coverage
F
8%

Method total_size has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

   def total_size
      model = self.name.constantize
      rela = self.except(:limit, :offset)
      return totals(rela) #TODO
      pure = rela.except(:group, :order, :select, :joins, :left_outer_joins)
Severity: Minor
Found in app/models/concerns/total_size.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 total_size has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

   def total_size
      model = self.name.constantize
      rela = self.except(:limit, :offset)
      return totals(rela) #TODO
      pure = rela.except(:group, :order, :select, :joins, :left_outer_joins)
Severity: Major
Found in app/models/concerns/total_size.rb - About 3 hrs to fix

    Method proceed_joins has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

       def proceed_joins joins, default_type = :inner
          joins.reduce({}) do |res, join|
             _outer = false
    
             name =
    Severity: Minor
    Found in app/models/concerns/total_size.rb - About 35 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

    unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

                ref.respond_to?(:source_reflection_name) && ref.source_reflection_name || ref&.name
    Severity: Minor
    Found in app/models/concerns/total_size.rb by rubocop

    unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
    Open

             x.match(/(?<tab>.*)\.\w* as (?:#{types.join("|")})/i)&.[](:tab)&.strip
    Severity: Minor
    Found in app/models/concerns/total_size.rb by rubocop

    There are no issues that match your filters.

    Category
    Status