MiniProfiler/rack-mini-profiler

View on GitHub

Showing 151 of 176 total issues

Method profile_method has a Cognitive Complexity of 16 (exceeds 5 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 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

Method get_profile_script has 50 lines of code (exceeds 25 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 2 hrs to fix

    Function o has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          function o(c) {
            var d = c.substring(1, c.length - 1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));
            c = [];
    
            for (var a = [], k = d[0] === "^", e = k ? 1 : 0, h = d.length; e < h; ++e) {
    Severity: Minor
    Found in lib/html/pretty-print.js - About 2 hrs to fix

      Function o has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            function o(c) {
              var d = c.substring(1, c.length - 1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]", "g"));
              c = [];
      
              for (var a = [], k = d[0] === "^", e = k ? 1 : 0, h = d.length; e < h; ++e) {
      Severity: Minor
      Found in lib/html/vendor.js - About 2 hrs to fix

        Method inject_profiler has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def inject_profiler(env, status, headers, body)
              # mini profiler is meddling with stuff, we can not cache cause we will get incorrect data
              # Rack::ETag has already inserted some nonesense in the chain
              content_type = headers['Content-Type']
        
        
        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

        Function toggleHidden has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var toggleHidden = function toggleHidden(popup) {
            var trivial = popup.querySelector(".profiler-toggle-trivial");
            var childrenTime = popup.querySelector(
              ".profiler-toggle-duration-with-children"
            );
        Severity: Minor
        Found in lib/html/includes.js - About 1 hr to fix

          Method default has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.default
                  new.instance_eval {
                    @auto_inject      = true # automatically inject on every html page
                    @base_url_path    = "/mini-profiler-resources/".dup
                    @cookie_path      = "/".dup
          Severity: Minor
          Found in lib/mini_profiler/config.rb - About 1 hr to fix

            Method profile_gc has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def profile_gc(app, env)
            
                # for memsize_of
                require 'objspace'
            
            
            Severity: Minor
            Found in lib/mini_profiler/gc_profiler.rb - About 1 hr to fix

              Method analyze_memory has 45 lines of code (exceeds 25 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

                Method serve_snapshot has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def serve_snapshot(env)
                        MiniProfiler.authorize_request
                        status = 200
                        headers = { 'Content-Type' => 'text/html' }
                        qp = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
                Severity: Minor
                Found in lib/mini_profiler/actions.rb - About 1 hr to fix

                  Method write! has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def write!(headers)
                  
                          tokens_changed = false
                  
                          if MiniProfiler.request_authorized? && MiniProfiler.config.authorization_mode == :allow_authorized
                  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

                  Function n has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        function n(r) {
                          for (var j = r.c, q = [j, z], m = 0, t = r.source.match(o) || [], p = {}, c = 0, d = t.length; c < d; ++c) {
                            var a = t[c],
                                k = p[a],
                                e = void 0,
                  Severity: Minor
                  Found in lib/html/vendor.js - About 1 hr to fix

                    Function n has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          function n(r) {
                            for (var j = r.c, q = [j, z], m = 0, t = r.source.match(o) || [], p = {}, c = 0, d = t.length; c < d; ++c) {
                              var a = t[c],
                                  k = p[a],
                                  e = void 0,
                    Severity: Minor
                    Found in lib/html/pretty-print.js - About 1 hr to fix

                      Function fetch has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              window.fetch = function(input, init) {
                                var originalFetchRun = __originalFetch(input, init);
                      
                                originalFetchRun.then(function(response) {
                                  try {
                      Severity: Minor
                      Found in lib/html/includes.js - About 1 hr to fix

                        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

                            Severity
                            Category
                            Status
                            Source
                            Language