hackedteam/rcs-collector

View on GitHub

Showing 209 of 209 total issues

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

  def execute_select(query, result)
    statement = @db.createStatement()
    res = statement.executeQuery(query)
    meta = res.getMetaData()

Severity: Minor
Found in lib/rcs-collector/sqlite.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 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 load_from_file has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def load_from_file
        trace :info, "Loading configuration file..."
        conf_file = File.join Dir.pwd, CONF_DIR, CONF_FILE
    
        # load the config in the @global hash
    Severity: Minor
    Found in lib/rcs-collector/config.rb - About 1 hr to fix

      Method status_update has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def status_update(component, remoteip, status, message, disk, cpu, pcpu, type, version)
      Severity: Major
      Found in lib/rcs-collector/db_rest.rb - About 1 hr to fix

        Method execute_select has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def execute_select(query, result)
            statement = @db.createStatement()
            res = statement.executeQuery(query)
            meta = res.getMetaData()
        
        
        Severity: Minor
        Found in lib/rcs-collector/sqlite.rb - About 1 hr to fix

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

            def self.new_downloads(bid)
              return {} unless File.exist?(CACHE_FILE)
          
              begin
                db = SQLite.open CACHE_FILE
          Severity: Major
          Found in lib/rcs-collector/db_cache.rb and 1 other location - About 1 hr to fix
          lib/rcs-collector/db_cache.rb on lines 652..668

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

          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 self.new_exec(bid)
              return {} unless File.exist?(CACHE_FILE)
          
              begin
                db = SQLite.open CACHE_FILE
          Severity: Major
          Found in lib/rcs-collector/db_cache.rb and 1 other location - About 1 hr to fix
          lib/rcs-collector/db_cache.rb on lines 522..538

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

          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 agent_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def agent_status(build_id, instance_id, platform, demo, level)
              # if the database has gone, reply with a fake response in order for the sync to continue
              return agent_cached_status(build_id) unless @available
          
              trace :debug, "Asking the status of [#{build_id}_#{instance_id}] to the db"
          Severity: Minor
          Found in lib/rcs-collector/db.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

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

            def self.run!(*argv)
              # reopen the class and declare any empty trace method
              # if called from command line, we don't have the trace facility
              self.class_eval do
                def trace(level, message)
          Severity: Major
          Found in lib/rcs-carrier/statistics.rb and 1 other location - About 1 hr to fix
          lib/rcs-collector/statistics.rb on lines 158..186

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

          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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def run(options)
                  run_with_rescue do
                    # ensure the public and log directory are present
                    Dir::mkdir(Dir.pwd + PUBLIC_DIR) if not File.directory?(Dir.pwd + PUBLIC_DIR)
          
          
          Severity: Minor
          Found in lib/rcs-collector/collector.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

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

            def self.run!(*argv)
              # reopen the class and declare any empty trace method
              # if called from command line, we don't have the trace facility
              self.class_eval do
                def trace(level, message)
          Severity: Major
          Found in lib/rcs-collector/statistics.rb and 1 other location - About 1 hr to fix
          lib/rcs-carrier/statistics.rb on lines 157..185

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

          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 command_id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def command_id(peer, session, message)
          
              # agent version
              version = message.slice!(0..3).unpack('I').first
          
          
          Severity: Minor
          Found in lib/rcs-collector/sync_commands.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 prepare_response has 26 lines of code (exceeds 25 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 1 hr to fix

            Method create! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.create!
                begin
                  db = SQLite.open CACHE_FILE
                rescue Exception => e
                  trace :error, "Problems creating the cache file: #{e.message}"
            Severity: Minor
            Found in lib/rcs-collector/db_cache.rb - About 1 hr to fix

              Method http_get_file has 26 lines of code (exceeds 25 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 1 hr to fix

                Method create has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def create(bid, ident, instance, platform, demo, level, k, ip)
                Severity: Major
                Found in lib/rcs-collector/sessions.rb - About 1 hr to fix

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

                    def self.save_downloads(bid, downloads)
                      # ensure the db was already created, otherwise create it
                      create! unless File.exist?(CACHE_FILE)
                  
                      begin
                  Severity: Minor
                  Found in lib/rcs-collector/db_cache.rb and 1 other location - About 1 hr to fix
                  lib/rcs-collector/db_cache.rb on lines 671..684

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

                  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

                      metaclass.send(:define_method, :generate_header_lines, proc { |in_hash|
                        out_ary = []
                                 in_hash.keys.each {|k|
                                     v = in_hash[k]
                                     if v.is_a?(Array)
                  Severity: Minor
                  Found in lib/rcs-collector/rest_response.rb and 1 other location - About 1 hr to fix
                  lib/rcs-collector/rest_response.rb on lines 86..96

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

                  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 self.save_exec(bid, commands)
                      # ensure the db was already created, otherwise create it
                      create! unless File.exist?(CACHE_FILE)
                  
                      begin
                  Severity: Minor
                  Found in lib/rcs-collector/db_cache.rb and 1 other location - About 1 hr to fix
                  lib/rcs-collector/db_cache.rb on lines 541..554

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

                  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

                      metaclass.send(:define_method, :generate_header_lines, proc { |in_hash|
                        out_ary = []
                                 in_hash.keys.each {|k|
                                     v = in_hash[k]
                                     if v.is_a?(Array)
                  Severity: Minor
                  Found in lib/rcs-collector/rest_response.rb and 1 other location - About 1 hr to fix
                  lib/rcs-collector/rest_response.rb on lines 161..171

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language