BaseSecrete/rorvswild

View on GitHub
lib/rorvswild/local/middleware.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method serve_embed_profiler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def serve_embed_profiler(env)
        status, headers, body = app.call(env)
        status = status.to_i
        if status >= 200 && status < 300 && headers["Content-Type"] && headers["Content-Type"].include?("text/html")
          if headers["Content-Encoding"]
Severity: Minor
Found in lib/rorvswild/local/middleware.rb - About 45 mins 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 inject_into has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def inject_into(html)
        if index = html.index("</body>")
          markup = File.read(File.join(LOCAL_FOLDER, "local.html.erb"))
          markup = ERB.new(markup).result(binding)
          markup = markup.html_safe if markup.respond_to?(:html_safe)
Severity: Minor
Found in lib/rorvswild/local/middleware.rb - About 25 mins 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

There are no issues that match your filters.

Category
Status