increments/qiita-markdown

View on GitHub

Showing 10 of 10 total issues

Method call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def call
          result[:mentioned_usernames] ||= []

          doc.search(".//text()").each do |node|
            content = node.to_html
Severity: Minor
Found in lib/qiita/markdown/filters/mention.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def call
          doc.search("a").each do |anchor|
            next unless anchor["href"]

            href = anchor["href"].strip
Severity: Minor
Found in lib/qiita/markdown/filters/external_link.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 call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def call
          result[:codes] ||= []
          doc.search("pre").each do |pre|
            next unless (code = pre.at("code"))

Severity: Minor
Found in lib/qiita/markdown/filters/code_block.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 transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def transform
          if name == "script"
            if URL_WHITE_LIST.include?(node["src"]) || HOST_WHITE_LIST.include?(host_of(node["src"]))
              node["async"] = "async" unless node.attributes.key?("async")
              node.children.unlink
Severity: Minor
Found in lib/qiita/markdown/transformers/filter_script.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 clean_complex_markups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def clean_complex_markups
          doc.traverse do |node|
            next unless node.element?
            next if SIMPLE_ELEMENTS.include?(node.name)

Severity: Minor
Found in lib/qiita/markdown/filters/simplify.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

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

        def process_text_node(node)
          node.content.each_char.with_index do |char, index|
            current_char_is_blank = char.strip.empty?

            @current_length += 1 if !@previous_char_was_blank || !current_char_is_blank
Severity: Minor
Found in lib/qiita/markdown/filters/truncate.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 host_of has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def host_of(url)
          if url
            scheme = URI.parse(url).scheme
            Addressable::URI.parse(url).host if ["http", "https", nil].include? scheme
          end
Severity: Minor
Found in lib/qiita/markdown/transformers/filter_iframe.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 host_of has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def host_of(url)
          if url
            scheme = URI.parse(url).scheme
            Addressable::URI.parse(url).host if %w[http https].include? scheme
          end
Severity: Minor
Found in lib/qiita/markdown/transformers/filter_script.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def call
          if context[:group_mention_url_generator]
            result[:mentioned_groups] ||= []
            doc.search(".//text()").each do |node|
              mentionable_node = MentionableNode.new(node, context[:group_mention_url_generator])
Severity: Minor
Found in lib/qiita/markdown/filters/group_mention.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 highlighted_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def highlighted_node
            if specific_language && Rouge::Lexer.find(specific_language)
              begin
                highlight(specific_language).presence or raise
              rescue StandardError
Severity: Minor
Found in lib/qiita/markdown/filters/syntax_highlight.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