Showing 77 of 77 total issues

Avoid too many return statements within this method.
Open

        return push doctype(line.text) if line.text[0, 3] == '!!!'
Severity: Major
Found in lib/haml/parser.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return push plain(line.strip!(3), false) if line.text[1, 2] == '=='
    Severity: Major
    Found in lib/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/haml/parser.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

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

          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/haml/parser.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return false unless scanner.scan(re)
            Severity: Major
            Found in lib/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/haml/parser.rb - About 30 mins to fix

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class Filters
                    class Less < TiltBase
                      def compile(node)
                        require 'tilt/less' if explicit_require?('less')
                        temple = [:multi]
                Severity: Minor
                Found in lib/haml/filters/less.rb and 2 other locations - About 30 mins to fix
                lib/haml/filters/sass.rb on lines 3..11
                lib/haml/filters/scss.rb on lines 3..11

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class Filters
                    class Scss < TiltBase
                      def compile(node)
                        require 'tilt/sass' if explicit_require?('scss')
                        temple = [:multi]
                Severity: Minor
                Found in lib/haml/filters/scss.rb and 2 other locations - About 30 mins to fix
                lib/haml/filters/less.rb on lines 8..16
                lib/haml/filters/sass.rb on lines 3..11

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 3 locations. Consider refactoring.
                Open

                  class Filters
                    class Sass < TiltBase
                      def compile(node)
                        require 'tilt/sass' if explicit_require?('sass')
                        temple = [:multi]
                Severity: Minor
                Found in lib/haml/filters/sass.rb and 2 other locations - About 30 mins to fix
                lib/haml/filters/less.rb on lines 8..16
                lib/haml/filters/scss.rb on lines 3..11

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 32.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                      def string_literal?(code)
                        return false if SyntaxChecker.syntax_error?(code)
                
                        type, instructions = Ripper.sexp(code)
                        return false if type != :program
                Severity: Minor
                Found in lib/haml/string_splitter.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 ::Haml::Util.contains_interpolation?(node.value[:text])
                          # original: Haml::Filters#compile
                          text = ::Haml::Util.unescape_interpolation(text).gsub(/(\\+)n/) do |s|
                Severity: Minor
                Found in lib/haml/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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def call(template, source = nil)
                      source ||= template.source
                      options = RailsTemplate.options
                
                      # Make the filename available in parser etc.
                Severity: Minor
                Found in lib/haml/rails_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

                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/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 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/haml/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

                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/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 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/haml/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

                Severity
                Category
                Status
                Source
                Language