rapid7/metasploit-framework

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

Summary

Maintainability
F
3 days
Test Coverage

Method tab_complete_option_values has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

        def tab_complete_option_values(mod, str, words, opt:)
          if words.last.casecmp?('SessionTlvLogging')
            return %w[console true false file:<file>]
          end

Severity: Minor
Found in lib/msf/ui/console/module_option_tab_completion.rb - About 5 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 option_values_dispatch has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

        def option_values_dispatch(mod, o, str, words)
          res = []
          res << o.default.to_s if o.default
          case o
          when Msf::OptAddress
Severity: Minor
Found in lib/msf/ui/console/module_option_tab_completion.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

File module_option_tab_completion.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
  module Ui
    module Console
      ###
      #
Severity: Minor
Found in lib/msf/ui/console/module_option_tab_completion.rb - About 2 hrs to fix

    Method option_values_dispatch has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def option_values_dispatch(mod, o, str, words)
              res = []
              res << o.default.to_s if o.default
              case o
              when Msf::OptAddress
    Severity: Major
    Found in lib/msf/ui/console/module_option_tab_completion.rb - About 2 hrs to fix

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

              def tab_complete_option_names(mod, str, words)
                res = tab_complete_module_datastore_names(mod, str, words) || [ ]
      
                if !mod
                  return res
      Severity: Minor
      Found in lib/msf/ui/console/module_option_tab_completion.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_option_names has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def tab_complete_option_names(mod, str, words)
                res = tab_complete_module_datastore_names(mod, str, words) || [ ]
      
                if !mod
                  return res
      Severity: Minor
      Found in lib/msf/ui/console/module_option_tab_completion.rb - About 1 hr to fix

        Method tab_complete_option_values has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def tab_complete_option_values(mod, str, words, opt:)
                  if words.last.casecmp?('SessionTlvLogging')
                    return %w[console true false file:<file>]
                  end
        
        
        Severity: Minor
        Found in lib/msf/ui/console/module_option_tab_completion.rb - About 1 hr to fix

          Avoid too many return statements within this method.
          Open

                      return option_values_encoders if opt.upcase == 'STAGEENCODER'
          Severity: Major
          Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return option_values_actions(mod) if opt.upcase == 'ACTION'
            Severity: Major
            Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return option_values_sessions(mod) if opt.upcase == 'SESSION'
              Severity: Major
              Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

                              return option_values_targets(mod) if opt.upcase == 'TARGET'
                  Severity: Major
                  Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return option_values_nops if opt.upcase == 'NOPS'
                    Severity: Major
                    Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return option_values_payloads(mod) if opt.upcase == 'PAYLOAD'
                      Severity: Major
                      Found in lib/msf/ui/console/module_option_tab_completion.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

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

                                  def option_values_target_addrs(mod)
                                    res = [ ]
                                    res << Rex::Socket.source_address
                                    return res if !framework.db.active
                          
                          
                          Severity: Minor
                          Found in lib/msf/ui/console/module_option_tab_completion.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