hackedteam/rcs-common

View on GitHub

Showing 60 of 90 total issues

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

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

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

    Avoid too many return statements within this method.
    Open

            return false
    Severity: Major
    Found in lib/rcs-common/updater/server.rb - About 30 mins to fix

      Method private_ipv4? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def private_ipv4?
              a,b,c,d = remote_addr.split(".").map(&:to_i)
              return true if a==127 && b==0 && c==0 && d==1 # localhost
              return true if a==192 && b==168 && c.between?(0,255) && d.between?(0,255) # 192.168.0.0/16
              return true if a==172 && b.between?(16,31) && c.between?(0,255) && d.between?(0,255) # 172.16.0.0/12
      Severity: Minor
      Found in lib/rcs-common/updater/server.rb - About 25 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 mirror has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def mirror(local_folder, remote_folder, opts = {})
              opts[:trap] = true
              result = mirror!(local_folder, remote_folder, opts)
              changes = result.split("\n")[1..-3].reject { |x| x.empty? }
              changed = changes.size > 0 && changes != ["./"]
      Severity: Minor
      Found in lib/rcs-common/deploy.rb - About 25 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_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def decode_query(url)
          query = []
          query = url.scan(/(?:&?|^)q=([^&]*)(?:&|$)/).first if url['google']
          query = url.scan(/(?:&?|^)p=([^&]*)(?:&|$)/).first if url['yahoo']
          query = url.scan(/(?:&?|^)q=([^&]*)(?:&|$)/).first if url['bing']
      Severity: Minor
      Found in lib/rcs-common/evidence/url.rb - About 25 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 filesystem_stat_path has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.filesystem_stat_path
            return @@filesystem_stat_path if @@filesystem_stat_path
      
            pwd = Dir.pwd
      
      
      Severity: Minor
      Found in lib/rcs-common/systemstatus.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def decode_additional_header(data)
          raise EvidenceDeserializeError.new("incomplete CHAT MultiMedia") if data.nil? or data.bytesize == 0
      
          stream = StringIO.new data
          info = decode_from_to({}, stream)
      Severity: Minor
      Found in lib/rcs-common/evidence/chat.rb - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def initialize(name = DEFAULT_NAME, options = {})
                @name                 = name.to_s.downcase.strip
                @name                 = DEFAULT_NAME if @name.empty?
                @mongoid_session_name = options[:mongoid_session_name] || :default
                @setup_on_write       = options[:lazy].nil? ? true : options[:lazy]
      Severity: Minor
      Found in lib/rcs-common/gridfs.rb - About 25 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 read_utf16le_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def read_utf16le_string
          # at least the null terminator
          return '' if self.size < 2
      
          # empty string by default
      Severity: Minor
      Found in lib/rcs-common/utf16le.rb - About 25 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_from_to has a Cognitive Complexity of 6 (exceeds 5 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 25 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