hackedteam/rcs-db

View on GitHub

Showing 612 of 612 total issues

Method actions_with_start_stop has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def actions_with_start_stop(modules, actions, events)
      actions.each do |a|
        # skip actions created during migration
        next if a[:_mig]
        # search for start action for camera, screenshot and position
Severity: Minor
Found in scripts/xml_to_json.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 extract has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.extract(target_id, ev)

    # check if the position is good
    return [] if ev.data['latitude'].nil? or ev.data['longitude'].nil?

Severity: Minor
Found in lib/rcs-aggregator/position.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 agents_with_repetition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def agents_with_repetition(modules, actions, events)
      modules.each do |m|
        if m.has_key?('interval')
          action = {:desc => "#{m[:module]} iteration", :_mig => true, :subactions => [{:action => 'module', :status => 'start', :module => m[:module]}] }
          actions << action
Severity: Minor
Found in scripts/xml_to_json.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 print_total has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def print_total
    puts "Total Statistics from: #{@stats[:total][:start]}"

    table_width = 0
    @stats[:total].each_key do |k|
Severity: Minor
Found in lib/rcs-db/statistics.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 log has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def log(params)
      params[:time] = Time.now.getutc.to_i

      if params[:_item]
        item = params.delete(:_item)
Severity: Minor
Found in lib/rcs-db/audit.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 generate_anon_certificate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def generate_anon_certificate
    trace :info, "Generating anon ssl certificates..."

    FileUtils.cp Config.instance.cert('openssl.cnf'), path('openssl.cnf')

Severity: Minor
Found in lib/rcs-db/build/anon.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 decrypt_evidence has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def decrypt_evidence(raw_id)
        content = RCS::DB::GridFS.get(raw_id, "evidence", :worker) rescue nil
        return unless content

        decoded_data = ''
Severity: Minor
Found in lib/rcs-worker/instance_worker.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 patch has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def patch(params)
    # skip the phase if not needed
    return if params.nil? or params[:core].nil?

    trace :debug, "Build: patching [#{params[:core]}] file"
Severity: Minor
Found in lib/rcs-db/build.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 filter_for_keywords has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.filter_for_keywords(info, filter_hash)
    if filter_info_has_key_values?(info)
      each_filter_key_value(info.first) do |k, v|
        # special case for $near search
        next if %w[lat lon r].include?(k)
Severity: Minor
Found in lib/rcs-db/db_objects/evidence.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 index_diff has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def index_diff(mongoid_document_class)
    collection = mongoid_document_class.collection

    if !collection_exists?(collection)
      diff = {missing_collection: true}
Severity: Minor
Found in lib/rcs-db/db_layer.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 create_callback has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def create_callback
    return if STAT_EXCLUSION.include? self.type
    agent = Item.find self.aid
    agent.stat.inc(:"evidence.#{self.type}", 1)
    agent.stat.inc(:"dashboard.#{self.type}", 1)
Severity: Minor
Found in lib/rcs-db/db_objects/evidence.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 backup_index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.backup_index
    index = []

    glob = File.join File.expand_path(Config.instance.global['BACKUP_DIR']), '*'

Severity: Minor
Found in lib/rcs-db/backup.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 filter_for_position has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.filter_for_position(info, filter_hash)
    return unless filter_info_has_key_values?(info)

    lat, lon, r = nil

Severity: Minor
Found in lib/rcs-db/db_objects/evidence.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

      if ::Item.agents.where(type: 'mobile', status: 'open', demo: false, deleted: false).count > @limits[:agents][:mobile]
        trace :fatal, "LICENCE EXCEEDED: Number of agents(mobile) is greater than license file. Fixing..."
        # fix by queuing the last updated agent
        offending = ::Item.where(_kind: 'agent', type: 'mobile', status: 'open', demo: false).order_by([[:updated_at, :desc]]).first
        offending[:status] = 'queued'
Severity: Major
Found in lib/rcs-db/license.rb and 1 other location - About 1 hr to fix
lib/rcs-db/license.rb on lines 467..473

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

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 ::Item.agents.where(type: 'desktop', status: 'open', demo: false, deleted: false).count > @limits[:agents][:desktop]
        trace :fatal, "LICENCE EXCEEDED: Number of agents(desktop) is greater than license file. Fixing..."
        # fix by queuing the last updated agent
        offending = ::Item.where(_kind: 'agent', type: 'desktop', status: 'open', demo: false).order_by([[:updated_at, :desc]]).first
        offending[:status] = 'queued'
Severity: Major
Found in lib/rcs-db/license.rb and 1 other location - About 1 hr to fix
lib/rcs-db/license.rb on lines 476..482

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

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 create_suggested_peer has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.create_suggested_peer(target_id, params)
    time = Time.parse(params[:day])
    peer = params[:data][:peer]
    type = params[:type]
    versus = params[:data][:versus]
Severity: Minor
Found in lib/rcs-aggregator/peer.rb - About 1 hr to fix

    Method generate_certificates_anon has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def generate_certificates_anon
        trace :info, "Generating anon ssl certificates..."
    
        # ensure dir is present
        FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
    Severity: Minor
    Found in lib/rcs-db/config.rb - About 1 hr to fix

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

            def run
              options = {}
              optparse = OptionParser.new do |opts|
                opts.banner = "Usage: rcs-money [opts]"
      
      
      Severity: Minor
      Found in lib/rcs-money/cli.rb - About 1 hr to fix

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

          def run(options)
        
            return analyze(options[:analyze]) if options[:analyze]
        
            $local_address = options[:ip]
        Severity: Minor
        Found in scripts/rcs-kill.rb - About 1 hr to fix

          Method common_filter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.common_filter(params)
          
              # filtering
              filter = {}
              filter = JSON.parse(params['filter']) if params.has_key? 'filter' and params['filter'].is_a? String
          Severity: Minor
          Found in lib/rcs-db/db_objects/evidence.rb - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language