rapid7/metasploit-framework

View on GitHub
lib/msf/ui/console/command_dispatcher/jobs.rb

Summary

Maintainability
F
3 days
Test Coverage

Method cmd_jobs has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

          def cmd_jobs(*args)
            # Make the default behavior listing all jobs if there were no options
            # or the only option is the verbose flag
            args.unshift("-l") if args.empty? || args == ["-v"]

Severity: Minor
Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 7 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_jobs has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

          def cmd_jobs(*args)
            # Make the default behavior listing all jobs if there were no options
            # or the only option is the verbose flag
            args.unshift("-l") if args.empty? || args == ["-v"]

Severity: Major
Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 4 hrs to fix

    File jobs.rb has 335 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Msf
      module Ui
        module Console
          module CommandDispatcher
            #
    Severity: Minor
    Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 4 hrs to fix

      Method cmd_handler has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def cmd_handler(*args)
                  # Display the help banner if no arguments were passed
                  if args.empty?
                    cmd_handler_help
                    return
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 3 hrs to fix

        Method cmd_handler has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

                  def cmd_handler(*args)
                    # Display the help banner if no arguments were passed
                    if args.empty?
                      cmd_handler_help
                      return
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/jobs.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

        Method add_persist_job has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def add_persist_job(job_id)
                    if job_id && framework.jobs.has_key?(job_id.to_s)
                      handler_ctx = framework.jobs[job_id.to_s].ctx[1]
                      unless handler_ctx and handler_ctx.respond_to?(:replicant)
                        print_error("Add persistent job failed: job #{job_id} is not payload handler.")
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 1 hr to fix

          Method add_persist_job has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                    def add_persist_job(job_id)
                      if job_id && framework.jobs.has_key?(job_id.to_s)
                        handler_ctx = framework.jobs[job_id.to_s].ctx[1]
                        unless handler_ctx and handler_ctx.respond_to?(:replicant)
                          print_error("Add persistent job failed: job #{job_id} is not payload handler.")
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/jobs.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 lib/msf/ui/console/command_dispatcher/jobs.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                          return
            Severity: Major
            Found in lib/msf/ui/console/command_dispatcher/jobs.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status