csdn-dev/second_level_cache

View on GitHub
lib/second_level_cache/active_record/finder_methods.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method find_one_with_second_level_cache has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def find_one_with_second_level_cache(id)
        return find_one_without_second_level_cache(id) unless second_level_cache_enabled?
        return find_one_without_second_level_cache(id) unless select_all_column?

        id = id.id if ActiveRecord::Base === id
Severity: Minor
Found in lib/second_level_cache/active_record/finder_methods.rb - About 2 hrs 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 find_by_attributes_with_second_level_cache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def find_by_attributes_with_second_level_cache(match, attributes, *args)
        return find_by_attributes_without_second_level_cache(match, attributes, *args) unless second_level_cache_enabled?
        return find_by_attributes_without_second_level_cache(match, attributes, *args) unless select_all_column?

        conditions = Hash[attributes.map {|a| [a, args[attributes.index(a)]]}]
Severity: Minor
Found in lib/second_level_cache/active_record/finder_methods.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

Avoid too many return statements within this method.
Open

            return record if where_match_with_cache?(where_values, record)
Severity: Major
Found in lib/second_level_cache/active_record/finder_methods.rb - About 30 mins to fix

    There are no issues that match your filters.

    Category
    Status