next-l/enju_leaf

View on GitHub
app/policies/profile_policy.rb

Summary

Maintainability
B
5 hrs
Test Coverage
A
90%

Method destroy? has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy?
    return false unless user
    return false unless user.try(:has_role?, 'Librarian')

    if record.user
Severity: Minor
Found in app/policies/profile_policy.rb - About 3 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 show? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def show?
    case user.try(:role).try(:name)
    when 'Administrator'
      true
    when 'Librarian'
Severity: Minor
Found in app/policies/profile_policy.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

Avoid deeply nested control flow statements.
Open

            true if record.user.deletable_by?(user)
Severity: Major
Found in app/policies/profile_policy.rb - About 45 mins to fix

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

      def update?
        case user.try(:role).try(:name)
        when 'Administrator'
          true
        when 'Librarian'
    Severity: Minor
    Found in app/policies/profile_policy.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