pboling/active_security

View on GitHub

Showing 4 of 4 total issues

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

    def _active_security_not_scoped_handler
      return active_security_config.on_restricted_no_scope.call(active_security_config) if active_security_config.on_restricted_no_scope.respond_to?(:call)

      unless VALID_CONFIG_VALUES.include?(active_security_config.on_restricted_no_scope)
        raise InvalidConfig, "on_restricted_no_scope must either be set to a callable lambda/proc or one of [:log, :log_and_raise, :raise]"
Severity: Minor
Found in lib/active_security/restricted_hooks.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 use has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def use(*modules, &block)
      mods = modules.to_a.compact
      mods.map.with_index do |object, idx|
        case object
        when Array
Severity: Minor
Found in lib/active_security/configuration.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

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

      def after_config(model_class)
        raise InvalidConfig, ":finders plugin must be used with default_finders set to one of :privileged, or :restricted" unless %i[restricted privileged].include?(model_class.active_security_config.default_finders)

        model_class.active_security_config.use(model_class.active_security_config.default_finders)
        model_class.class_eval do
Severity: Minor
Found in lib/active_security/finders.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

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

    def _use(mod, idx, &block)
      mod.setup(@model_class) if mod.respond_to?(:setup)
      @model_class.send(:include, mod) unless uses?(mod)
      # Only yield on the first module, so as to not run the block multiple times,
      # and because later modules may require the attributes of a prior module to exist.
Severity: Minor
Found in lib/active_security/configuration.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

Severity
Category
Status
Source
Language