af83/chouette-core

View on GitHub
app/lib/policy/base.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Class Base has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Base
    class << self
      def strategy_classes
        @strategy_classes ||= {}
      end
Severity: Minor
Found in app/lib/policy/base.rb - About 2 hrs to fix

    Method context_class_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def context_class_for(action)
            context_class = action.nil? ? nil : context_class(nil)
            strategy_classes[action]&.each do |s|
              next unless s.context_class
    
    
    Severity: Minor
    Found in app/lib/policy/base.rb - About 55 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 apply_strategies_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def apply_strategies_for(key, action, *args)
          return true unless strategies.key?(key)
    
          strategies[key].all? do |s|
            s.apply(action, *args).tap do |result|
    Severity: Minor
    Found in app/lib/policy/base.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