k0kubun/hamlit

View on GitHub

Showing 84 of 84 total issues

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

    Avoid too many return statements within this method.
    Open

          return name, [:dynamic,
            %!"#{content.each_with_object(''.dup) {|(t, v), s| s << (t == :str ? inspect_obj(v)[1...-1] : "\#{#{v}}")}}"!]
    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 doctype(line.text) if line.text[0, 3] == '!!!'
      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 name, [:dynamic, var]
        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 name, [:static, content.first[1]] if content.size == 1
          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!(2)) 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 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 false unless scanner.scan(re)
                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!(3), false) if 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 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 unless scanner.scan(/\s*(?:,|$)\s*/)
                      Severity: Major
                      Found in lib/hamlit/parser/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/hamlit/filters/less.rb and 2 other locations - About 30 mins to fix
                        lib/hamlit/filters/sass.rb on lines 3..11
                        lib/hamlit/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 Sass < TiltBase
                              def compile(node)
                                require 'tilt/sass' if explicit_require?('sass')
                                temple = [:multi]
                        Severity: Minor
                        Found in lib/hamlit/filters/sass.rb and 2 other locations - About 30 mins to fix
                        lib/hamlit/filters/less.rb on lines 8..16
                        lib/hamlit/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/hamlit/filters/scss.rb and 2 other locations - About 30 mins to fix
                        lib/hamlit/filters/less.rb on lines 8..16
                        lib/hamlit/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

                        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

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

                        Severity
                        Category
                        Status
                        Source
                        Language