CanCanCommunity/cancancan

View on GitHub
lib/cancan/model_adapters/active_record_adapter.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class ActiveRecordAdapter has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ActiveRecordAdapter < AbstractAdapter
      def self.version_greater_or_equal?(version)
        Gem::Version.new(ActiveRecord.version).release >= Gem::Version.new(version)
      end

Severity: Minor
Found in lib/cancan/model_adapters/active_record_adapter.rb - About 2 hrs to fix

    Method merge_non_empty_conditions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def merge_non_empty_conditions(behavior, conditions_hash, sql)
            conditions = sanitize_sql(conditions_hash)
            case sql
            when true_sql
              behavior ? true_sql : "not (#{conditions})"
    Severity: Minor
    Found in lib/cancan/model_adapters/active_record_adapter.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 deep_merge has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def deep_merge(base_hash, added_hash)
            added_hash.each do |key, value|
              if base_hash[key].is_a?(Hash)
                deep_merge(base_hash[key], value) unless value.empty?
              else
    Severity: Minor
    Found in lib/cancan/model_adapters/active_record_adapter.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 parent_child_conditions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def parent_child_conditions(parent, child, all_conditions)
              child_class = child.is_a?(Class) ? child : child.class
              parent_class = parent.is_a?(Class) ? parent : parent.class
    
              foreign_key = child_class.reflect_on_all_associations(:belongs_to).find do |association|
    Severity: Minor
    Found in lib/cancan/model_adapters/active_record_adapter.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 child_association_to_parent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def child_association_to_parent(parent, child)
              child_class = child.is_a?(Class) ? child : child.class
              parent_class = parent.is_a?(Class) ? parent : parent.class
    
              association = child_class.reflect_on_all_associations(:belongs_to).find do |belongs_to_assoc|
    Severity: Minor
    Found in lib/cancan/model_adapters/active_record_adapter.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

    There are no issues that match your filters.

    Category
    Status