metaminded/tabulatr2

View on GitHub
lib/tabulatr/data/filtering.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method apply_filters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_filters(filter_params)
    default_filters = table_columns.map do |col|
      next if col.col_options.default_filter.nil?
      ["#{col.table_name}:#{col.name}", col.col_options.default_filter]
    end.compact.to_h
Severity: Minor
Found in lib/tabulatr/data/filtering.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 apply_search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def apply_search(query)
    like ||= Tabulatr::Utility.like_statement
    return unless query.present?
    if @search.is_a? Array
      query = query.strip.gsub(/['*%\s]+/, '%')
Severity: Minor
Found in lib/tabulatr/data/filtering.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

unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    filters = default_filters.merge(filter_params&.permit! || {})
Severity: Minor
Found in lib/tabulatr/data/filtering.rb by rubocop

unexpected token tCOMMA (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

      name, value = param
Severity: Minor
Found in lib/tabulatr/data/filtering.rb by rubocop

unexpected token kEND (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

end
Severity: Minor
Found in lib/tabulatr/data/filtering.rb by rubocop

unexpected token tRPAREN (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    filters = default_filters.merge(filter_params&.permit! || {})
Severity: Minor
Found in lib/tabulatr/data/filtering.rb by rubocop

unexpected token kDO_BLOCK (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

    filters.to_hash.with_indifferent_access.each do |param|
Severity: Minor
Found in lib/tabulatr/data/filtering.rb by rubocop

There are no issues that match your filters.

Category
Status