frozeek/xhive

View on GitHub

Showing 8 of 8 total issues

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

    def method_missing(sym, *args, &block)
      # If I receive a method with the form 'foo='
      if sym.to_s =~ /=/
        attr = sym.to_s.scan(/(\w*)=/)
        self[attr[0][0].to_sym] = args[0] unless attr.empty?
Severity: Minor
Found in lib/xhive/hashy.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 mount_page_setter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def mount_page_setter(attr)
        define_method("#{attr}=") do |value|
          fail RecordNotPersistedError, "Cannot assign a page to an unsaved #{self.class.name}" if new_record?
          # TODO: support multiple sites
          site = Xhive::Site.first
Severity: Minor
Found in lib/xhive/active_record_extensions.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 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
            Severity
            Category
            Status
            Source
            Language