tektite-software/authoreyes

View on GitHub

Showing 28 of 28 total issues

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

      def validate?(attr_validator, object = nil, hash = nil)
        object ||= attr_validator.object
        return false unless object

        if Authorization.is_a_association_proxy?(object) &&
Severity: Minor
Found in lib/authoreyes/authorization/attribute.rb - About 7 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 validate? has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def validate?(attr_validator, object = nil, hash = nil)
        object ||= attr_validator.object
        return false unless object

        if Authorization.is_a_association_proxy?(object) &&
Severity: Major
Found in lib/authoreyes/authorization/attribute.rb - About 3 hrs to fix

    Method permit! has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

          def permit!(privilege, options = {})
            return true if Authorization.ignore_access_control
            options = {
              object: nil,
              skip_attribute_test: false,
    Severity: Minor
    Found in lib/authoreyes/authorization/engine.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

    Class AuthorizationRulesParser has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class AuthorizationRulesParser
          attr_reader :roles, :role_hierarchy, :auth_rules,
                      :role_descriptions, :role_titles, :omnipotent_roles # :nodoc:
    
          def initialize # :nodoc:
    Severity: Minor
    Found in lib/authoreyes/parser/authorization_rules_parser.rb - About 2 hrs to fix

      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 roles_for has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def roles_for(user)
                user ||= Authorization.current_user
                raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
                  if !user.respond_to?(:role_symbols) && !user.respond_to?(:roles)
        
        
        Severity: Minor
        Found in lib/authoreyes/authorization/engine.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 obligations has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def obligations(attr_validator)
                exceptions = []
                obligations = @attributes.collect do |attr|
                  begin
                    attr.obligation(attr_validator)
        Severity: Minor
        Found in lib/authoreyes/authorization/authorization_rule.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 permit! has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def permit!(privilege, options = {})
                return true if Authorization.ignore_access_control
                options = {
                  object: nil,
                  skip_attribute_test: false,
        Severity: Minor
        Found in lib/authoreyes/authorization/engine.rb - About 1 hr to fix

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

                def to_long_s(hash = nil)
                  if hash
                    hash.inject({}) do |memo, key_val|
                      key, val = key_val
                      memo[key] = case val
          Severity: Minor
          Found in lib/authoreyes/authorization/attribute.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 obligations has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def obligations(attr_validator)
                    exceptions = []
                    obligations = @attributes.collect do |attr|
                      begin
                        attr.obligation(attr_validator)
            Severity: Minor
            Found in lib/authoreyes/authorization/authorization_rule.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

              Consider simplifying this complex logical expression.
              Open

                        elsif value.is_a?(Array) && value.length == 2 && value.first.is_a?(Symbol)
                          evaluated = if value[1].is_a?(Proc)
                                        attr_validator.evaluate(value[1])
                                      else
                                        value[1]
              Severity: Major
              Found in lib/authoreyes/authorization/attribute.rb - About 1 hr to fix

                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

                Method flatten_privileges has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def flatten_privileges(privileges, context = nil, flattened_privileges = Set.new)
                        # TODO: caching?
                        raise AuthorizationUsageError, 'No context given or inferable from object' unless context
                        privileges.reject { |priv| flattened_privileges.include?(priv) }.each do |priv|
                          flattened_privileges << priv
                Severity: Minor
                Found in lib/authoreyes/authorization/engine.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 has_permission_on has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def has_permission_on(*args)
                        options = args.extract_options!
                        context = args.flatten
                
                        raise DSLError, 'has_permission_on only allowed in role blocks' if @current_role.nil?
                Severity: Minor
                Found in lib/authoreyes/parser/authorization_rules_parser.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def initialize(role, privileges = [], contexts = nil, join_operator = :or,
                                     options = {})
                Severity: Minor
                Found in lib/authoreyes/authorization/authorization_rule.rb - About 35 mins to fix

                  Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          def initialize(engine, user, object = nil, privilege = nil, context = nil)
                  Severity: Minor
                  Found in lib/authoreyes/authorization/engine.rb - About 35 mins to fix

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

                          def self.development_reload?
                            if Rails.env.development?
                              mod_time = AUTH_DSL_FILES.map do |m|
                                begin
                                                         File.mtime(m)
                    Severity: Minor
                    Found in lib/authoreyes/authorization/engine.rb - About 35 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

                    Severity
                    Category
                    Status
                    Source
                    Language