sealink/dependent_restrict

View on GitHub

Showing 3 of 5 total issues

Method add_dependency_callback! has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def add_dependency_callback!(reflection, options)
      dependent_type = active_record_4? ? options[:dependent] : reflection.options[:dependent]
      name = reflection.name
      name = name.first if name.is_a?(Array) # rails 3
      method_name = "dependent_#{dependent_type}_for_#{name}"
Severity: Minor
Found in lib/dependent_restrict.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 basic_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def basic_message
      assoc = @record.send(@name)
      count = assoc.respond_to?(:count) ? assoc.count : (assoc ? 1 : 0)
      name = I18n.t(@name.to_s.singularize, {
        :scope => [:activerecord, :models],
Severity: Minor
Found in lib/dependent_restrict/delete_restriction_error.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 has_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def has_one(*args, &extension)
      options = args.extract_options! || {}
      if VALID_DEPENDENTS.include?(options[:dependent].try(:to_sym))
        reflection = if active_record_4?
          association_id, scope = *args
Severity: Minor
Found in lib/dependent_restrict.rb - About 25 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