MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

Function onClickEvents has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var onClickEvents = function onClickEvents(e) {
    // this happens on every keystroke, and :visible is crazy expensive in IE <9
    // and in this case, the display:none check is sufficient.
    var popup = toArray(document.querySelectorAll(".profiler-popup")).filter(
      function(el) {
Severity: Minor
Found in lib/html/includes.js - About 1 hr to fix

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

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

              def initialize(env)
                timer_id     = MiniProfiler.generate_id
                started_at   = (Time.now.to_f * 1000).to_i
                started      = (Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i
                machine_name = env['SERVER_NAME']
      Severity: Minor
      Found in lib/mini_profiler/timer_struct/page.rb - About 1 hr to fix

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

          Function initControls has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var initControls = function initControls(container) {
              if (options.showControls) {
                var _controls = document.createElement("div");
          
                _controls.classList.add("profiler-controls");
          Severity: Minor
          Found in lib/html/includes.js - About 1 hr to fix

            Function toQueryString has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var toQueryString = function toQueryString(data, parentKey) {
                var result = [];
                for (var key in data) {
                  var val = data[key];
                  var newKey = !parentKey ? key : parentKey + "[" + key + "]";
            Severity: Minor
            Found in lib/html/includes.js - About 1 hr to fix

              Function H has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function H(b, f, i) {
                    switch (b.nodeType) {
                      case 1:
                        var o = b.tagName.toLowerCase();
                        f.push("<", o);
              Severity: Minor
              Found in lib/html/pretty-print.js - About 1 hr to fix

                Function H has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function H(b, f, i) {
                      switch (b.nodeType) {
                        case 1:
                          var o = b.tagName.toLowerCase();
                          f.push("<", o);
                Severity: Minor
                Found in lib/html/vendor.js - About 1 hr to fix

                  Method binds_to_params has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def binds_to_params(binds)
                          return if binds.nil? || config.max_sql_param_length == 0
                          # map ActiveRecord::Relation::QueryAttribute to [name, value]
                          params = binds.map { |c| c.kind_of?(Array) ? [c.first, c.last] : [c.name, c.value] }
                          if (skip = config.skip_sql_param_names)
                  Severity: Minor
                  Found in lib/mini_profiler.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 render_notification_handler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def render_notification_handler(name, finish, start, name_as_description: false)
                      return if !should_measure?
                  
                      description = name_as_description ? name : "Rendering: #{name}"
                      current = Rack::MiniProfiler.current.current_timer
                  Severity: Minor
                  Found in lib/mini_profiler_rails/railtie_methods.rb - About 1 hr to fix

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

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

                              def initialize(name, page, parent)
                                start_millis = (Process.clock_gettime(Process::CLOCK_MONOTONIC) * 1000).to_i - page[:started]
                                depth        = parent ? parent.depth + 1 : 0
                                super(
                                  id: MiniProfiler.generate_id,
                      Severity: Minor
                      Found in lib/mini_profiler/timer_struct/request.rb - About 1 hr to fix

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

                              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

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

                                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language