rapid7/metasploit-framework

View on GitHub
lib/msf/core/modules/loader/base.rb

Summary

Maintainability
D
2 days
Test Coverage

Method load_module has 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def load_module(parent_path, type, module_reference_name, options = {})
    options.assert_valid_keys(:count_by_type, :force, :recalculate_by_type, :reload, :cached_metadata)
    force = options[:force] || false
    reload = options[:reload] || false

Severity: Major
Found in lib/msf/core/modules/loader/base.rb - About 3 hrs to fix

    File base.rb has 321 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'msf/core/constants'
    # Responsible for loading modules for {Msf::ModuleManager}.
    #
    # @abstract Subclass and override {#each_module_reference_name}, {#loadable?}, {#module_path}, and
    #   {#read_module_content}.
    Severity: Minor
    Found in lib/msf/core/modules/loader/base.rb - About 3 hrs to fix

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

        def load_module(parent_path, type, module_reference_name, options = {})
          options.assert_valid_keys(:count_by_type, :force, :recalculate_by_type, :reload, :cached_metadata)
          force = options[:force] || false
          reload = options[:reload] || false
      
      
      Severity: Minor
      Found in lib/msf/core/modules/loader/base.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

      Class Base has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Msf::Modules::Loader::Base
        #
        # CONSTANTS
        #
      
      
      Severity: Minor
      Found in lib/msf/core/modules/loader/base.rb - About 2 hrs to fix

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

          def reload_module(original_metasploit_class_or_instance)
            if original_metasploit_class_or_instance.is_a? Msf::Module
              original_metasploit_instance = original_metasploit_class_or_instance
              original_metasploit_class = original_metasploit_class_or_instance.class
            else
        Severity: Minor
        Found in lib/msf/core/modules/loader/base.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 reload_module has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def reload_module(original_metasploit_class_or_instance)
            if original_metasploit_class_or_instance.is_a? Msf::Module
              original_metasploit_instance = original_metasploit_class_or_instance
              original_metasploit_class = original_metasploit_class_or_instance.class
            else
        Severity: Minor
        Found in lib/msf/core/modules/loader/base.rb - About 1 hr to fix

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

            def restore_namespace_module(parent_module, relative_name, namespace_module)
              if parent_module
                # If there is a current module with relative_name
                if parent_module.const_defined?(relative_name)
                  # if the current value isn't the value to be restored.
          Severity: Minor
          Found in lib/msf/core/modules/loader/base.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 namespace_module_transaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def namespace_module_transaction(module_full_name, options={}, &block)
              options.assert_valid_keys(:reload)
          
              reload = options[:reload] || false
              namespace_module_names = self.namespace_module_names(module_full_name)
          Severity: Minor
          Found in lib/msf/core/modules/loader/base.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 false
          Severity: Major
          Found in lib/msf/core/modules/loader/base.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return false
            Severity: Major
            Found in lib/msf/core/modules/loader/base.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return true
              Severity: Major
              Found in lib/msf/core/modules/loader/base.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return false unless loaded
                Severity: Major
                Found in lib/msf/core/modules/loader/base.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status