MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

Function anonymous has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

MiniProfiler.templates["snapshotsList"] = function anonymous(it
) {
var out=' '; var data = it.data; out+=' '; var customFieldsNames = it.allCustomFieldsNames; out+=' ';if(data.list && data.list.length){out+=' <h2>Snapshots for '+( data.group_name )+'</h2> <table class="snapshots-table"> <thead> <tr> <th>ID</th> <th>Duration (ms)</th> <th>SQL Count</th> ';var arr1=customFieldsNames;if(arr1){var name,i1=-1,l1=arr1.length-1;while(i1<l1){name=arr1[i1+=1];out+=' <th>'+( name )+'</th> ';} } out+=' <th>Age</th> </tr> </thead> <tbody> ';var arr2=data.list;if(arr2){var row,i2=-1,l2=arr2.length-1;while(i2<l2){row=arr2[i2+=1];out+=' <tr> <td><a href="'+( row.url )+'"> '+( row.id )+' </a></td> <td>'+( MiniProfiler.formatDuration(row.duration) )+'</td> <td>'+( row.sql_count )+'</td> ';var arr3=customFieldsNames;if(arr3){var name,i3=-1,l3=arr3.length-1;while(i3<l3){name=arr3[i3+=1];out+=' <td>'+( row.custom_fields[name] || "" )+'</td> ';} } out+=' <td> ';if(row.timestamp){out+=' '+( MiniProfiler.timestampToRelative(row.timestamp) )+' ';}out+=' </td> </tr> ';} } out+=' </tbody> </table> ';}else{out+=' <h2>No snapshots for '+( data.group_name )+'</h2> ';}return out;
}
Severity: Minor
Found in lib/html/vendor.js - 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/vendor.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/pretty-print.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/vendor.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 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

                            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

                              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/pretty-print.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/vendor.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