slim-template/slim

View on GitHub

Showing 32 of 32 total issues

File parser.rb has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Slim
  # Parses Slim code and transforms it to a Temple expression
  # @api private
  class Parser < Temple::Parser
    define_options :file,
Severity: Minor
Found in lib/slim/parser.rb - About 5 hrs to fix

    Method parse_tag has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_tag(tag)
          if @tag_shortcut[tag]
            @line.slice!(0, tag.size) unless @attr_shortcut[tag]
            tag = @tag_shortcut[tag]
          end
    Severity: Minor
    Found in lib/slim/parser.rb - About 4 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 parse_text_block has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_text_block(first_line = nil, text_indent = nil)
          result = [:multi]
          if !first_line || first_line.empty?
            text_indent = nil
          else
    Severity: Minor
    Found in lib/slim/parser.rb - About 4 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 parse_attributes has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_attributes(attributes)
          # Check to see if there is a delimiter right after the tag name
          delimiter = nil
          if @line =~ @attr_list_delims_re
            delimiter = @attr_list_delims[$1]
    Severity: Minor
    Found in lib/slim/parser.rb - About 3 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 process has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def process
          args = @args.dup
          unless @options[:input]
            file = args.shift
            if file
    Severity: Minor
    Found in lib/slim/command.rb - About 3 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 parse_tag has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_tag(tag)
          if @tag_shortcut[tag]
            @line.slice!(0, tag.size) unless @attr_shortcut[tag]
            tag = @tag_shortcut[tag]
          end
    Severity: Major
    Found in lib/slim/parser.rb - About 2 hrs to fix

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

          def initialize(opts = {})
            super
            @attr_list_delims = options[:attr_list_delims]
            @code_attr_delims = options[:code_attr_delims]
            tabsize = options[:tabsize]
      Severity: Minor
      Found in lib/slim/parser.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 parse_ruby_code has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_ruby_code(outer_delimiter)
            code, count, delimiter, close_delimiter = '', 0, nil, nil
      
            # Attribute ends with space or attribute delimiter
            end_re = /\A[\s#{Regexp.escape outer_delimiter.to_s}]/
      Severity: Minor
      Found in lib/slim/parser.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 set_opts has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def set_opts(opts)
            opts.on('-s', '--stdin', 'Read input from standard input instead of an input file') do
              @options[:input] = $stdin
            end
      
      
      Severity: Minor
      Found in lib/slim/command.rb - About 2 hrs to fix

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

                def lambda(name, &block)
                  @lookup.each do |lookup|
                    case lookup
                    when :method
                      return @dict.public_send(name, &block) if @dict.respond_to?(name, false)
        Severity: Minor
        Found in lib/slim/logic_less/context.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 [] has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

                def [](name)
                  @lookup.each do |lookup|
                    case lookup
                    when :method
                      return @dict.public_send(name) if @dict.respond_to?(name, false)
        Severity: Minor
        Found in lib/slim/logic_less/context.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 parse_attributes has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_attributes(attributes)
              # Check to see if there is a delimiter right after the tag name
              delimiter = nil
              if @line =~ @attr_list_delims_re
                delimiter = @attr_list_delims[$1]
        Severity: Minor
        Found in lib/slim/parser.rb - About 1 hr to fix

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

              def parse_line_indicators
                case @line
                when /\A\/!( ?)/
                  # HTML comment
                  @stacks.last << [:html, :comment, [:slim, :text, :verbatim, parse_text_block($', @indents.last + $1.size + 2)]]
          Severity: Minor
          Found in lib/slim/parser.rb - About 1 hr to fix

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

                def parse_line
                  if @line =~ /\A\s*\Z/
                    @stacks.last << [:newline]
                    return
                  end
            Severity: Minor
            Found in lib/slim/parser.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 unknown_line_indicator has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def unknown_line_indicator
                    if @line =~ /\A>( ?)/
                      # Found explicit text block.
                      @stacks.last << [:slim, :text, :explicit, parse_text_block($', @indents.last + $1.size + 1)]
                    else
            Severity: Minor
            Found in lib/slim/smart/parser.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 on_multi has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def on_multi(*exps)
                    # The [:multi] blocks serve two purposes.
                    # On outer level, they collect the building blocks like
                    # tags, verbatim text, and implicit/explicit text.
                    # Within a text block, they collect the individual
            Severity: Minor
            Found in lib/slim/smart/filter.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 parse_quoted_attribute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_quoted_attribute(quote)
                  value, count = '', 0
            
                  until count == 0 && @line[0] == quote[0]
                    if @line =~ /\A(\\)?\Z/
            Severity: Minor
            Found in lib/slim/parser.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 on_multi has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def on_multi(*exps)
                  result = [:multi]
                  # This variable is true if the previous line was
                  # (1) a control code and (2) contained indented content.
                  prev_indent = false
            Severity: Minor
            Found in lib/slim/end_inserter.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 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def initialize(opts = {})
                  super
                  @attr_list_delims = options[:attr_list_delims]
                  @code_attr_delims = options[:code_attr_delims]
                  tabsize = options[:tabsize]
            Severity: Minor
            Found in lib/slim/parser.rb - About 1 hr to fix

              Method on_html_tag has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def on_html_tag(tag, attributes, content = nil)
                    return super if tag != 'include'
                    name = content.to_a.flatten.select {|s| String === s }.join
                    raise ArgumentError, 'Invalid include statement' unless attributes == [:html, :attrs] && !name.empty?
                    unless file = find_file(name)
              Severity: Minor
              Found in lib/slim/include.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