hackedteam/rcs-collector

View on GitHub
lib/rcs-collector/evidence_manager.rb

Summary

Maintainability
D
2 days
Test Coverage

File evidence_manager.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'fileutils'
require_relative 'sqlite'

# from RCS::Common
require 'rcs-common/trace'
Severity: Minor
Found in lib/rcs-collector/evidence_manager.rb - About 5 hrs to fix

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

      def run(options)
    
        # delete all the instance with zero evidence pending and not in progress
        if options[:purge] then
          instances.each do |e|
    Severity: Minor
    Found in lib/rcs-collector/evidence_manager.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 run has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run(options)
    
        # delete all the instance with zero evidence pending and not in progress
        if options[:purge] then
          instances.each do |e|
    Severity: Major
    Found in lib/rcs-collector/evidence_manager.rb - About 2 hrs to fix

      Class EvidenceManager has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class EvidenceManager
        include Singleton
        include RCS::Tracer
      
        REPO_DIR = Dir.pwd + '/evidence'
      Severity: Minor
      Found in lib/rcs-collector/evidence_manager.rb - About 2 hrs to fix

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

          def create_repository(session)
            # ensure the repository directory is present
            Dir::mkdir(REPO_DIR) if not File.directory?(REPO_DIR)
        
            trace :info, "Creating repository for [#{session[:ident]}_#{session[:instance]}]"
        Severity: Minor
        Found in lib/rcs-collector/evidence_manager.rb - About 1 hr to fix

          Method store_evidence_chunk has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def store_evidence_chunk(session, id, base, chunk, size, content)
              Dir::mkdir(REPO_CHUNK_DIR) if not File.directory?(REPO_CHUNK_DIR)
              path =  REPO_CHUNK_DIR + '/' + session[:ident] + '_' + session[:instance]
          
              header_len = 12
          Severity: Minor
          Found in lib/rcs-collector/evidence_manager.rb - About 1 hr to fix

            Method store_evidence_chunk has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def store_evidence_chunk(session, id, base, chunk, size, content)
            Severity: Minor
            Found in lib/rcs-collector/evidence_manager.rb - About 45 mins to fix

              Method sync_start has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def sync_start(session, version, user, device, source, time)
              Severity: Minor
              Found in lib/rcs-collector/evidence_manager.rb - About 45 mins to fix

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

                  def purge(instance, options = {force: false, timeout: false})
                
                    # forced deletion
                    if options[:force]
                      FileUtils.rm_rf(REPO_DIR + '/' + instance)
                Severity: Minor
                Found in lib/rcs-collector/evidence_manager.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 compact has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def compact(instance)
                    # sanity check
                    path = REPO_DIR + '/' + instance
                    return unless File.exist?(path)
                
                
                Severity: Minor
                Found in lib/rcs-collector/evidence_manager.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 store_evidence_chunk has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def store_evidence_chunk(session, id, base, chunk, size, content)
                    Dir::mkdir(REPO_CHUNK_DIR) if not File.directory?(REPO_CHUNK_DIR)
                    path =  REPO_CHUNK_DIR + '/' + session[:ident] + '_' + session[:instance]
                
                    header_len = 12
                Severity: Minor
                Found in lib/rcs-collector/evidence_manager.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

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

                  def create_repository(session)
                    # ensure the repository directory is present
                    Dir::mkdir(REPO_DIR) if not File.directory?(REPO_DIR)
                
                    trace :info, "Creating repository for [#{session[:ident]}_#{session[:instance]}]"
                Severity: Minor
                Found in lib/rcs-collector/evidence_manager.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