MiniProfiler/rack-mini-profiler

View on GitHub

Showing 176 of 176 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def exec_prepared(*args, &blk)
    return exec_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?

    start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    result       = exec_prepared_without_profiling(*args, &blk)
Severity: Major
Found in lib/patches/db/pg.rb and 1 other location - About 1 hr to fix
lib/patches/db/pg.rb on lines 95..106

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def send_query_prepared(*args, &blk)
    return send_query_prepared_without_profiling(*args, &blk) unless SqlPatches.should_measure?

    start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    result       = send_query_prepared_without_profiling(*args, &blk)
Severity: Major
Found in lib/patches/db/pg.rb and 1 other location - About 1 hr to fix
lib/patches/db/pg.rb on lines 81..92

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function getClientTimings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    getClientTimings: function getClientTimings(clientTimings) {
      var list = [];
      var t;
      if (!clientTimings.timings) return [];

Severity: Minor
Found in lib/html/includes.js - About 1 hr to fix

    Function f has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function f(c) {
            if (c.charAt(0) !== "\\") return c.charCodeAt(0);
    
            switch (c.charAt(1)) {
              case "b":
    Severity: Minor
    Found in lib/html/pretty-print.js - About 1 hr to fix

      Method push_snapshot has 29 lines of code (exceeds 25 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 1 hr to fix

        Function f has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              function f(c) {
                if (c.charAt(0) !== "\\") return c.charCodeAt(0);
        
                switch (c.charAt(1)) {
                  case "b":
        Severity: Minor
        Found in lib/html/vendor.js - About 1 hr to fix

          Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def initialize(args = nil)
                  args ||= {}
                  @path = args[:path]
                  @expires_in_seconds = args[:expires_in] || EXPIRES_IN_SECONDS
                  raise ArgumentError.new :path unless @path
          Severity: Minor
          Found in lib/mini_profiler/storage/file_store.rb - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      if (timing.children) {
                        for (var i = 0; i < timing.children.length; i++) {
                          countSql(timing.children[i]);
                        }
                      }
            Severity: Major
            Found in lib/html/includes.js and 1 other location - About 1 hr to fix
            lib/html/includes.js on lines 1307..1311

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                      if (timing.children) {
                        for (var i = 0; i < timing.children.length; i++) {
                          addToResults(timing.children[i]);
                        }
                      }
            Severity: Major
            Found in lib/html/includes.js and 1 other location - About 1 hr to fix
            lib/html/includes.js on lines 1453..1457

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Method allowed_tokens has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def allowed_tokens
            
                    token_info = @client.get("#{@prefix}-tokens")
                    key1, key2, cycle_at = nil
            
            
            Severity: Minor
            Found in lib/mini_profiler/storage/memcache_store.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 get_profile_script has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                  def get_profile_script(env, response_headers = {})
                    path = public_base_path(env)
                    version = MiniProfiler::ASSET_VERSION
                    if @config.assets_url
                      url = @config.assets_url.call('rack-mini-profiler.js', version, env)
            Severity: Minor
            Found in lib/mini_profiler/views.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 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

              Function send has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    XMLHttpRequest.prototype.send = function(data) {
                      ajaxStartTime = new Date();
                      this.addEventListener("load", function() {
                        // responseURL isn't available in IE11
                        if (
              Severity: Minor
              Found in lib/html/includes.js - 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_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

                            Severity
                            Category
                            Status
                            Source
                            Language