rapid7/metasploit-framework

View on GitHub
lib/rex/post/hwbridge/extensions/automotive/automotive.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

  def send_isotp_and_wait_for_response(bus, src_id, dst_id, data, opt = {})
    # TODO: Implement sending ISO-TP > 8 bytes
    data = [ data ] if data.is_a? Integer
    if data.size < 8
      # Padding is handled differently after 0.0.3
Severity: Minor
Found in lib/rex/post/hwbridge/extensions/automotive/automotive.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 check_for_errors has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def check_for_errors(data)
    if data && (data.key? "Packets")
      if data["Packets"].size == 1
        if data["Packets"][0]["DATA"].size > 3 && data["Packets"][0]["DATA"][1].hex == 0x7F
          if ERR_MNEMONIC.key? data["Packets"][0]["DATA"][3].hex
Severity: Minor
Found in lib/rex/post/hwbridge/extensions/automotive/automotive.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 send_isotp_and_wait_for_response has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def send_isotp_and_wait_for_response(bus, src_id, dst_id, data, opt = {})
Severity: Minor
Found in lib/rex/post/hwbridge/extensions/automotive/automotive.rb - About 35 mins to fix

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

      def is_valid_bus?(bus)
        valid = false
        get_supported_buses if buses.nil?
        unless bus.blank?
          self.buses.each do |b|
    Severity: Minor
    Found in lib/rex/post/hwbridge/extensions/automotive/automotive.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