peryaudo/bcwallet

View on GitHub
bcwallet.rb

Summary

Maintainability
F
4 days
Test Coverage

File bcwallet.rb has 917 lines of code (exceeds 250 allowed). Consider refactoring.
Open

IS_TESTNET = true

# Remote host to use: It is recommended to use this client with a local client.
# Install Bitcoin-Qt and then launch with -testnet option to connect Testnet.
HOST = 'localhost'
Severity: Major
Found in bcwallet.rb - About 2 days to fix

    Class Message has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Message
      #
      # Constants used in inventory vector
      #
      MSG_TX = 1
    Severity: Minor
    Found in bcwallet.rb - About 2 hrs to fix

      Class Network has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Network
        attr_reader :status, :data
      
        # 
        # keys = { name => ECDSA key objects }
      Severity: Minor
      Found in bcwallet.rb - About 2 hrs to fix

        Method initialize has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize
            #
            # Message definitions.
            #
            @message_definitions = {
        Severity: Major
        Found in bcwallet.rb - About 2 hrs to fix

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

            def run
              return usage if @argv.length < 1
          
              # check argument numbers
              case @argv.first
          Severity: Minor
          Found in bcwallet.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 accumulate_txs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def accumulate_txs(from_key, amount)
              public_key_hash = from_key.to_public_key_hash
          
              # Refresh spent flags of tx_outs
              set_spent_for_tx_outs!
          Severity: Minor
          Found in bcwallet.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 sync has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def sync
              Thread.abort_on_exception = true
              @is_sync_finished = false
              t = Thread.new do
          
          
          Severity: Minor
          Found in bcwallet.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 get_balance has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_balance(keys)
              balance = {}
              keys.each do |addr, _|
                balance[addr] = 0
              end
          Severity: Minor
          Found in bcwallet.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 serialize_struct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def serialize_struct(type, struct)
              if type.kind_of?(Proc)
                type.call(:write, struct)
                return
              end
          Severity: Minor
          Found in bcwallet.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 relay_flag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def relay_flag(rw, val = nil)
              case rw
              when :read
                if @payload.length > 0
                  uint8(:read)
          Severity: Minor
          Found in bcwallet.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
          Severity: Major
          Found in bcwallet.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                when 'block'    then return if require_args(1)
            Severity: Major
            Found in bcwallet.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  when 'balance'  then return if require_args(0)
              Severity: Major
              Found in bcwallet.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    when 'send'     then return if require_args(3)
                Severity: Major
                Found in bcwallet.rb - About 30 mins to fix

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

                    def read(socket)
                      packet = read_packet(socket)
                  
                      expected_magic    = [IS_TESTNET ? '0b110907' : 'f9beb4d9'].pack('H*')
                      expected_checksum = Key.hash256(packet[:payload])[0, 4]
                  Severity: Minor
                  Found in bcwallet.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

                  There are no issues that match your filters.

                  Category
                  Status