joel/scoped_rolify

View on GitHub

Showing 3 of 3 total issues

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

    def add_role_with_root(role_name, resource, root_resource)
      unless root_resource
        add_role(role_name, resource)
      else
        conditions = {
Severity: Minor
Found in lib/scoped_rolify/role.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 add_role has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def add_role(role_name, resource = nil)
      role = self.class.adapter.find_or_create_by(role_name.to_s,
                                                  (resource.is_a?(Class) ? resource.to_s : resource.class.base_class.name if resource),
                                                  (resource.id if resource && !resource.is_a?(Class)))

Severity: Minor
Found in lib/scoped_rolify/role.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 add_resourced_role has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def add_resourced_role(role_name, resource)
      root_resource = resource.respond_to?(:root_resource) ? resource.send(resource.root_resource) : nil

      if self.new_record?
        role = self.class.adapter.role_class.find_or_initialize_by(name: role_name, resource: resource, root_resource: root_resource).tap do |role|
Severity: Minor
Found in lib/scoped_rolify/role.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

Severity
Category
Status
Source
Language