MiniProfiler/rack-mini-profiler

View on GitHub

Showing 176 of 176 total issues

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 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 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 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 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

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

        def exec_params(*args, &blk)
          return exec_params_without_profiling(*args, &blk) unless SqlPatches.should_measure?
    
          start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
          result       = exec_params_without_profiling(*args, &blk)
    Severity: Major
    Found in lib/patches/db/pg.rb and 2 other locations - About 45 mins to fix
    lib/patches/db/pg.rb on lines 55..64
    lib/patches/db/pg.rb on lines 109..118

    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 41.

    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 3 locations. Consider refactoring.
    Open

      def exec(*args, &blk)
        return exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?
    
        start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
        result       = exec_without_profiling(*args, &blk)
    Severity: Major
    Found in lib/patches/db/pg.rb and 2 other locations - About 45 mins to fix
    lib/patches/db/pg.rb on lines 68..77
    lib/patches/db/pg.rb on lines 109..118

    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 41.

    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 3 locations. Consider refactoring.
    Open

      def async_exec(*args, &blk)
        return async_exec_without_profiling(*args, &blk) unless SqlPatches.should_measure?
    
        start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
        result       = exec_without_profiling(*args, &blk)
    Severity: Major
    Found in lib/patches/db/pg.rb and 2 other locations - About 45 mins to fix
    lib/patches/db/pg.rb on lines 55..64
    lib/patches/db/pg.rb on lines 68..77

    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 41.

    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

    Avoid deeply nested control flow statements.
    Open

                  for (h = 0; h < l; ++h) {
                    g = f[h];
    
                    if (e = a.match(g[1])) {
                      k = g[0];
    Severity: Major
    Found in lib/html/pretty-print.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (!ba.test(m)) if (ca.test(m)) {
                    f.push(m.substring(9, m.length - 3));
                    n += m.length - 12;
                  } else if (da.test(m)) {
                    f.push("\n");
      Severity: Major
      Found in lib/html/pretty-print.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                  } else if ("\\" === g.charAt(0)) if ((g = +g.substring(1)) && g <= h) d[e] = "\\" + k[h];
        Severity: Major
        Found in lib/html/vendor.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                        for (h = 0; h < l; ++h) {
                          g = f[h];
          
                          if (e = a.match(g[1])) {
                            k = g[0];
          Severity: Major
          Found in lib/html/vendor.js - About 45 mins to fix

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

                  def merge!(config)
                    if config
                      if Hash === config
                        config.each { |k, v| instance_variable_set "@#{k}", v }
                      else
            Severity: Minor
            Found in lib/mini_profiler/config.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/pretty-print.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            if (stringIds) {
                              var ids = stringIds.split(",");
                              fetchResults(ids);
                            }
              Severity: Major
              Found in lib/html/includes.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if ((a.tagName === "pre" || a.tagName === "code" || a.tagName === "xmp") && a.className && a.className.indexOf("prettyprint") >= 0) {
                                d = true;
                                break;
                              }
                Severity: Major
                Found in lib/html/pretty-print.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                for (var r = [], j = n; --j >= 0;) {
                                  r[j] = l[j];
                                }
                  Severity: Major
                  Found in lib/html/vendor.js - About 45 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

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

                                def symbolize_hash(hash)
                                  new_hash = {}
                                  hash.each do |k, v|
                                    sym_k = String === k ? k.to_sym : k
                                    if Hash === v
                      Severity: Minor
                      Found in lib/mini_profiler/timer_struct/page.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

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

                          def inject(fragment, script)
                            # find explicit or implicit body
                            index = fragment.rindex(/<\/body>/i) || fragment.rindex(/<\/html>/i)
                            if index
                              # if for whatever crazy reason we dont get a utf string,
                      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

                      Severity
                      Category
                      Status
                      Source
                      Language