tomlobato/db_facet

View on GitHub

Showing 6 of 6 total issues

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

  def merge! data
    root_model = @root_node[:class_name].constantize
    root_model.reflections.each do |ref_name, reflection|
      next unless data[ref_name]

Severity: Minor
Found in lib/db_facet/db_spider_root_merger.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 allow_column? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def allow_column? model, col
    if @keep_columns[model.name].to_a.include? col
      return true
    end

Severity: Minor
Found in lib/db_facet/db_spider.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

Method follow_reflection? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def follow_reflection? ref, parent_rec
    return false if !ref.macro.in? [:belongs_to, :has_many, :has_one]
    return false if ref.options[:through] # Skip :through assossiations
    return false if !ref.active_record.name == ref.class_name # Skip self joins
    return false if !ref.class_name.in? @allow_models.to_a
Severity: Minor
Found in lib/db_facet/db_spider.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

Avoid too many return statements within this method.
Open

    return false if @deny_models.include? ref.class_name
Severity: Major
Found in lib/db_facet/db_spider.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

        return false if parent_rec and parent_rec.class == ref.klass # Deny model go back up to the parent class
    Severity: Major
    Found in lib/db_facet/db_spider.rb - About 30 mins to fix

      Method traverse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def traverse rec, parent_rec, parent_node = nil, excl_foreign_key = nil
          data_columns = get_data_columns(rec.class) - [excl_foreign_key]
      
          node = @node_set.find_or_create rec, data_columns
      
      
      Severity: Minor
      Found in lib/db_facet/db_spider.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