MiniProfiler/rack-mini-profiler

View on GitHub

Showing 176 of 176 total issues

Method profile_method has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def profile_method(klass, method, type = :profile, &blk)
        default_name = type == :counter ? method.to_s : klass.to_s + " " + method.to_s
        clean        = clean_method_name(method)

        with_profiling    = ("#{clean}_with_mini_profiler").intern
Severity: Minor
Found in lib/mini_profiler/profiling_methods.rb - About 1 hr to fix

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

      Method initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(env, store, start)
              @request = ::Rack::Request.new(env)
              @cookie = @request.cookies[COOKIE_NAME]
              @store = store
              @start = start
      Severity: Minor
      Found in lib/mini_profiler/client_settings.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 analyze_memory has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def analyze_memory
            require 'objspace'
      
            utf8 = "utf-8"
      
      
      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 a Cognitive Complexity of 13 (exceeds 5 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

      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 a Cognitive Complexity of 13 (exceeds 5 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

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

                    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

                      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

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

                                  container.addEventListener("mouseleave", function() {
                                    if (this.classList.contains("profiler-min")) {
                                      this.querySelector(".profiler-min-max").style.display = "none";
                                    }
                                  });
                            Severity: Major
                            Found in lib/html/includes.js and 1 other location - About 1 hr to fix
                            lib/html/includes.js on lines 752..756

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

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

                                  container.addEventListener("mouseenter", function() {
                                    if (this.classList.contains("profiler-min")) {
                                      this.querySelector(".profiler-min-max").style.display = "block";
                                    }
                                  });
                            Severity: Major
                            Found in lib/html/includes.js and 1 other location - About 1 hr to fix
                            lib/html/includes.js on lines 757..761

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language