rapid7/metasploit-framework

View on GitHub
lib/msf/core/analyze/result.rb

Summary

Maintainability
D
1 day
Test Coverage

Method determine_prerequisites has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def determine_prerequisites
    mod_detail = @framework.modules.create(@mod.fullname)
    if mod_detail.nil?
      @required << :module_not_loadable
      return
Severity: Minor
Found in lib/msf/core/analyze/result.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 matches_host_os? has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def matches_host_os?
    hos = @host.os_name&.downcase
    return true if hos.nil? || hos.empty?

    set = @mod.platform.split(',').map{ |x| x.downcase }
Severity: Minor
Found in lib/msf/core/analyze/result.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 determine_prerequisites has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def determine_prerequisites
    mod_detail = @framework.modules.create(@mod.fullname)
    if mod_detail.nil?
      @required << :module_not_loadable
      return
Severity: Minor
Found in lib/msf/core/analyze/result.rb - About 1 hr to fix

    Method state has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def state
        if ready_for_test? || (@missing.empty? && @invalid.empty?)
          :READY_FOR_TEST
          # TODO: result eval can look for previous attempts to determine :REUSE_PREVIOUS_OPTIONS state
        else
    Severity: Minor
    Found in lib/msf/core/analyze/result.rb - About 55 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 determine_likely_compatibility has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def determine_likely_compatibility
        if matches_host_os?
          @datastore['rhost'] = @host.address
        else
          @missing << :os_match
    Severity: Minor
    Found in lib/msf/core/analyze/result.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 true if set.include?("java")
    Severity: Major
    Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return true if set.include?("php")
      Severity: Major
      Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return true if hos.include?(mos)
        Severity: Major
        Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return false if set.include?("irix") && mod.refname.include?("irix") && !hos.include?("irix")
          Severity: Major
          Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return true if set.include?("python")
            Severity: Major
            Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return true if !hos.include?('windows')
              Severity: Major
              Found in lib/msf/core/analyze/result.rb - About 30 mins to fix

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

                  def description
                    if ready_for_test?
                      "ready for testing"
                    elsif @missing.empty? && @invalid.empty?
                      # TODO? confirm vuln match in this class
                Severity: Minor
                Found in lib/msf/core/analyze/result.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