hackedteam/rcs-collector

View on GitHub

Showing 209 of 209 total issues

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

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

    if upgrade.nil?
      trace :info, "[#{peer}][#{session[:cookie]}] NO upgrade"
      response = [PROTO_NO].pack('I')
    else
      response = [PROTO_OK].pack('I')
Severity: Major
Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 2 hrs to fix
lib/rcs-collector/sync_commands.rb on lines 205..218

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 89.

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 upload.nil?
      trace :info, "[#{peer}][#{session[:cookie]}] NO uploads"
      response = [PROTO_NO].pack('I')
    else
      response = [PROTO_OK].pack('I')
Severity: Major
Found in lib/rcs-collector/sync_commands.rb and 1 other location - About 2 hrs to fix
lib/rcs-collector/sync_commands.rb on lines 237..250

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 89.

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

File sync_commands.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'db.rb'
require_relative 'sessions.rb'
require_relative 'evidence_manager.rb'

# from RCS::Common
Severity: Minor
Found in lib/rcs-collector/sync_commands.rb - About 2 hrs to fix

    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

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

        def new_upgrades(bid)
          begin
            ret = rest_call('GET', "/agent/upgrades/#{bid}")
      
            upgr = {}
      Severity: Major
      Found in lib/rcs-collector/db_rest.rb and 1 other location - About 2 hrs to fix
      lib/rcs-collector/db_rest.rb on lines 373..390

      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 85.

      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

        def new_uploads(bid)
          begin
            ret = rest_call('GET', "/agent/uploads/#{bid}")
      
            upl = {}
      Severity: Major
      Found in lib/rcs-collector/db_rest.rb and 1 other location - About 2 hrs to fix
      lib/rcs-collector/db_rest.rb on lines 402..419

      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 85.

      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

      File sync_protocol.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative 'sessions'
      require_relative 'db'
      require_relative 'sync_commands'
      
      # from RCS::Common
      Severity: Minor
      Found in lib/rcs-collector/sync_protocol.rb - About 2 hrs to fix

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

        class RESTController
          include RCS::Tracer
        
          STATUS_OK = 200
          STATUS_REDIRECT = 302
        Severity: Minor
        Found in lib/rcs-collector/rest.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 http_get_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def http_get_file(headers, uri, delete=true)
            
                # retrieve the Operating System and app specific extension of the requester
                os, ext = http_get_os(headers)
            
            
            Severity: Minor
            Found in lib/rcs-collector/http_controller.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 prepare_response has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def prepare_response(connection, request)
            
                @request = request
                @connection = connection
                @response = EM::DelegatedHttpResponse.new @connection
            Severity: Minor
            Found in lib/rcs-collector/rest_response.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 authenticate_scout has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.authenticate_scout(peer, uri, content, anon_version)
                trace :info, "[#{peer}] Authentication scout required for (#{content.length.to_s} bytes)..."
            
                begin
                  # remove the base64 container
            Severity: Minor
            Found in lib/rcs-collector/sync_protocol.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 migrate_sqlite_scout_column has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def migrate_sqlite_scout_column
                    dbs_path = File.expand_path("../../../evidence", __FILE__)
            
                    return unless Dir.exists?(dbs_path)
            
            
            Severity: Minor
            Found in lib/rcs-collector/migration.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

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

              def print_average(section)
                puts "Average by #{section.to_s} statistics:"
            
                table_width = 0
                @stats[:total].each_key do |k|
            Severity: Major
            Found in lib/rcs-carrier/statistics.rb and 1 other location - About 2 hrs to fix
            lib/rcs-collector/statistics.rb on lines 108..129

            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 78.

            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

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

              def print_average(section)
                puts "Average by #{section.to_s} statistics:"
            
                table_width = 0
                @stats[:total].each_key do |k|
            Severity: Major
            Found in lib/rcs-collector/statistics.rb and 1 other location - About 2 hrs to fix
            lib/rcs-carrier/statistics.rb on lines 107..128

            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 78.

            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

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

              def print_section(section)
                puts "Last 5 #{section.to_s} statistics:"
            
                table_width = 0
                @stats[:total].each_key do |k|
            Severity: Major
            Found in lib/rcs-carrier/statistics.rb and 1 other location - About 2 hrs to fix
            lib/rcs-collector/statistics.rb on lines 83..105

            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 77.

            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

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

              def print_section(section)
                puts "Last 5 #{section.to_s} statistics:"
            
                table_width = 0
                @stats[:total].each_key do |k|
            Severity: Major
            Found in lib/rcs-collector/statistics.rb and 1 other location - About 2 hrs to fix
            lib/rcs-carrier/statistics.rb on lines 82..104

            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 77.

            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

            Method run has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run(options)
                if options[:alt_log]
                  logfilepath = File.expand_path("../../../log/rcs-collector-config.log", __FILE__)
            
                  @logger = Log4r::Logger.new("migration").tap do |logger|
            Severity: Minor
            Found in lib/rcs-collector/config.rb - About 1 hr to fix

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

                def act!
                  @request[:action] = @request[:method].to_s.downcase.to_sym
              
                  # check we have a valid action
                  return bad_request unless public_methods(false).include?(@request[:action])
              Severity: Minor
              Found in lib/rcs-collector/rest.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

              Severity
              Category
              Status
              Source
              Language