MiniProfiler/rack-mini-profiler

View on GitHub
lib/mini_profiler/timer_struct/sql.rb

Summary

Maintainability
C
1 day
Test Coverage

Method trim_binds has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

        def trim_binds(binds)
          max_len = Rack::MiniProfiler.config.max_sql_param_length
          return if binds.nil? || max_len == 0
          return binds.map { |(name, val)| [name, val] } if max_len.nil?
          binds.map do |(name, val)|
Severity: Minor
Found in lib/mini_profiler/timer_struct/sql.rb - About 3 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 initialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(query, duration_ms, page, parent, params = nil, skip_backtrace = false, full_backtrace = false)

          stack_trace = nil
          unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
            # Allow us to filter the stack trace
Severity: Minor
Found in lib/mini_profiler/timer_struct/sql.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 initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize(query, duration_ms, page, parent, params = nil, skip_backtrace = false, full_backtrace = false)

          stack_trace = nil
          unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
            # Allow us to filter the stack trace
Severity: Minor
Found in lib/mini_profiler/timer_struct/sql.rb - About 1 hr to fix

    Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def initialize(query, duration_ms, page, parent, params = nil, skip_backtrace = false, full_backtrace = false)
    Severity: Major
    Found in lib/mini_profiler/timer_struct/sql.rb - About 50 mins to fix

      There are no issues that match your filters.

      Category
      Status