lib/volt/models/permissions.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method run_permissions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def run_permissions(action_name = nil)
        compute_allow_and_deny(action_name).then do

          errors = {}

Severity: Minor
Found in lib/volt/models/permissions.rb - About 2 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 filtered_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def filtered_attributes
        # Run the read permission check
        allow_and_deny_fields(:read).then do |allow, deny|

          result = nil
Severity: Minor
Found in lib/volt/models/permissions.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 filtered_attributes has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def filtered_attributes
        # Run the read permission check
        allow_and_deny_fields(:read).then do |allow, deny|

          result = nil
Severity: Minor
Found in lib/volt/models/permissions.rb - About 1 hr to fix

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

            def own_by_user(key = :user_id)
              relation, pattern = key.to_s, /_id$/
              if relation.match(pattern)
                belongs_to key.to_s.gsub(pattern, '')
              else
    Severity: Minor
    Found in lib/volt/models/permissions.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 allow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def allow(*fields)
            if @__allow_fields
              if @__allow_fields != true
                if fields.size == 0
                  # No field's were passed, this means we deny all
    Severity: Minor
    Found in lib/volt/models/permissions.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 deny has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def deny(*fields)
            if @__deny_fields
              if @__deny_fields != true
                if fields.size == 0
                  # No field's were passed, this means we deny all
    Severity: Minor
    Found in lib/volt/models/permissions.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 permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def permissions(*actions, &block)
              # Store the permissions block so we can run it in validations
              self.__permissions__ ||= {}
    
              # if no action was specified, assume all actions
    Severity: Minor
    Found in lib/volt/models/permissions.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