MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

Function _MiniProfiler has a Cognitive Complexity of 437 (exceeds 5 allowed). Consider refactoring.
Open

var _MiniProfiler = (function() {
  var _arguments = arguments;
  var options,
    container,
    controls,
Severity: Minor
Found in lib/html/includes.js - About 1 wk 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 _MiniProfiler has 1291 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var _MiniProfiler = (function() {
  var _arguments = arguments;
  var options,
    container,
    controls,
Severity: Major
Found in lib/html/includes.js - About 6 days to fix

    File includes.js has 1299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    "use strict";
    
    var _MiniProfiler = (function() {
      var _arguments = arguments;
      var options,
    Severity: Major
    Found in lib/html/includes.js - About 3 days to fix

      Method call has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
      Open

          def call(env)
            start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
            client_settings = ClientSettings.new(env, @storage, start)
            MiniProfiler.deauthorize_request if @config.authorization_mode == :allow_authorized
      
      
      Severity: Minor
      Found in lib/mini_profiler.rb - About 1 day 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

      File vendor.js has 714 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
        THIS FILE IS AUTOMATICALLY GENERATED BY THE `write_vendor_js` RAKE TASK.
        DON'T EDIT THIS FILE BY HAND; CHANGES WILL BE OVERRIDEN.
      **/
      
      
      Severity: Major
      Found in lib/html/vendor.js - About 1 day to fix

        File pretty-print.js has 683 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        if (typeof prettyPrint === "undefined") {
          // prettify.js
          // http://code.google.com/p/google-code-prettify/
          // prettier-ignore
          window.PR_SHOULD_USE_CONTINUATION = true;
        Severity: Major
        Found in lib/html/pretty-print.js - About 1 day to fix

          File mini_profiler.rb has 517 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'cgi'
          require 'json'
          require 'erb'
          
          require 'mini_profiler/timer_struct'
          Severity: Major
          Found in lib/mini_profiler.rb - About 1 day to fix

            Method call has 194 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def call(env)
                  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
                  client_settings = ClientSettings.new(env, @storage, start)
                  MiniProfiler.deauthorize_request if @config.authorization_mode == :allow_authorized
            
            
            Severity: Major
            Found in lib/mini_profiler.rb - About 7 hrs to fix

              Function initPopupView has 189 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var initPopupView = function initPopupView() {
                  if (options.authorized) {
                    // all fetched profilings will go in here
                    container = document.createElement("div");
                    container.className = "profiler-results";
              Severity: Major
              Found in lib/html/includes.js - About 7 hrs to fix

                Method initialize! has a Cognitive Complexity of 47 (exceeds 5 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: Minor
                Found in lib/mini_profiler_rails/railtie.rb - About 7 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 anonymous has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
                Open

                MiniProfiler.templates["profilerTemplate"] = function anonymous(it
                ) {
                var out=' <div class="profiler-result"> <div class="profiler-button ';if(it.has_duplicate_sql_timings){out+='profiler-warning';}out+='"> ';if(it.has_duplicate_sql_timings){out+='<span class="profiler-nuclear">!</span>';}out+=' <span class="profiler-number profiler-duration-milliseconds"> '+( MiniProfiler.formatDuration(it.duration_milliseconds))+' <span class="profiler-unit">ms</span> </span> ';if(MiniProfiler.showTotalSqlCount()){out+=' <span class="profiler-number profiler-sql-count"> '+( it.sql_count)+' <span class="profiler-unit">sql</span> </span> ';}out+=' <span class="profiler-name"> ';if(it.name.length >= 30){out+=' '+( it.name.substring(0,15) + "..." + it.name.slice(-15) )+' ';}else{out+=' '+( it.name)+' ';}out+=' </span> </div> <div class="profiler-popup"> <div class="profiler-info"> <span class="profiler-name"> '+( it.name)+' <span class="profiler-overall-duration">('+( MiniProfiler.formatDuration(it.duration_milliseconds))+' ms)</span> </span> <span class="profiler-server-time">'+( it.machine_name)+' on '+( MiniProfiler.renderDate(it.started_formatted))+'</span> </div> <div class="profiler-output"> <table class="profiler-timings"> <thead> <tr> <th>event</th> <th>duration (ms)</th> <th class="profiler-duration-with-children">with children (ms)</th> <th class="time-from-start">from start (ms)</th> ';if(it.has_sql_timings){out+=' <th colspan="2">query time (ms)</th> ';}out+=' ';var arr1=it.custom_timing_names;if(arr1){var value,i1=-1,l1=arr1.length-1;while(i1<l1){value=arr1[i1+=1];out+=' <th colspan="2">'+( value.toLowerCase() )+' (ms)</th> ';} } out+=' </tr> </thead> <tbody> '+( MiniProfiler.templates.timingTemplate({timing: it.root, page: it}) )+' </tbody> <tfoot> <tr> <td colspan="3"> ';if(!it.client_timings){out+=' '+( MiniProfiler.templates.linksTemplate({timing: it.root, page: it}) )+' ';}out+=' <a class="profiler-toggle-duration-with-children" title="toggles column with aggregate child durations">show time with children</a> <a class="profiler-snapshots-page-link" title="Go to snapshots page" href="'+( MiniProfiler.options.path )+'snapshots">snapshots</a> </td> ';if(it.has_sql_timings){out+=' <td colspan="2" class="profiler-number profiler-percent-in-sql" title="'+( MiniProfiler.getSqlTimingsCount(it.root) )+' queries spent '+( MiniProfiler.formatDuration(it.duration_milliseconds_in_sql) )+' ms of total request time"> '+( MiniProfiler.formatDuration(it.duration_milliseconds_in_sql / it.duration_milliseconds * 100) )+' <span class="profiler-unit">% in sql</span> </td> ';}out+=' ';var arr2=it.custom_timing_names;if(arr2){var value,i2=-1,l2=arr2.length-1;while(i2<l2){value=arr2[i2+=1];out+=' <td colspan="2" class="profiler-number profiler-percentage-in-sql" title="'+( it.custom_timing_stats[value].count )+' '+( value.toLowerCase() )+' invocations spent '+( MiniProfiler.formatDuration(it.custom_timing_stats[value].duration) )+' ms of total request time"> '+( MiniProfiler.formatDuration(it.custom_timing_stats[value].duration / it.duration_milliseconds * 100) )+' <span class="profiler-unit">% in '+( value.toLowerCase() )+'</span> </td> ';} } out+=' </tr> </tfoot> </table> ';if(it.client_timings){out+=' <table class="profiler-timings profiler-client-timings"> <thead> <tr> <th>client event</th> <th>duration (ms)</th> <th>from start (ms)</th> </tr> </thead> <tbody> ';var arr3=MiniProfiler.getClientTimings(it.client_timings);if(arr3){var value,i3=-1,l3=arr3.length-1;while(i3<l3){value=arr3[i3+=1];out+=' <tr class="';if(value.isTrivial){out+='profiler-trivial';}out+='"> <td class="profiler-label">'+( value.name )+'</td> <td class="profiler-duration"> ';if(value.duration >= 0){out+=' <span class="profiler-unit"></span>'+( MiniProfiler.formatDuration(value.duration) )+' ';}out+=' </td> <td class="profiler-duration time-from-start"> <span class="profiler-unit">+</span>'+( MiniProfiler.formatDuration(value.start) )+' </td> </tr> ';} } out+=' </tbody> <tfoot> <td colspan="3"> '+( MiniProfiler.templates.linksTemplate({timing: it.root, page: it}) )+' </td> </tfoot> </table> ';}out+=' ';if(it.custom_fields && Object.keys(it.custom_fields).length > 0){out+=' <p class="custom-fields-title">Snapshot custom fields</p> <table class="profiler-timings"> <tbody> ';var arr4=Object.keys(it.custom_fields);if(arr4){var key,i4=-1,l4=arr4.length-1;while(i4<l4){key=arr4[i4+=1];out+=' <tr> <td class="profiler-label">'+( key )+'</td> <td class="profiler-label">'+( it.custom_fields[key] )+'</td> </tr> ';} } out+=' </tbody> </table> ';}out+=' </div> </div> ';if(it.has_sql_timings){out+=' <div class="profiler-queries"> <table> <thead> <tr> <th class="ta-right">step<br />time from start<br />query type<br />duration</th> <th class="ta-left">call stack<br />query</th> </tr> </thead> <tbody> ';var arr5=MiniProfiler.getSqlTimings(it.root);if(arr5){var value,index=-1,l5=arr5.length-1;while(index<l5){value=arr5[index+=1];out+=' '+( MiniProfiler.templates.sqlGapTemplate({g: value.prevGap}) )+' '+( MiniProfiler.templates.sqlTimingTemplate({i: index, s: value}) )+' ';if(value.nextGap){out+=' '+( MiniProfiler.templates.sqlGapTemplate({g: value.nextGap}) )+' ';}out+=' ';} } out+=' </tbody> </table> <p class="profiler-trivial-gap-container"> <a class="profiler-toggle-trivial-gaps">show trivial gaps</a> </p> </div> ';}out+=' </div>';return out;
                }
                Severity: Minor
                Found in lib/html/vendor.js - About 6 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

                Class MiniProfiler has 42 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class MiniProfiler
                    include Actions
                    include Views
                
                    class << self
                Severity: Minor
                Found in lib/mini_profiler.rb - About 5 hrs to fix

                  Function O has 133 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

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

                    Function O has 133 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Function getSqlTimings has 130 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          getSqlTimings: function getSqlTimings(root) {
                            var result = [],
                              addToResults = function addToResults(timing) {
                                if (timing.sql_timings) {
                                  for (var i = 0, sqlTiming; i < timing.sql_timings.length; i++) {
                      Severity: Major
                      Found in lib/html/includes.js - About 5 hrs to fix

                        Function init has 129 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            init: function init() {
                              var script = document.getElementById("mini-profiler");
                              if (!script || !script.getAttribute) return;
                        
                              this.options = options = (function() {
                        Severity: Major
                        Found in lib/html/includes.js - About 5 hrs to fix

                          Consider simplifying this complex logical expression.
                          Open

                          if (typeof prettyPrint === "undefined") {
                            // prettify.js
                            // http://code.google.com/p/google-code-prettify/
                            // prettier-ignore
                            window.PR_SHOULD_USE_CONTINUATION = true;
                          Severity: Critical
                          Found in lib/html/vendor.js - About 4 hrs to fix

                            Consider simplifying this complex logical expression.
                            Open

                            if (typeof prettyPrint === "undefined") {
                              // prettify.js
                              // http://code.google.com/p/google-code-prettify/
                              // prettier-ignore
                              window.PR_SHOULD_USE_CONTINUATION = true;
                            Severity: Critical
                            Found in lib/html/pretty-print.js - About 4 hrs to fix

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

                              MiniProfiler.templates["timingTemplate"] = function anonymous(it
                              ) {
                              var out=' <tr class="';if(it.timing.is_trivial){out+='profiler-trivial';}out+='" data-timing-id="'+( it.timing.id )+'"> <td class="profiler-label" title="';if(it.timing.name && it.timing.name.length > 45){out+=''+( it.timing.name );}out+='"> <span class="profiler-indent">'+( MiniProfiler.renderIndent(it.timing.depth) )+'</span> '+( it.timing.name.slice(0,45) );if(it.timing.name && it.timing.name.length > 45){out+='...';}out+=' </td> <td class="profiler-duration" title="duration of this step without any children\'s durations"> '+( MiniProfiler.formatDuration(it.timing.duration_without_children_milliseconds) )+' </td> <td class="profiler-duration profiler-duration-with-children" title="duration of this step and its children"> '+( MiniProfiler.formatDuration(it.timing.duration_milliseconds) )+' </td> <td class="profiler-duration time-from-start" title="time elapsed since profiling started"> <span class="profiler-unit">+</span>'+( MiniProfiler.formatDuration(it.timing.start_milliseconds) )+' </td> ';if(it.timing.has_sql_timings){out+=' <td class="profiler-duration ';if(it.timing.has_duplicate_sql_timings){out+='profiler-warning';}out+='" title="';if(it.timing.has_duplicate_sql_timings){out+='duplicate queries detected - ';}if(it.timing.executed_readers > 0 || it.timing.executed_scalars > 0 || it.timing.executed_non_queries > 0){out+=''+( it.timing.executed_readers )+' reader, '+( it.timing.executed_scalars )+' scalar, '+( it.timing.executed_non_queries )+' non-query statements executed';}out+='"> <a class="profiler-queries-show"> ';if(it.timing.has_duplicate_sql_timings){out+='<span class="profiler-nuclear">!</span>';}out+=' '+( it.timing.sql_timings.length )+' <span class="profiler-unit">sql</span> </a> </td> <td class="profiler-duration" title="aggregate duration of all queries in this step (excludes children)"> '+( MiniProfiler.formatDuration(it.timing.sql_timings_duration_milliseconds) )+' </td> ';}else{out+=' <td colspan="2"></td> ';}out+=' ';var arr1=it.page.custom_timing_names;if(arr1){var value,i1=-1,l1=arr1.length-1;while(i1<l1){value=arr1[i1+=1];out+=' ';if(it.timing.custom_timings && it.timing.custom_timings[value]){out+=' <td class="profiler-duration" title="aggregate number of all '+( value.toLowerCase() )+' invocations in this step (excludes children)"> '+( it.timing.custom_timings[value].length )+' '+( value.toLowerCase() )+' </td> <td class="profiler-duration" title="aggregate duration of all '+( value.toLowerCase() )+' invocations in this step (excludes children)"> '+( MiniProfiler.formatDuration(it.timing.custom_timing_stats[value].duration) )+' </td> ';}else{out+=' <td colspan="2"></td> ';}out+=' ';} } out+=' </tr> ';if(it.timing.has_children){out+=' ';var arr2=it.timing.children;if(arr2){var value,i2=-1,l2=arr2.length-1;while(i2<l2){value=arr2[i2+=1];out+=' '+( MiniProfiler.templates.timingTemplate({timing: value, page: it.page}) )+' ';} } out+=' ';}return out;
                              }
                              Severity: Minor
                              Found in lib/html/vendor.js - About 4 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 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

                              Severity
                              Category
                              Status
                              Source
                              Language