rapid7/metasploit-credential

View on GitHub

Showing 25 of 29 total issues

Method convert_creds_in_workspace has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def convert_creds_in_workspace(workspace)
    workspace.creds.each do |cred|
      service = cred.service
      begin
        core = create_credential(
Severity: Minor
Found in lib/metasploit/credential/migrator.rb - About 1 hr to fix

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

      def create_credential_core(opts={})
        return nil unless active_db?
    
        if self.respond_to?(:[]) and self[:task]
          opts[:task_id] ||= self[:task].record.id
    Severity: Minor
    Found in lib/metasploit/credential/creation.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 invalidate_login has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def invalidate_login(opts = {})
        return nil unless active_db?
        address     = opts.fetch(:address)
        return nil unless Rex::Socket.is_ipv4?(address) || Rex::Socket.is_ipv6?(address)
        port        = opts.fetch(:port)
    Severity: Minor
    Found in lib/metasploit/credential/creation.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 maximal_clusters has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.maximal_clusters
        clusters = cluster_by_class.values
        unique_clusters = clusters.uniq
    
        maximal_clusters = unique_clusters.dup
    Severity: Minor
    Found in lib/metasploit/credential/entity_relationship_diagram.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 public_for_ssh_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def public_for_ssh_key
          if private.present? && private.type == Metasploit::Credential::SSHKey.name
            errors.add(:base, :public_for_ssh_key) unless public.present?
          end
        end
    Severity: Minor
    Found in lib/metasploit/credential/core_validations.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

    Severity
    Category
    Status
    Source
    Language