k0kubun/hamlit

View on GitHub

Showing 71 of 84 total issues

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

    def handle_multiline(line)
      return unless is_multiline?(line.text)
      line.text.slice!(-1)
      loop do
        new_line = @template.first
Severity: Minor
Found in lib/hamlit/parser/haml_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 each_attr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def each_attr(tokens)
      attr_tokens = []
      open_tokens = Hash.new { |h, k| h[k] = 0 }

      tokens.each do |token|
Severity: Minor
Found in lib/hamlit/attribute_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 compile_contents has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def compile_contents(node, &block)
        case
        when !node.children.empty?
          yield(node)
        when node.value[:value].nil? && self_closing?(node)
Severity: Minor
Found in lib/hamlit/compiler/tag_compiler.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 process_line has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def process_line(line)
      case line.text[0]
      when DIV_CLASS; push div(line)
      when DIV_ID
        return push plain(line) if %w[{ @ $].include?(line.text[1])
Severity: Minor
Found in lib/hamlit/parser/haml_parser.rb - About 1 hr to fix

    Method parse_new_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_new_attributes(text)
          scanner = StringScanner.new(text)
          last_line = @line.index + 1
          attributes = {}
    
    
    Severity: Minor
    Found in lib/hamlit/parser/haml_parser.rb - About 1 hr to fix

      Method each_attr has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def each_attr(tokens)
            attr_tokens = []
            open_tokens = Hash.new { |h, k| h[k] = 0 }
      
            tokens.each do |token|
      Severity: Minor
      Found in lib/hamlit/attribute_parser.rb - About 1 hr to fix

        Method build_attributes has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def build_attributes(is_html, attr_wrapper, escape_attrs, hyphenate_data_attrs, attributes = {})
                # @TODO this is an absolutely ridiculous amount of arguments. At least
                # some of this needs to be moved into an instance method.
                join_char = hyphenate_data_attrs ? '-' : '_'
        
        
        Severity: Minor
        Found in lib/hamlit/parser/haml_attribute_builder.rb - About 1 hr to fix

          Method compile_boolean! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def compile_boolean!(temple, key, values)
                exp = literal_for(values.last)
          
                if Temple::StaticAnalyzer.static?(exp)
                  value = eval(exp)
          Severity: Minor
          Found in lib/hamlit/attribute_compiler.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 next_line has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def next_line
                line = @template.shift || raise(StopIteration)
          
                # `flat?' here is a little outdated,
                # so we have to manually check if either the previous or current line
          Severity: Minor
          Found in lib/hamlit/parser/haml_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 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def on_multi(*exps)
                exps = exps.dup
                result = [:multi]
                buffer = []
          
          
          Severity: Minor
          Found in lib/hamlit/dynamic_merger.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_object_ref has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_object_ref(ref)
                prefix = ref[1]
                ref = ref[0]
                # Let's make sure the value isn't nil. If it is, return the default Hash.
                return {} if ref.nil?
          Severity: Minor
          Found in lib/hamlit/parser/haml_buffer.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 compute_tabs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def compute_tabs(line)
                return 0 if line.text.empty? || !line.whitespace
          
                if @indentation.nil?
                  @indentation = line.whitespace
          Severity: Minor
          Found in lib/hamlit/parser/haml_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 balance has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def balance(scanner, start, finish, count = 0)
                str = ''.dup
                scanner = StringScanner.new(scanner) unless scanner.is_a? StringScanner
                regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
                while scanner.scan(regexp)
          Severity: Minor
          Found in lib/hamlit/parser/haml_util.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 count_lines has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.count_lines(exp)
                type, *args = exp
                case type
                when :multi
                  args.map { |a| count_lines(a) }.reduce(:+) || 0
          Severity: Minor
          Found in lib/hamlit/temple_line_counter.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 close_silent_script has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def close_silent_script(node)
                @script_level_stack.pop if ["if", "case", "unless"].include? node.value[:keyword]
          
                # Post-process case statements to normalize the nesting of "when" clauses
                return unless node.value[:keyword] == "case"
          Severity: Minor
          Found in lib/hamlit/parser/haml_parser.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 capture_haml has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def capture_haml(*args, &block)
                buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer
                with_haml_buffer(buffer) do
                  position = haml_buffer.buffer.length
          
          
          Severity: Minor
          Found in lib/hamlit/parser/haml_helpers.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 haml_internal_concat has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def haml_internal_concat(text = "", newline = true, indent = true)
                if haml_buffer.tabulation == 0
                  haml_buffer.buffer << "#{text}#{"\n" if newline}"
                else
                  haml_buffer.buffer << %[#{haml_indent if indent}#{text.to_s.gsub("\n", "\n#{haml_indent}")}#{"\n" if newline}]
          Severity: Minor
          Found in lib/hamlit/parser/haml_helpers.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 build has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def build(escape_attrs, quote, format, boolean_attributes, object_ref, *hashes)
          Severity: Minor
          Found in lib/hamlit/attribute_builder.rb - About 45 mins to fix

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

                def handle_ruby_multiline(line)
                  line.text.rstrip!
                  return line unless is_ruby_multiline?(line.text)
                  begin
                    # Use already fetched @next_line in the first loop. Otherwise, fetch next
            Severity: Minor
            Found in lib/hamlit/parser/haml_parser.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 build_boolean! has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def build_boolean!(escape_attrs, quote, format, buf, key, value)
            Severity: Minor
            Found in lib/hamlit/attribute_builder.rb - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language