kaspernj/html_gen

View on GitHub
lib/html_gen/parser.rb

Summary

Maintainability
D
1 day
Test Coverage

Method parse_tag has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_tag(args = {})
    if match = search(/\A\s*<\s*(\/|)\s*(\S+?)(\s+|\/\s*>|>)/)
      tag_name = match[2].to_s.strip.downcase
      start_sign = match[1].to_s.strip.downcase
      end_sign = match[3].to_s.strip.downcase
Severity: Minor
Found in lib/html_gen/parser.rb - About 4 hrs 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_content_of_tag has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_content_of_tag(ele, tag_name)
    raise "Empty tag-name given: '#{tag_name}'." if tag_name.to_s.strip.empty?
    raise "No 'ele' was given." unless ele

    loop do
Severity: Minor
Found in lib/html_gen/parser.rb - About 3 hrs 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_attr_of_tag has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_attr_of_tag(ele, tag_name)
    loop do
      if (match = search(/\A\s*(\S+)=("|'|)/))
        attr_name = match[1]
        raise "Attribute already exists on element: '#{attr_name}'." if ele.attr.key?(attr_name)
Severity: Minor
Found in lib/html_gen/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 parse_tag has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_tag(args = {})
    if match = search(/\A\s*<\s*(\/|)\s*(\S+?)(\s+|\/\s*>|>)/)
      tag_name = match[2].to_s.strip.downcase
      start_sign = match[1].to_s.strip.downcase
      end_sign = match[3].to_s.strip.downcase
Severity: Minor
Found in lib/html_gen/parser.rb - About 1 hr to fix

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

      def parse_attr_until_quote(quote_char, quote_val)
        val = ""
    
        loop do
          ensure_buffer
    Severity: Minor
    Found in lib/html_gen/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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(args)
        if args[:io]
          @io = args[:io]
        elsif args[:str]
          @io = ::StringIO.new(args[:str])
    Severity: Minor
    Found in lib/html_gen/parser.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

    There are no issues that match your filters.

    Category
    Status