AndyObtiva/glimmer-dsl-xml

View on GitHub

Showing 6 of 6 total issues

Method initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(parent, name, attributes, &contents)
        @is_name_space = false
        @children = []
        @parent = parent
        if attributes.is_a?(Array)
Severity: Minor
Found in lib/glimmer/xml/node.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 initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def initialize(parent, name, attributes, &contents)
        @is_name_space = false
        @children = []
        @parent = parent
        if attributes.is_a?(Array)
Severity: Minor
Found in lib/glimmer/xml/node.rb - About 1 hr to fix

    Method append_attributes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def append_attributes(node)
            return if node.name == 'xml' || node.name_space_context?
    #         Glimmer::Config.logger&.debug "Append Attributes"
    #         Glimmer::Config.logger&.debug(node.attributes)
            node.attributes.each do |attribute, value|
    Severity: Minor
    Found in lib/glimmer/xml/xml_visitor.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 add_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            def add_content(parent, keyword, *args, &block)
              return_value = block.call(parent)
              if !return_value.is_a?(Glimmer::XML::Node) and !parent.children.include?(return_value)
                text = return_value.to_s
                first_match = text.match(/[#][^{]+[{][^}]+[}]/)
    Severity: Minor
    Found in lib/glimmer/dsl/xml/node_parent_expression.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 render_html_tag? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def render_html_tag?(node)
            if node.name == 'html'
              node_children = node.children.select {|node_or_text| node_or_text.is_a?(Glimmer::XML::Node)}
              if !node_children.empty?
                children_names = node_children.map(&:name)
    Severity: Minor
    Found in lib/glimmer/xml/html_visitor.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 end_open_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def end_open_tag(node)
            return if node.name == 'xml' || node.name_space_context?
            if (node.contents)
              @document += ">"
            else
    Severity: Minor
    Found in lib/glimmer/xml/xml_visitor.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