slim-template/slim

View on GitHub

Showing 33 of 33 total issues

Method process has 34 lines of code (exceeds 25 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 1 hr to fix

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

    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 code_attr has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def code_attr(name, escape, value)
            if delim = @options[:merge_attrs][name]
              value = Array === value ? value.join(delim) : value.to_s
              attr(name, escape_html(escape, value)) unless value.empty?
            elsif @options[:hyphen_attrs].include?(name) && Hash === value
    Severity: Minor
    Found in lib/slim/splat/builder.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_text_block has 31 lines of code (exceeds 25 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 1 hr to fix

      Method make_builder has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def make_builder(attrs)
              @splat_options ||= unique_name
              builder = unique_name
              result = [:multi, [:code, "#{builder} = ::Slim::Splat::Builder.new(#{@splat_options})"]]
              attrs.each do |attr|
      Severity: Minor
      Found in lib/slim/splat/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 set_opts has a Cognitive Complexity of 10 (exceeds 5 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 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 build_attrs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_attrs
              attrs = @options[:sort_attrs] ? @attrs.sort_by(&:first) : @attrs
              attrs.map do |k, v|
                if v == true
                  if @options[:format] == :xhtml
      Severity: Minor
      Found in lib/slim/splat/builder.rb - About 55 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 hyphen_attr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def hyphen_attr(name, escape, value)
              if Hash === value
                if @options[:hyphen_underscore_attrs] 
                  value.each do |n, v|
                    hyphen_attr("#{name}-#{n.to_s.gsub('_', '-')}", escape, v)
      Severity: Minor
      Found in lib/slim/splat/builder.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(error, file, line, lineno, column)
      Severity: Minor
      Found in lib/slim/parser.rb - About 35 mins to fix

        Method build_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def build_tag(&block)
                tag = @attrs.delete('tag').to_s
                tag = @options[:default_tag] if tag.empty?
                if block
                  # This is a bit of a hack to get a universal capturing.
        Severity: Minor
        Found in lib/slim/splat/builder.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 on_slim_interpolate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def on_slim_interpolate(string)
                if @active
                  string = "\n" + string if @prepend && string !~ @prepend_re
                  string += "\n" if @append && string !~ @append_re
                end
        Severity: Minor
        Found in lib/slim/smart/filter.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

        Method attr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def attr(name, value)
                if name =~ INVALID_ATTRIBUTE_NAME_REGEX
                  raise InvalidAttributeNameError, "Invalid attribute name '#{name}' was rendered"
                end
                if @attrs[name]
        Severity: Minor
        Found in lib/slim/splat/builder.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

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

              def on_html_tag(name, attrs, content = nil)
                return super if name != '*'
                builder, block = make_builder(attrs[2..-1])
                if content
                  [:multi,
        Severity: Minor
        Found in lib/slim/splat/filter.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

        Severity
        Category
        Status
        Source
        Language