frozeek/xhive

View on GitHub
app/models/xhive/mapper.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

    def self.map_resource(site, page, resource, action, key = nil, policy = nil)
      check_policy_class(policy) if policy.present?

      mapper = find_exact_map(site, resource, action, key, policy)
      mapper = new(:site_id => site.id, :resource => resource,
Severity: Minor
Found in app/models/xhive/mapper.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 map_resource has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def self.map_resource(site, page, resource, action, key = nil, policy = nil)
Severity: Minor
Found in app/models/xhive/mapper.rb - About 45 mins to fix

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

        def self.find_map(site, resource, action, key, opts)
    Severity: Minor
    Found in app/models/xhive/mapper.rb - About 35 mins to fix

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

          def self.unmap_resource(site, resource, action, key = nil, policy = nil)
      Severity: Minor
      Found in app/models/xhive/mapper.rb - About 35 mins to fix

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

            def self.page_for(site, resource, action, key = nil, opts = {})
        Severity: Minor
        Found in app/models/xhive/mapper.rb - About 35 mins to fix

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

              def self.find_exact_map(site, resource, action, key, policy)
          Severity: Minor
          Found in app/models/xhive/mapper.rb - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status