plugins/tags/main.rb

Summary

Maintainability
C
1 day
Test Coverage

Method process_tag has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def process_tag(name, attrs, content, context)
    tag = @@tags[name]
    name = tag.full_name

    tag_counter = context[:tag_counter] ||= {}
Severity: Minor
Found in plugins/tags/main.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

File main.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
Open

description  'Extends wiki text with custom xml tags'
dependencies 'filters'

# Simple XML tag parser based on regular expressions
class TagSoupParser
Severity: Minor
Found in plugins/tags/main.rb - About 2 hrs to fix

    Method replace_protected_tags has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def replace_protected_tags(content)
        # Protected elements can be nested into each other
        MAX_RECURSION.times do
          break if !content.gsub!(/#{@protection_prefix}(\d+)#{@protection_suffix}/) do
            element = @protected_tags[$1.to_i]
    Severity: Minor
    Found in plugins/tags/main.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 get_content has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_content
        stack = [@name]
        text = ''
        while !stack.empty?
          case @content
    Severity: Minor
    Found in plugins/tags/main.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 process_tag has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def process_tag(name, attrs, content, context)
        tag = @@tags[name]
        name = tag.full_name
    
        tag_counter = context[:tag_counter] ||= {}
    Severity: Minor
    Found in plugins/tags/main.rb - About 1 hr to fix

      Method get_content has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def get_content
          stack = [@name]
          text = ''
          while !stack.empty?
            case @content
      Severity: Minor
      Found in plugins/tags/main.rb - About 1 hr to fix

        Method define has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.define(name, options = {}, &block)
            raise 'Dynamic tag cannot be immediate' if options[:dynamic] && options[:immediate]
            raise 'Tag must take two or three arguments' if block.arity != 2 && block.arity != 3
            # Find the plugin which provided this tag.
            plugin = Plugin.for(block)
        Severity: Minor
        Found in plugins/tags/main.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