piotrmurach/tty-markdown

View on GitHub

Showing 9 of 13 total issues

File converter.rb has 436 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "kramdown/converter"
require "kramdown/element"
require "pastel"
require "strings"
require "uri"
Severity: Minor
Found in lib/tty/markdown/converter.rb - About 6 hrs to fix

    Class Converter has 45 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Converter < ::Kramdown::Converter::Base
          NEWLINE = "\n"
          SPACE = " "
    
          def initialize(root, options = {})
    Severity: Minor
    Found in lib/tty/markdown/converter.rb - About 6 hrs to fix

      Method convert_tr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert_tr(el, opts)
              indent = SPACE * @current_indent
              result = []
      
              if opts[:prev] && opts[:prev].type == :tr
      Severity: Minor
      Found in lib/tty/markdown/converter.rb - About 2 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 convert_td has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert_td(el, opts)
              indent = SPACE * @current_indent
              pipe_char = @symbols[:pipe]
              pipe = @pastel.decorate(pipe_char, *@theme[:table])
              suffix = " #{pipe} "
      Severity: Minor
      Found in lib/tty/markdown/converter.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 convert_a has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert_a(el, opts)
              result = []
      
              if URI.parse(el.attr["href"]).class == URI::MailTo
                el.attr["href"] = URI.parse(el.attr["href"]).to
      Severity: Minor
      Found in lib/tty/markdown/converter.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 convert_html_element has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert_html_element(el, opts)
              if el.value == "div"
                inner(el, opts)
              elsif %w[i em].include?(el.value)
                convert_em(el, opts)
      Severity: Minor
      Found in lib/tty/markdown/converter.rb - About 55 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 convert_xml_comment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def convert_xml_comment(el, opts)
              block = el.options[:category] == :block
              indent = SPACE * @current_indent
              content = el.value
              content.gsub!(/^<!-{2,}\s*/, "") if content.start_with?("<!--")
      Severity: Minor
      Found in lib/tty/markdown/converter.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

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

            def convert_dd(el, opts)
              result = []
              @current_indent += @indent unless opts[:parent].type == :root
              content = inner(el, opts)
              @current_indent -= @indent unless opts[:parent].type == :root
      Severity: Minor
      Found in lib/tty/markdown/converter.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 inner has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def inner(el, opts)
              result = []
              el.children.each_with_index do |inner_el, i|
                options = opts.dup
                options[:parent] = el
      Severity: Minor
      Found in lib/tty/markdown/converter.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