bestmike007/appbase

View on GitHub
lib/appbase/model_concern.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method crud_allow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def crud_allow(crud, criteria=:mine, &block)
        validate_crud crud
        
        if criteria == :mine
          allow_mine crud
Severity: Minor
Found in lib/appbase/model_concern.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 symbol_array_manipulate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def symbol_array_manipulate(op, source, options)
        raise InvalidUsage if op != :only && op != :except
        if options.has_key? op
          operands = options[op]
          operands = [operands] if operands.instance_of?(String) || operands.instance_of?(Symbol)
Severity: Minor
Found in lib/appbase/model_concern.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 show_usage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def show_usage(crud)
        raise %-
          allow_#{crud} usage:
            allow_#{crud} :mine
            allow_#{crud} :#{ crud == :query ? 'within' : 'if' } => :a_singleton_method
Severity: Minor
Found in lib/appbase/model_concern.rb - About 45 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 allow_criteria_with_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def allow_criteria_with_block(crud, block)
        show_usage(crud) if crud == :query && block.parameters.count != 1
        show_usage(crud) if crud != :query && block.parameters.count != 2
        model_inject crud == :query ? :accessible_by : "allow_#{crud}", &block
      end
Severity: Minor
Found in lib/appbase/model_concern.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