actionview/lib/action_view/template.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Template has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Template
    extend ActiveSupport::Autoload

    STRICT_LOCALS_REGEX = /\#\s+locals:\s+\((.*)\)/

Severity: Minor
Found in actionview/lib/action_view/template.rb - About 3 hrs to fix

    File template.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "thread"
    require "delegate"
    
    module ActionView
      # = Action View \Template
    Severity: Minor
    Found in actionview/lib/action_view/template.rb - About 2 hrs to fix

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

          def render(view, locals, buffer = nil, implicit_locals: [], add_to_stack: true, &block)
            instrument_render_template do
              compile!(view)
      
              if strict_locals? && @strict_local_keys && !implicit_locals.empty?
      Severity: Minor
      Found in actionview/lib/action_view/template.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 encode! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def encode!
            source = self.source
      
            return source unless source.encoding == Encoding::BINARY
      
      
      Severity: Minor
      Found in actionview/lib/action_view/template.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 compile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def compile(mod)
              begin
                mod.module_eval(compiled_source, identifier, offset)
              rescue SyntaxError
                # Account for when code in the template is not syntactically valid; e.g. if we're using
      Severity: Minor
      Found in actionview/lib/action_view/template.rb - About 35 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 compiled_source has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def compiled_source
              set_strict_locals = strict_locals!
              source = encode!
              code = @handler.call(self, source)
      
      
      Severity: Minor
      Found in actionview/lib/action_view/template.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