MiniProfiler/rack-mini-profiler

View on GitHub

Showing 176 of 176 total issues

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

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

              if (duration.finish < item.finish) {
                if (duration.finish < item.start) {
                  newList.push(item);
                  continue;
                }
    Severity: Major
    Found in lib/html/includes.js and 1 other location - About 2 hrs to fix
    lib/html/includes.js on lines 1322..1332

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

    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

              if (duration.start > item.start) {
                if (duration.start > item.finish) {
                  newList.push(item);
                  continue;
                }
    Severity: Major
    Found in lib/html/includes.js and 1 other location - About 2 hrs to fix
    lib/html/includes.js on lines 1334..1344

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

    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

    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

    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

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

                                (e.type == "click" &&
                                  !(queries !== e.target && queries.contains(e.target)) &&
                                  !(popup !== e.target && popup.contains(e.target)));
                        Severity: Major
                        Found in lib/html/includes.js and 1 other location - About 1 hr to fix
                        lib/html/includes.js on lines 544..546

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

                        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

                                (e.type == "click" &&
                                  !(popup !== e.target && popup.contains(e.target)) &&
                                  !(button !== e.target && button.contains(e.target)) &&
                        Severity: Major
                        Found in lib/html/includes.js and 1 other location - About 1 hr to fix
                        lib/html/includes.js on lines 538..540

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

                        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

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