rapid7/metasploit-framework

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

Summary

Maintainability
F
2 wks
Test Coverage

File modules.rb has 1365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
  module Ui
    module Console
      module CommandDispatcher

Severity: Major
Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 3 days to fix

    Class Modules has 74 methods (exceeds 20 allowed). Consider refactoring.
    Open

            class Modules
    
              include Msf::Ui::Console::CommandDispatcher
              include Msf::Ui::Console::CommandDispatcher::Common
    
    
    Severity: Major
    Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 day to fix

      Method cmd_search has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
      Open

                def cmd_search(*args)
                  match        = ''
                  row_filter  = nil
                  output_file  = nil
                  cached       = false
      Severity: Minor
      Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 day 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_search has 160 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                def cmd_search(*args)
                  match        = ''
                  row_filter  = nil
                  output_file  = nil
                  cached       = false
      Severity: Major
      Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 6 hrs to fix

        Method cmd_show has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

                  def cmd_show(*args)
                    if args.empty?
                      print_error("Argument required\n")
                      cmd_show_help
                      return
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_use has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

                  def cmd_use(*args)
                    if args.length == 0 || args.first == '-h'
                      cmd_use_help
                      return false
                    end
        Severity: Minor
        Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_use has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                  def cmd_use(*args)
                    if args.length == 0 || args.first == '-h'
                      cmd_use_help
                      return false
                    end
        Severity: Major
        Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 3 hrs to fix

          Method cmd_favorite has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                    def cmd_favorite(*args)
                      valid_custom_args = ['-c', '-d', '-l']
                      favs_file = Msf::Config.fav_modules_file
          
                      # always display the help banner if -h is provided or if multiple options are provided
          Severity: Minor
          Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_show has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                    def cmd_show(*args)
                      if args.empty?
                        print_error("Argument required\n")
                        cmd_show_help
                        return
          Severity: Major
          Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 3 hrs to fix

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

                      def cmd_info(*args)
                        dump_json = false
                        show_doc = false
            
                        if args.include?('-j')
            Severity: Minor
            Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_search_help has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def cmd_search_help
                        print_line "Usage: search [<options>] [<keywords>:<value>]"
                        print_line
                        print_line "Prepending a value with '-' will exclude any matching results."
                        print_line "If no options or keywords are provided, cached results are displayed."
            Severity: Major
            Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 2 hrs to fix

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

                        def cmd_loadpath_tabs(str, words)
                          return [] if words.length > 1
              
                          # This custom completion might better than Readline's... We'll leave it for now.
                          #tab_complete_filenames(str,words)
              Severity: Minor
              Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_favorite has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                        def cmd_favorite(*args)
                          valid_custom_args = ['-c', '-d', '-l']
                          favs_file = Msf::Config.fav_modules_file
              
                          # always display the help banner if -h is provided or if multiple options are provided
              Severity: Major
              Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 2 hrs to fix

                Method generate_module_table has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          def generate_module_table(type, search_terms = [], row_filter = nil) # :nodoc:
                            table_hierarchy_formatters = framework.features.enabled?(Msf::FeatureManager::HIERARCHICAL_SEARCH_TABLE) ? [Msf::Ui::Console::TablePrint::BlankFormatter.new] : []
                
                              Table.new(
                                Table::Style::Default,
                Severity: Minor
                Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

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

                            def favorite_del(modules, delete_all, favs_file)
                              # obtain useful info about the fav_modules file
                              exists, writable, readable, contents = favorite_check_fav_modules(favs_file)
                  
                              if delete_all
                  Severity: Minor
                  Found in lib/msf/ui/console/command_dispatcher/modules.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 favorite_del has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                            def favorite_del(modules, delete_all, favs_file)
                              # obtain useful info about the fav_modules file
                              exists, writable, readable, contents = favorite_check_fav_modules(favs_file)
                  
                              if delete_all
                  Severity: Minor
                  Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                    Method cmd_info has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                              def cmd_info(*args)
                                dump_json = false
                                show_doc = false
                    
                                if args.include?('-j')
                    Severity: Minor
                    Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                      Method favorite_add has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                                def favorite_add(modules, favs_file)
                                  fav_limit = 50
                                  # obtain useful info about the fav_modules file
                                  exists, writable, readable, contents = favorite_check_fav_modules(favs_file)
                      
                      
                      Severity: Minor
                      Found in lib/msf/ui/console/command_dispatcher/modules.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 show_favorites has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                                def show_favorites # :nodoc:
                                  favs_file = Msf::Config.fav_modules_file
                      
                                  unless File.exist?(favs_file)
                                    print_error("The favorite modules file does not exist")
                      Severity: Minor
                      Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                        Method favorite_add has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                  def favorite_add(modules, favs_file)
                                    fav_limit = 50
                                    # obtain useful info about the fav_modules file
                                    exists, writable, readable, contents = favorite_check_fav_modules(favs_file)
                        
                        
                        Severity: Minor
                        Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                          Method show_module_metadata has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                                    def show_module_metadata(table_name, module_filter)
                                      count = -1
                                      tbl = generate_module_table(table_name)
                          
                                      if module_filter.is_a?(Array) || module_filter.is_a?(Hash)
                          Severity: Minor
                          Found in lib/msf/ui/console/command_dispatcher/modules.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 dangerzone_build_map has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                    def dangerzone_build_map
                                      return unless @dangerzone_map.nil?
                          
                                      @dangerzone_map = {}
                          
                          
                          Severity: Minor
                          Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                            Method show_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def show_missing(mod) # :nodoc:
                                        mod_opt = Serializer::ReadableText.dump_options(mod, '   ', true)
                                        print("\nModule options (#{mod.fullname}):\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0)
                            
                                        # If it's an exploit and a payload is defined, create it and
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_popm has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def cmd_popm(*args)
                                        if (args.count > 1 or not args[0].respond_to?("to_i"))
                                          return self.cmd_popm_help
                                        elsif args.count == 1
                                          # then pop 'n' items off the stack, but don't change the active module
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 show_evasion_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def show_evasion_options(mod) # :nodoc:
                                        mod_opt = Serializer::ReadableText.dump_evasion_options(mod, '   ')
                                        print("\nModule evasion options:\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0)
                            
                                        # If it's an exploit and a payload is defined, create it and
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 add_record has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def add_record(mod, count, compatible_mod)
                                        if compatible_mod
                                          check = mod.has_check? ? 'Yes' : 'No'
                                        else
                                          check = mod.check ? 'Yes' : 'No'
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_loadpath has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def cmd_loadpath(*args)
                                        if (args.length == 0 or args.include? "-h")
                                          cmd_loadpath_help
                                          return true
                                        end
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 show_advanced_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                      def show_advanced_options(mod) # :nodoc:
                                        mod_opt = Serializer::ReadableText.dump_advanced_options(mod, '   ')
                                        print("\nModule advanced options (#{mod.fullname}):\n\n#{mod_opt}\n") if (mod_opt and mod_opt.length > 0)
                            
                                        # If it's an exploit and a payload is defined, create it and
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.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 cmd_loadpath_tabs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                      def cmd_loadpath_tabs(str, words)
                                        return [] if words.length > 1
                            
                                        # This custom completion might better than Readline's... We'll leave it for now.
                                        #tab_complete_filenames(str,words)
                            Severity: Minor
                            Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

                              Method cmd_loadpath has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                        def cmd_loadpath(*args)
                                          if (args.length == 0 or args.include? "-h")
                                            cmd_loadpath_help
                                            return true
                                          end
                              Severity: Minor
                              Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 1 hr to fix

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

                                          def show_favorites # :nodoc:
                                            favs_file = Msf::Config.fav_modules_file
                                
                                            unless File.exist?(favs_file)
                                              print_error("The favorite modules file does not exist")
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/modules.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

                                Method cmd_advanced has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                          def cmd_advanced(*args)
                                            if args.empty?
                                              if (active_module)
                                                show_advanced_options(active_module)
                                                return true
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 35 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

                                Method cmd_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                          def cmd_options(*args)
                                            if args.empty?
                                              if (active_module)
                                                show_options(active_module)
                                                return true
                                Severity: Minor
                                Found in lib/msf/ui/console/command_dispatcher/modules.rb - About 35 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/modules.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

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

                                    Avoid too many return statements within this method.
                                    Open

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

                                      Avoid too many return statements within this method.
                                      Open

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

                                        Avoid too many return statements within this method.
                                        Open

                                                    return false if (mod == nil)
                                        Severity: Major
                                        Found in lib/msf/ui/console/command_dispatcher/modules.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/modules.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/modules.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/modules.rb - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return false
                                                Severity: Major
                                                Found in lib/msf/ui/console/command_dispatcher/modules.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/modules.rb - About 30 mins to fix

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

                                                              def show_targets(mod) # :nodoc:
                                                                case mod
                                                                when Msf::Exploit
                                                                  mod_targs = Serializer::ReadableText.dump_exploit_targets(mod, '', "\nExploit targets:")
                                                                  print("#{mod_targs}\n") if (mod_targs and mod_targs.length > 0)
                                                    Severity: Minor
                                                    Found in lib/msf/ui/console/command_dispatcher/modules.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

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                if (mod.exploit? and mod.datastore['PAYLOAD'])
                                                                  p = framework.payloads.create(mod.datastore['PAYLOAD'])
                                                    
                                                                  if (!p)
                                                                    print_error("Invalid payload defined: #{mod.datastore['PAYLOAD']}\n")
                                                    Severity: Major
                                                    Found in lib/msf/ui/console/command_dispatcher/modules.rb and 1 other location - About 1 hr to fix
                                                    lib/msf/ui/console/command_dispatcher/modules.rb on lines 1677..1691

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 61.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                if (mod.evasion? and mod.datastore['PAYLOAD'])
                                                                  p = framework.payloads.create(mod.datastore['PAYLOAD'])
                                                    
                                                                  if (!p)
                                                                    print_error("Invalid payload defined: #{mod.datastore['PAYLOAD']}\n")
                                                    Severity: Major
                                                    Found in lib/msf/ui/console/command_dispatcher/modules.rb and 1 other location - About 1 hr to fix
                                                    lib/msf/ui/console/command_dispatcher/modules.rb on lines 1653..1667

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 61.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                {
                                                                  "back"       => "Move back from the current context",
                                                                  "advanced"   => "Displays advanced options for one or more modules",
                                                                  "info"       => "Displays information about one or more modules",
                                                                  "options"    => "Displays global options or for one or more modules",
                                                    Severity: Minor
                                                    Found in lib/msf/ui/console/command_dispatcher/modules.rb and 1 other location - About 30 mins to fix
                                                    lib/rex/post/hwbridge/ui/console/command_dispatcher/core.rb on lines 47..63

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 33.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status