rapid7/metasploit-framework

View on GitHub
lib/msf/ui/console/module_command_dispatcher.rb

Summary

Maintainability
C
1 day
Test Coverage

Method check_multiple has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

  def check_multiple(mod)
    rhosts_walker = Msf::RhostsWalker.new(mod.datastore['RHOSTS'], mod.datastore).to_enum
    rhosts_walker_count = rhosts_walker.count

    # Short-circuit check_multiple if it's a single host, or doesn't have any hosts set
Severity: Minor
Found in lib/msf/ui/console/module_command_dispatcher.rb - About 4 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

Method check_multiple has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def check_multiple(mod)
    rhosts_walker = Msf::RhostsWalker.new(mod.datastore['RHOSTS'], mod.datastore).to_enum
    rhosts_walker_count = rhosts_walker.count

    # Short-circuit check_multiple if it's a single host, or doesn't have any hosts set
Severity: Major
Found in lib/msf/ui/console/module_command_dispatcher.rb - About 2 hrs to fix

    Method check_simple has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_simple(instance=nil)
        unless instance
          instance = mod
        end
    
    
    Severity: Minor
    Found in lib/msf/ui/console/module_command_dispatcher.rb - About 2 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

    Method check_simple has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def check_simple(instance=nil)
        unless instance
          instance = mod
        end
    
    
    Severity: Minor
    Found in lib/msf/ui/console/module_command_dispatcher.rb - About 1 hr to fix

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

        def cmd_check(*args, opts: {})
          if (args.include?('-r') || args.include?('--reload-libs')) && !opts[:previously_reloaded]
            driver.run_single('reload_lib -a')
          end
      
      
      Severity: Minor
      Found in lib/msf/ui/console/module_command_dispatcher.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

      There are no issues that match your filters.

      Category
      Status