rapid7/metasploit-framework

View on GitHub
plugins/alias.rb

Summary

Maintainability
D
1 day
Test Coverage

Method cmd_alias has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

      def cmd_alias(*args)
        # we parse args manually instead of using @@alias.opts.parse to handle special cases
        case args.length
        when 0 # print the list of current aliases
          if @aliases.empty?
Severity: Minor
Found in plugins/alias.rb - About 6 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 cmd_alias has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def cmd_alias(*args)
        # we parse args manually instead of using @@alias.opts.parse to handle special cases
        case args.length
        when 0 # print the list of current aliases
          if @aliases.empty?
Severity: Major
Found in plugins/alias.rb - About 3 hrs to fix

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

          def valid_alias?(name, value)
            # print_good "Assessing validay for #{name} and #{value}"
            # we validate two things, the name and the value
    
            ### name
    Severity: Minor
    Found in plugins/alias.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 tab_complete_aliases_and_commands has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def tab_complete_aliases_and_commands
            items = []
            # gather all the current commands the driver's dispatcher's have
            driver.dispatcher_stack.each do |dispatcher|
              next unless dispatcher.respond_to?(:commands)
    Severity: Minor
    Found in plugins/alias.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

    Avoid too many return statements within this method.
    Open

                return
    Severity: Major
    Found in plugins/alias.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                    return false
      Severity: Major
      Found in plugins/alias.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return true
        Severity: Major
        Found in plugins/alias.rb - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status