MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

Method flamegraph has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def flamegraph(graph, path, env)
        headers = { 'Content-Type' => 'text/html' }
        iframe_src = "#{public_base_path(env)}speedscope/index.html"
        html = <<~HTML
          <!DOCTYPE html>
Severity: Minor
Found in lib/mini_profiler/views.rb - About 1 hr to fix

    Method cleanup_corrupt_snapshots has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def cleanup_corrupt_snapshots(corrupt_snapshots_ids, group_name)
            group_hash_key = group_snapshot_hash_key(group_name)
            group_zset_key = group_snapshot_zset_key(group_name)
            overview_zset_key = snapshot_overview_zset_key
            lua = <<~LUA
    Severity: Minor
    Found in lib/mini_profiler/storage/redis_store.rb - About 1 hr to fix

      Function l has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function l(c) {
              for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
                var g = d[e];
                if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
              }
      Severity: Minor
      Found in lib/html/pretty-print.js - About 1 hr to fix

        Method take_snapshot has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def take_snapshot(env, start)
              MiniProfiler.create_current(env, @config)
              Thread.current[:mp_ongoing_snapshot] = true
              results = @app.call(env)
              status = results[0].to_i
        Severity: Minor
        Found in lib/mini_profiler.rb - About 1 hr to fix

          Function l has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                function l(c) {
                  for (var d = c.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)", "g")), a = d.length, k = [], e = 0, h = 0; e < a; ++e) {
                    var g = d[e];
                    if (g === "(") ++h;else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) k[g] = -1;
                  }
          Severity: Minor
          Found in lib/html/vendor.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                } else if (popup.style.display === "block") {
                  hidePopup =
                    isEscPress ||
                    (e.type == "click" &&
                      !(popup !== e.target && popup.contains(e.target)) &&
            Severity: Major
            Found in lib/html/includes.js - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if (bg && bg.style.display === "block") {
                    hideQueries =
                      isEscPress ||
                      (e.type == "click" &&
                        !(queries !== e.target && queries.contains(e.target)) &&
              Severity: Major
              Found in lib/html/includes.js - About 1 hr to fix

                Method serve_results has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def serve_results(env)
                        request     = Rack::Request.new(env)
                        id          = request.params['id']
                        group_name  = request.params['group']
                        is_snapshot = group_name && group_name.size > 0
                Severity: Minor
                Found in lib/mini_profiler/actions.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 fetch_snapshots_overview has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def fetch_snapshots_overview
                    overview = {}
                    snapshots.shuffle.each do |ss|
                      group_name = "#{ss[:request_method]} #{ss[:request_path]}"
                      group = overview[group_name]
                Severity: Minor
                Found in website/sample.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 serve_profile_memory has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def serve_profile_memory(env, client_settings)
                        return tool_disabled_message(client_settings) if !advanced_debugging_enabled?
                
                        unless defined?(MemoryProfiler) && MemoryProfiler.respond_to?(:report)
                          message = "Please install the memory_profiler gem and require it: add gem 'memory_profiler' to your Gemfile"
                Severity: Minor
                Found in lib/mini_profiler/actions.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 push_snapshot has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                      def push_snapshot(page_struct, group_name, config)
                        @snapshots_lock.synchronize do
                          group = @snapshot_groups[group_name]
                          if !group
                            @snapshot_groups[group_name] = {
                Severity: Minor
                Found in lib/mini_profiler/storage/memory_store.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 flush_buffer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def flush_buffer
                    buffer_content = @buffer_mutex.synchronize do
                      @buffer.dup if @buffer.size > 0
                    end
                    if buffer_content
                Severity: Minor
                Found in lib/mini_profiler/snapshots_transporter.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 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

                  Avoid deeply nested control flow statements.
                  Open

                                if (null === K) {
                                  d = document.createElement("PRE");
                                  d.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
                                  K = !/</.test(d.innerHTML);
                                }
                  Severity: Major
                  Found in lib/html/vendor.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if (K) {
                                    d = a.innerHTML;
                                    if ("XMP" === a.tagName) d = y(d);else {
                                      a = a;
                                      if ("PRE" === a.tagName) a = true;else if (ka.test(d)) {
                    Severity: Major
                    Found in lib/html/vendor.js - About 45 mins to fix

                      Method add_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              def add_sql(query, elapsed_ms, page, params = nil, skip_backtrace = false, full_backtrace = false)
                      Severity: Minor
                      Found in lib/mini_profiler/timer_struct/request.rb - About 45 mins to fix

                        Method take_snapshot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def take_snapshot(env, start)
                              MiniProfiler.create_current(env, @config)
                              Thread.current[:mp_ongoing_snapshot] = true
                              results = @app.call(env)
                              status = results[0].to_i
                        Severity: Minor
                        Found in lib/mini_profiler.rb - About 45 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 deeply nested control flow statements.
                        Open

                                      if (p = m.a) {
                                        c = m.b;
                        
                                        if ("XMP" === c.tagName) {
                                          d = document.createElement("PRE");
                        Severity: Major
                        Found in lib/html/vendor.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                      if (k < 0) a = p;else {
                                        for (--k; (k = p.indexOf("&#", k + 1)) >= 0;) {
                                          var e = p.indexOf(";", k);
                          
                                          if (e >= 0) {
                          Severity: Major
                          Found in lib/html/pretty-print.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if (p = m.a) {
                                            c = m.b;
                            
                                            if ("XMP" === c.tagName) {
                                              d = document.createElement("PRE");
                            Severity: Major
                            Found in lib/html/pretty-print.js - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language