MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

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 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.initialize!(app)

    raise "MiniProfilerRails initialized twice. Set `require: false' for rack-mini-profiler in your Gemfile" if defined?(@already_initialized) && @already_initialized

    c = Rack::MiniProfiler.config
Severity: Major
Found in lib/mini_profiler_rails/railtie.rb - About 3 hrs to fix

    Function prettyPrint has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        window.prettyPrint = function (b) {
          function f() {
            for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
              var p = o[q];
    
    
    Severity: Major
    Found in lib/html/pretty-print.js - About 3 hrs to fix

      Function prettyPrint has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          window.prettyPrint = function (b) {
            function f() {
              for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
                var p = o[q];
      
      
      Severity: Major
      Found in lib/html/vendor.js - About 3 hrs to fix

        Class RedisStore has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class RedisStore < AbstractStore
        
              attr_reader :prefix
        
              EXPIRES_IN_SECONDS = 60 * 60 * 24
        Severity: Minor
        Found in lib/mini_profiler/storage/redis_store.rb - About 3 hrs to fix

          Function toggleShortcutEvent has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var toggleShortcutEvent = function toggleShortcutEvent(e) {
              // simplified version of https://github.com/jeresig/jquery.hotkeys/blob/master/jquery.hotkeys.js
              var shortcut = options.toggleShortcut.toLowerCase();
              var modifier = "";
              ["alt", "ctrl", "shift"].forEach(function(k) {
          Severity: Major
          Found in lib/html/includes.js - About 2 hrs to fix

            File redis_store.rb has 287 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'digest'
            require 'securerandom'
            
            module Rack
              class MiniProfiler
            Severity: Minor
            Found in lib/mini_profiler/storage/redis_store.rb - About 2 hrs to fix

              Function buttonShow has 72 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var buttonShow = function buttonShow(json) {
                  var result = renderTemplate(json);
                  totalTime += parseFloat(json.duration_milliseconds, 10);
                  totalSqlCount += parseInt(json.sql_count);
                  reqs++;
              Severity: Major
              Found in lib/html/includes.js - About 2 hrs to fix

                Function U has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function U(b) {
                      var f = b.f,
                          i = b.e;
                      b.a = f;
                
                
                Severity: Major
                Found in lib/html/pretty-print.js - About 2 hrs to fix

                  Function U has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function U(b) {
                        var f = b.f,
                            i = b.e;
                        b.a = f;
                  
                  
                  Severity: Major
                  Found in lib/html/vendor.js - About 2 hrs to fix

                    Function fetchResults has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      var fetchResults = function fetchResults(ids) {
                        var clientPerformance, clientProbes, i, j, p, id, idx;
                    
                        for (i = 0; i < ids.length; i++) {
                          id = ids[i];
                    Severity: Major
                    Found in lib/html/includes.js - About 2 hrs to fix

                      Function $ has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function $(b) {
                            function f(D) {
                              if (D > r) {
                                if (j && j !== q) {
                                  n.push("</span>");
                      Severity: Major
                      Found in lib/html/pretty-print.js - About 2 hrs to fix

                        Function $ has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function $(b) {
                              function f(D) {
                                if (D > r) {
                                  if (j && j !== q) {
                                    n.push("</span>");
                        Severity: Major
                        Found in lib/html/vendor.js - About 2 hrs to fix

                          Function B has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function B(b, f) {
                                var i = {},
                                    o;
                          
                                (function () {
                          Severity: Major
                          Found in lib/html/pretty-print.js - About 2 hrs to fix

                            Function B has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function B(b, f) {
                                  var i = {},
                                      o;
                            
                                  (function () {
                            Severity: Major
                            Found in lib/html/vendor.js - About 2 hrs to fix

                              Method init_from_form_data has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                              Open

                                      def self.init_from_form_data(env, page_struct)
                                        timings = []
                                        clientTimes, clientPerf, baseTime = nil
                                        form = env['rack.request.form_hash']
                              
                              
                              Severity: Minor
                              Found in lib/mini_profiler/timer_struct/client.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

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

                                    function f() {
                                      for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
                                        var p = o[q];
                              
                                        if (p.className && p.className.indexOf("prettyprint") >= 0) {
                              Severity: Major
                              Found in lib/html/vendor.js - About 2 hrs to fix

                                Method push_snapshot has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def push_snapshot(page_struct, group_name, config)
                                        group_zset_key = group_snapshot_zset_key(group_name)
                                        group_hash_key = group_snapshot_hash_key(group_name)
                                        overview_zset_key = snapshot_overview_zset_key
                                
                                
                                Severity: Major
                                Found in lib/mini_profiler/storage/redis_store.rb - About 2 hrs to fix

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

                                        function f() {
                                          for (var t = window.PR_SHOULD_USE_CONTINUATION ? j.now() + 250 : Infinity; q < o.length && j.now() < t; q++) {
                                            var p = o[q];
                                  
                                            if (p.className && p.className.indexOf("prettyprint") >= 0) {
                                  Severity: Major
                                  Found in lib/html/pretty-print.js - About 2 hrs to fix

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language