k0kubun/hamlit

View on GitHub

Showing 71 of 84 total issues

Avoid too many return statements within this method.
Open

        return push haml_comment(line.text[2..-1]) if line.text[1] == SILENT_COMMENT
Severity: Major
Found in lib/hamlit/parser/haml_parser.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return push script(line.strip!(2), false) if line.text[1] == SCRIPT
    Severity: Major
    Found in lib/hamlit/parser/haml_parser.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return push flat_script(line.strip!(2), false) if line.text[1] == FLAT_SCRIPT
      Severity: Major
      Found in lib/hamlit/parser/haml_parser.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return push plain(line.strip!(1), false) if line.text[1] == ?\s || line.text[1..2] == '#{'
        Severity: Major
        Found in lib/hamlit/parser/haml_parser.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return unless scanner.scan(/\s*(?:,|$)\s*/)
          Severity: Major
          Found in lib/hamlit/parser/haml_parser.rb - About 30 mins to fix

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

                def process_load_options
                  if options[:load_path]
                    options[:load_path].split(':').each do |dir|
                      $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
                    end
            Severity: Minor
            Found in lib/hamlit/cli.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 process_indent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def process_indent(line)
                  return unless line.tabs <= @template_tabs && @template_tabs > 0
            
                  to_close = @template_tabs - line.tabs
                  to_close.times {|i| close unless to_close - 1 - i == 0 && continuation_script?(line.text)}
            Severity: Minor
            Found in lib/hamlit/parser/haml_parser.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 haml_comment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def haml_comment(text)
                  if filter_opened?
                    @flat = true
                    @filter_buffer = String.new
                    @filter_buffer << "#{text}\n" unless text.empty?
            Severity: Minor
            Found in lib/hamlit/parser/haml_parser.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 compile_text! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def compile_text!(temple, node, prefix)
                    text = node.value[:text].rstrip.gsub(/^/, prefix)
                    if ::Hamlit::HamlUtil.contains_interpolation?(node.value[:text])
                      # original: Haml::Filters#compile
                      text = ::Hamlit::HamlUtil.unescape_interpolation(text).gsub(/(\\+)n/) do |s|
            Severity: Minor
            Found in lib/hamlit/filters/text_base.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 init_compiled_benches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def init_compiled_benches
                context = Context.new
            
                if Gem::Version.new(Haml::VERSION) >= Gem::Version.new('6.0.0')
                  context.instance_eval %{
            Severity: Minor
            Found in benchmark/run-benchmarks.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 find_and_preserve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def find_and_preserve(input = nil, tags = DEFAULT_PRESERVE_TAGS, &block)
                  return find_and_preserve(capture_haml(&block), input || tags) if block
            
                  tags = tags.each_with_object('') do |t, s|
                    s << '|' unless s.empty?
            Severity: Minor
            Found in lib/hamlit/rails_helpers.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