GeorgeKaraszi/active_record_extended

View on GitHub

Showing 8 of 8 total issues

Method json_object_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        def json_object_options(args, except: [], only: []) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
          options   = {}
          lean_opts = lambda do |key, &block|
            if only.present?
              options[key] ||= block.call if only.include?(key)
Severity: Minor
Found in lib/active_record_extended/query_methods/json.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 pipe_cte_with! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def pipe_cte_with!(value)
          return if value.nil? || value.empty?

          value.each_pair do |name, expression|
            sym_name = name.to_sym
Severity: Minor
Found in lib/active_record_extended/query_methods/with_cte.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 to_ordered_table_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def to_ordered_table_path(args)
        flatten_safely(Array.wrap(args)) do |arg|
          next arg unless arg.is_a?(Hash)

          arg.each_with_object({}) do |(tbl_or_col, obj), new_hash|
Severity: Minor
Found in lib/active_record_extended/utilities/order_by.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 construct_query_mappings has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def construct_query_mappings(queries) # rubocop:disable Metrics/AbcSize
        { joins: Set.new, references: Set.new, includes: Set.new, arel_query: nil, binds: [] }.tap do |query_map|
          query_map[:arel_query] = queries.map do |raw_query|
            query = generate_where_clause(raw_query)
            query_map[:joins]      << translate_reference(query.joins_values)      if query.joins_values.any?
Severity: Minor
Found in lib/active_record_extended/query_methods/any_of.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 contains has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def contains(opts, *rest)
        if ActiveRecordExtended::AR_VERSION_GTE_6_1
          return substitute_comparisons(opts, rest, Arel::Nodes::Contains, "contains")
        end

Severity: Minor
Found in lib/active_record_extended/query_methods/where_chain.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(*args)
          super
          return if @expressions.is_a?(::Array)

          @expressions = @expressions.is_a?(::Arel::Nodes::Node) ? [@expressions] : [::Arel.sql(@expressions)]
Severity: Minor
Found in lib/active_record_extended/arel/nodes.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 build_foster_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def build_foster_select(*args)
          flatten_safely(args).each do |select_arg|
            case select_arg
            when String, Symbol
              select!(select_arg)
Severity: Minor
Found in lib/active_record_extended/query_methods/foster_select.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

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

        def build_arel(*aliases)
          super.tap do |arel|
            build_windows(arel) if window_values?
            build_unions(arel)  if union_values?
            build_with(arel)    if with_values?
Severity: Minor
Found in lib/active_record_extended/patch/relation_patch.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