under-os/under-os

View on GitHub
gems/under-os-ui/lib/under_os/parser/html.rb

Summary

Maintainability
A
3 hrs
Test Coverage

Method close_tag has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def close_tag
    if m = @chunk.match(/\A<\/([a-z]+)>/)
      while node = @stack.pop
        if node[:tag] != m[1]
          if @stack.size > 0
Severity: Minor
Found in gems/under-os-ui/lib/under_os/parser/html.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_attrs_in has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_attrs_in(string)
    merge_data_attrs({}.tap do |hash|
      string.scan(/([a-z][a-z_\-\d]+)=('|")(.+?)(\2)/).each do |match|
        value = match[0] == match[2] ? true : match[2]
        value = true  if value == 'true'
Severity: Minor
Found in gems/under-os-ui/lib/under_os/parser/html.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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def parse(html)
    html = html.strip.gsub(/<\!--[\s\S]*?-->/, '').gsub(/>\s+/, '>').gsub(/\s+</, '<')

    [].tap do |top|
      @top   = top
Severity: Minor
Found in gems/under-os-ui/lib/under_os/parser/html.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

There are no issues that match your filters.

Category
Status