tektite-software/authoreyes

View on GitHub
lib/authoreyes/authorization/attribute_with_permission.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method obligation has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def obligation(attr_validator, hash_or_attr = nil, path = [])
        hash_or_attr ||= @attr_hash
        case hash_or_attr
        when Symbol
          @context ||= begin
Severity: Minor
Found in lib/authoreyes/authorization/attribute_with_permission.rb - About 2 hrs to fix

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

          def validate?(attr_validator, object = nil, hash_or_attr = nil)
            object ||= attr_validator.object
            hash_or_attr ||= @attr_hash
            return false unless object
    
    
    Severity: Minor
    Found in lib/authoreyes/authorization/attribute_with_permission.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 validate? has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def validate?(attr_validator, object = nil, hash_or_attr = nil)
            object ||= attr_validator.object
            hash_or_attr ||= @attr_hash
            return false unless object
    
    
    Severity: Minor
    Found in lib/authoreyes/authorization/attribute_with_permission.rb - About 1 hr to fix

      Method reflection_for_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.reflection_for_path(parent_model, path)
              reflection = path.empty? ? parent_model : begin
                parent = reflection_for_path(parent_model, path[0..-2])
                if !parent.respond_to?(:proxy_reflection) && parent.respond_to?(:klass)
                  parent.klass.reflect_on_association(path.last)
      Severity: Minor
      Found in lib/authoreyes/authorization/attribute_with_permission.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 obligation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def obligation(attr_validator, hash_or_attr = nil, path = [])
              hash_or_attr ||= @attr_hash
              case hash_or_attr
              when Symbol
                @context ||= begin
      Severity: Minor
      Found in lib/authoreyes/authorization/attribute_with_permission.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

      There are no issues that match your filters.

      Category
      Status