hackedteam/rcs-db

View on GitHub

Showing 612 of 612 total issues

Method parse_agents has a Cognitive Complexity of 173 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_agents(items)
      modules = []

      return modules if items.nil?

Severity: Minor
Found in scripts/xml_to_json.rb - About 3 days 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

File rest_test.rb has 957 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'openssl'
require 'net/http'
require 'json'
require 'benchmark'
require 'open-uri'
Severity: Major
Found in scripts/rest_test.rb - About 2 days to fix

    Method parse_events has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_events(items)
          events = []
    
          return events if items.nil?
    
    
    Severity: Minor
    Found in scripts/xml_to_json.rb - About 1 day 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

    File agent.rb has 589 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative '../license'
    require_relative '../alert'
    
    require 'rcs-common/crypt'
    
    
    Severity: Major
    Found in lib/rcs-db/rest/agent.rb - About 1 day to fix

      File collector.rb has 587 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'mongoid'
      
      class Collector
        include Mongoid::Document
        include Mongoid::Timestamps
      Severity: Major
      Found in lib/rcs-db/db_objects/collector.rb - About 1 day to fix

        File item.rb has 586 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'mongoid'
        
        require_relative '../build'
        require_relative '../push'
        
        
        Severity: Major
        Found in lib/rcs-db/db_objects/item.rb - About 1 day to fix

          Method new_link has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
          Open

              def new_link(entities)
                ::Alert.where(:enabled => true, :action => 'LINK').each do |alert|
                  # skip non matching entities
                  next unless match_path(alert, entities.first)
                  next unless match_path(alert, entities.last)
          Severity: Minor
          Found in lib/rcs-db/alert.rb - About 1 day 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

          File entity.rb has 547 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'mongoid'
          require 'lrucache'
          
          require_relative '../link_manager'
          require_relative '../position/proximity'
          Severity: Major
          Found in lib/rcs-db/db_objects/entity.rb - About 1 day to fix

            Method parse_actions has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_actions(items)
                  actions = []
            
                  return actions if items.nil?
            
            
            Severity: Minor
            Found in scripts/xml_to_json.rb - About 1 day 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

            File config.rb has 527 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'rcs-common/trace'
            
            require_relative 'indexer'
            require_relative 'migration'
            
            
            Severity: Major
            Found in lib/rcs-db/config.rb - About 1 day to fix

              File rcs-kill.rb has 517 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'singleton'
              require 'pp'
              require 'optparse'
              require 'openssl'
              
              
              Severity: Major
              Found in scripts/rcs-kill.rb - About 1 day to fix

                Method positions_flow has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.positions_flow(ids, from, to, options = {})
                    ext = 70*60
                
                    t = Time.at(from.to_i)
                    from = Time.new(t.year, t.month, t.day, t.hour, t.min, 0).to_i
                Severity: Minor
                Found in lib/rcs-db/db_objects/entity.rb - About 7 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 a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
                Open

                  def run(options)
                
                    if options[:reset]
                      reset_pass options
                      return 0
                Severity: Minor
                Found in lib/rcs-db/config.rb - About 7 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 process has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                Open

                      def process(grid_ev)
                        start_time = Time.now
                        raw_id = grid_ev['_id']
                
                        raise MissingAgentError.new("Unable to process evidence #{raw_id}, agent #{@agent_uid} is missing") unless agent?
                Severity: Minor
                Found in lib/rcs-worker/instance_worker.rb - About 6 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

                File license.rb has 428 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require_relative 'dongle.rb'
                require_relative 'shard.rb'
                
                # from RCS::Common
                require 'rcs-common/trace'
                Severity: Minor
                Found in lib/rcs-db/license.rb - About 6 hrs to fix

                  Method import_blk_file has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def import_blk_file(blk_file)
                          return if blk_file.imported?
                  
                          msg = "[#{@currency}] Start importing #{blk_file.path} from offeset #{blk_file.imported_bytes} (filesize is #{blk_file.filesize})"
                          @cli ? puts("#{msg}") : trace(:info, msg)
                  Severity: Minor
                  Found in lib/rcs-money/importer.rb - About 6 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 148 lines of code (exceeds 25 allowed). 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-db/config.rb - About 5 hrs to fix

                    Method stream_one_chunk has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def stream_one_chunk
                            loop do
                              if @connection.closed?
                                @file_io.close unless @file_io.closed?
                                break
                    Severity: Minor
                    Found in lib/rcs-db/em_streamer.rb - About 5 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 new_evidence has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def new_evidence(evidence)
                          ::Alert.where(:enabled => true, :action => 'EVIDENCE').each do |alert|
                            agent = ::Item.where({_id: evidence.aid, _kind: 'agent'}).first
                    
                            # not found
                    Severity: Minor
                    Found in lib/rcs-db/alert.rb - About 5 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

                    File xml_to_json.rb has 393 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'json'
                    require 'optparse'
                    require 'pp'
                    require 'xmlsimple'
                    
                    
                    Severity: Minor
                    Found in scripts/xml_to_json.rb - About 5 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language