hackedteam/rcs-common

View on GitHub

Showing 90 of 90 total issues

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

      def run
        @return_code = nil
        @output = ""

        cmd = "#{'ruby ' if ruby?}#{storable? ? filepath : payload}"
Severity: Minor
Found in lib/rcs-common/updater/payload.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 decode_additional_header has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def decode_additional_header(data)
    raise EvidenceDeserializeError.new("incomplete MAIL") if data.nil? or data.bytesize == 0

    ret = Hash.new
    ret[:data] = Hash.new
Severity: Minor
Found in lib/rcs-common/evidence/mail.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 process_http_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def process_http_request
        EM.defer do
          begin
            trace(:info, "[#{@http[:host]}] REQ #{@http_protocol} #{@http_request_method} #{@http_content.size} bytes from #{remote_addr}")

Severity: Minor
Found in lib/rcs-common/updater/server.rb - About 1 hr to fix

    Method append has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def append(file_id, data, options = {})
              attributes = if options[:filename]
                files_collection.find(filename: file_id).first
              else
                file_id = objectid(file_id)
    Severity: Minor
    Found in lib/rcs-common/gridfs.rb - About 1 hr to fix

      Method decode_content has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def decode_content(common_info, chunks)
          stream = StringIO.new chunks.join
      
          until stream.eof?
            tm = stream.read 36
      Severity: Minor
      Found in lib/rcs-common/evidence/chat.rb - About 1 hr to fix

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

              def request(payload, options = {}, retry_count = self.max_retries)
                msg = options[:store] ? [] : [payload]
                msg = ["#{payload.size} B", options.inspect]
                trace(:debug, "REQ #{msg.join(' | ')}")
        
        
        Severity: Minor
        Found in lib/rcs-common/updater/client.rb - About 1 hr to fix

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

            def decode_from_to(common_info, stream)
              tm = stream.read 36
              info = Hash[common_info]
              info[:da] = Time.gm(*(tm.unpack('L*')), 0)
              info[:data] = Hash.new if info[:data].nil?
          Severity: Minor
          Found in lib/rcs-common/evidence/chat.rb - About 1 hr to fix

            Method chunkerize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                    def chunkerize(data)
                      offset = 0
                      chunk_num = 0
            
                      loop do
            Severity: Minor
            Found in lib/rcs-common/gridfs.rb - About 55 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 decode_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def decode_content(common_info, chunks)
                stream = StringIO.new chunks.join
            
                entries = []
            
            
            Severity: Minor
            Found in lib/rcs-common/evidence/filesystem.rb - About 55 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 decode_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def decode_content(common_info, chunks)
                stream = StringIO.new chunks.join
            
                until stream.eof?
            
            
            Severity: Minor
            Found in lib/rcs-common/evidence/chat.rb - About 55 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

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

                  unless @calendar.fields[:body].nil?
                    body = @calendar.fields[:body]
                    unless body.empty?
                      info[:data][:body] = body
                      info[:data][:info] += " - " unless info[:data][:info].empty?
            Severity: Minor
            Found in lib/rcs-common/evidence/calendar.rb and 1 other location - About 55 mins to fix
            lib/rcs-common/evidence/calendar.rb on lines 39..45

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

            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

                  unless @calendar.fields[:location].nil?
                    location = @calendar.fields[:location]
                    unless location.empty?
                      info[:data][:location] = location
                      info[:data][:info] += " - " unless info[:data][:info].empty?
            Severity: Minor
            Found in lib/rcs-common/evidence/calendar.rb and 1 other location - About 55 mins to fix
            lib/rcs-common/evidence/calendar.rb on lines 48..54

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

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

                  def task(name, &block)
                    if name.kind_of?(Hash)
                      name.each do |alias_name, task_name|
                        raise("Undefined task `#{task_name}'") unless @@tasks[task_name.to_s]
                        @@tasks[alias_name.to_s] = @@tasks[task_name.to_s]
            Severity: Minor
            Found in lib/rcs-common/updater/dsl.rb - About 45 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 service_failure has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def service_failure(service_name, reset = 0, action1 = "restart/60000", action2 = "restart/60000", action3 = "restart/60000")
            Severity: Minor
            Found in lib/rcs-common/updater/client.rb - About 35 mins to fix

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

                  def decode_content(common_info, chunks)
                    stream = StringIO.new chunks.join
              
                    until stream.eof?
                      info = Hash[common_info]
              Severity: Minor
              Found in lib/rcs-common/evidence/addressbook.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 require_component has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def require_component(name, opts = {})
                      $invocation_directory = Dir.pwd
                      $invocation_directory = ENV['CWD'] if ENV['CWD']
              
                      init_script = caller[0].scan(/^(.+)\:\d+\:.+$/)[0][0]
              Severity: Minor
              Found in lib/rcs-common/path_utils.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 rm_rf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def rm_rf(path, allow: [], check: true)
                      if localhost?
                        FileUtils.rm_rf(unixpath(path))
                      else
                        request("ruby -e 'require \"fileutils\"; FileUtils.rm_rf(\"#{unixpath(path)}\");'", exec: 1)
              Severity: Minor
              Found in lib/rcs-common/updater/client.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 decode_additional_header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def decode_additional_header(data)
                  raise EvidenceDeserializeError.new("incomplete PHOTO") if data.nil? or data.bytesize == 0
              
                  binary = StringIO.new data
              
              
              Severity: Minor
              Found in lib/rcs-common/evidence/photo.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 decode_content has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def decode_content(common_info, chunks)
                    stream = StringIO.new chunks.join
              
                    output = stream.read
              
              
              Severity: Minor
              Found in lib/rcs-common/evidence/command.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def self.call(command, read: false)
                        command = "netsh advfirewall #{command.strip}"
              
                        unless exists?
                          raise "The Windows Firewall is missing. You cannot call the command #{command.inspect} on this OS."
              Severity: Minor
              Found in lib/rcs-common/winfirewall.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

              Severity
              Category
              Status
              Source
              Language