piotrmurach/tty-markdown

View on GitHub

Showing 14 of 14 total issues

File converter.rb has 438 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

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

          ASCII_SYMBOLS = {
            arrow: "->",
            bullet: "*",
            diamond: "*",
            bar: "│",
      Severity: Major
      Found in lib/tty/markdown.rb and 1 other location - About 1 hr to fix
      lib/tty/markdown.rb on lines 13..46

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

      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 2 locations. Consider refactoring.
      Open

          SYMBOLS = {
            arrow: "»",
            bullet: "●",
            bar: "┃",
            diamond: "◈",
      Severity: Major
      Found in lib/tty/markdown.rb and 1 other location - About 1 hr to fix
      lib/tty/markdown.rb on lines 48..81

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

      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 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 build_symbols has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_symbols(options)
            if options == :ascii
              ASCII_SYMBOLS
            elsif options.is_a?(Hash)
              base_symbols = options[:base] == :ascii ? ASCII_SYMBOLS : SYMBOLS
      Severity: Minor
      Found in lib/tty/markdown.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 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

      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

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

              if opts[:prev] && opts[:prev].type == :thead
                result << border(opts[:column_widths], :mid)
              else
                result << border(opts[:column_widths], :top)
              end
      Severity: Minor
      Found in lib/tty/markdown/converter.rb and 1 other location - About 15 mins to fix
      lib/tty/markdown/converter.rb on lines 514..518

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

      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 2 locations. Consider refactoring.
      Open

              if opts[:next] && opts[:next].type == :tfoot
                result << border(opts[:column_widths], :mid)
              else
                result << border(opts[:column_widths], :bottom)
              end
      Severity: Minor
      Found in lib/tty/markdown/converter.rb and 1 other location - About 15 mins to fix
      lib/tty/markdown/converter.rb on lines 503..507

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

      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

      Severity
      Category
      Status
      Source
      Language