rapid7/metasploit-framework

View on GitHub
lib/rex/parser/graphml.rb

Summary

Maintainability
C
1 day
Test Coverage

Method start_element has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        def start_element(name, attrs = [])
          attrs = attrs.to_h

          case name
          when 'data'
Severity: Minor
Found in lib/rex/parser/graphml.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 graphml.rb has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Rex
  module Parser
    #
    # A partial implementation of the GraphML specification for loading structured data from an XML file. Notable
    # missing components include GraphML parse meta-data (XML attributes with the "parse" prefix), hyperedges and ports.
Severity: Minor
Found in lib/rex/parser/graphml.rb - About 3 hrs to fix

    Method start_element has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def start_element(name, attrs = [])
              attrs = attrs.to_h
    
              case name
              when 'data'
    Severity: Minor
    Found in lib/rex/parser/graphml.rb - About 1 hr to fix

      Method populate_element_default_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def populate_element_default_attributes(element)
                @meta_attributes.values.each do |meta_attribute|
                  next unless meta_attribute.valid_for? element
                  next if element.attributes.key? meta_attribute.name
                  next if meta_attribute.default.nil?
      Severity: Minor
      Found in lib/rex/parser/graphml.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 characters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def characters(string)
                element = @stack[-1]
                case element
                when Element::Data
                  parent = @stack[-2]
      Severity: Minor
      Found in lib/rex/parser/graphml.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_element has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def end_element(name)
                element = @stack.pop
      
                populate_element_default_attributes(element) if element.is_a? AttributeContainer
      
      
      Severity: Minor
      Found in lib/rex/parser/graphml.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 from_xml_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

                def self.from_xml_attributes(xml_attrs)
                  id = xml_attrs['id']
                  raise Error::InvalidAttributeError.new('key', 'id') if id.nil?
      
                  name = xml_attrs['attr.name']
      Severity: Minor
      Found in lib/rex/parser/graphml.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

      There are no issues that match your filters.

      Category
      Status