hackedteam/rcs-common

View on GitHub

Showing 90 of 90 total issues

Method unserialize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def unserialize(stream)

      header_begin = stream.pos

      # discard header
Severity: Minor
Found in lib/rcs-common/serializer.rb - About 1 hr to fix

    Method stringify_attributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

            def stringify_attributes(only = [])
              attrs = {
                name:       name,
                dir:        direction,
                action:     action,
    Severity: Minor
    Found in lib/rcs-common/winfirewall.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 unserialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def unserialize(stream)
          header_begin = stream.pos
    
          tot_size = stream.read(4).unpack('L').shift
          version = stream.read(4).unpack('L').shift
    Severity: Minor
    Found in lib/rcs-common/serializer.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_content has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def decode_content(common_info, chunks)
          stream = StringIO.new chunks.join
    
          # ABLogStruct
          magic_ver = read_uint32 stream
    Severity: Minor
    Found in lib/rcs-common/evidence/addressbook.rb - About 1 hr to fix

      Method decode_content has 37 lines of code (exceeds 25 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/calendar.rb - About 1 hr to fix

        Method unserialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def unserialize(stream)
              header_begin = stream.pos
        
              tot_size = stream.read(4).unpack('L').shift
              version = stream.read(4).unpack('L').shift
        Severity: Minor
        Found in lib/rcs-common/serializer.rb - About 1 hr to fix

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

              cw.addressbook.each do |k|
                trace :debug, "WALLET: address #{k.inspect}"
                info = Hash[address_info]
                info[:data] = {}
                info[:data][:program] = coin
          Severity: Major
          Found in lib/rcs-common/evidence/money.rb and 1 other location - About 1 hr to fix
          lib/rcs-common/evidence/money.rb on lines 113..123

          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 decode_content has a Cognitive Complexity of 12 (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/file.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

              cw.keys.each do |k|
                trace :debug, "WALLET: key #{k.inspect}"
                info = Hash[address_info]
                info[:data] = {}
                info[:data][:program] = coin
          Severity: Major
          Found in lib/rcs-common/evidence/money.rb and 1 other location - About 1 hr to fix
          lib/rcs-common/evidence/money.rb on lines 101..111

          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 request has a Cognitive Complexity of 12 (exceeds 5 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

          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 35 lines of code (exceeds 25 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

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

              def decode_content(common_info, chunks)
                info = Hash[common_info]
                info[:data] ||= Hash.new
                info[:data][:type] = :mail
            
            
            Severity: Minor
            Found in lib/rcs-common/evidence/mail.rb - About 1 hr to fix

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

                def decode_additional_header(data)
                  raise EvidenceDeserializeError.new("incomplete FILECAP") if data.nil? or data.bytesize == 0
              
                  binary = StringIO.new data
              
              
              Severity: Major
              Found in lib/rcs-common/evidence/file.rb and 2 other locations - About 1 hr to fix
              lib/rcs-common/evidence/download.rb on lines 29..40
              lib/rcs-common/evidence/print.rb on lines 27..38

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

              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 append has a Cognitive Complexity of 11 (exceeds 5 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

              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 3 locations. Consider refactoring.
              Open

                def decode_additional_header(data)
                  raise EvidenceDeserializeError.new("incomplete DOWNLOAD") if data.nil? or data.bytesize == 0
              
                  binary = StringIO.new data
              
              
              Severity: Major
              Found in lib/rcs-common/evidence/download.rb and 2 other locations - About 1 hr to fix
              lib/rcs-common/evidence/file.rb on lines 103..114
              lib/rcs-common/evidence/print.rb on lines 27..38

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

              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 3 locations. Consider refactoring.
              Open

                def decode_additional_header(data)
                  raise EvidenceDeserializeError.new("incomplete PRINT") if data.nil? or data.bytesize == 0
              
                  binary = StringIO.new data
              
              
              Severity: Major
              Found in lib/rcs-common/evidence/print.rb and 2 other locations - About 1 hr to fix
              lib/rcs-common/evidence/download.rb on lines 29..40
              lib/rcs-common/evidence/file.rb on lines 103..114

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

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

                  def establish_database_connection(wait_until_connected: false)
                    loop do
                      connected = database.respond_to?(:connect!) ? database.connect!(component) : database.connect
              
                      if connected
              Severity: Minor
              Found in lib/rcs-common/component.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 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 invoke has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def invoke(args)
                      if address? and ([String, Symbol].include?(args.class))
                        task_name, address = args, self.address
                      elsif !address? and args.kind_of?(Hash)
                        task_name, address =  *args.to_a.flatten
              Severity: Minor
              Found in lib/rcs-common/updater/dsl.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

              Severity
              Category
              Status
              Source
              Language