JeffDeCola/jeffCoin

View on GitHub

Showing 34 of 34 total issues

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

func GenesisWallet(nodeName string, passwordString string) {

    s := "START  GenesisWallet() - Creates the wallet and writes to file (Keys and jeffCoin Address)"
    log.Debug("WALLET:      I/F      " + s)

Severity: Major
Found in wallet/wallet-interface.go and 3 other locations - About 1 hr to fix
wallet/wallet-interface.go on lines 55..70
webserver/webserver-interface.go on lines 29..44
webserver/webserver-interface.go on lines 47..62

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

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

func ReadWalletFile(nodeName string, passwordString string) {

    s := "START  ReadWalletFile() - Reads the wallet from a file and puts in struct"
    log.Debug("WALLET:      I/F      " + s)

Severity: Major
Found in wallet/wallet-interface.go and 3 other locations - About 1 hr to fix
wallet/wallet-interface.go on lines 37..52
webserver/webserver-interface.go on lines 29..44
webserver/webserver-interface.go on lines 47..62

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

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

Function LoadTestDatatoBlockchain has 51 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func LoadTestDatatoBlockchain() {

    s := "START  LoadTestDatatoBlockchain() - Load the blockchain with test data"
    log.Debug("*** LOAD-TEST-DATA:   " + s)

Severity: Minor
Found in testblockchain/load-test-data.go - About 1 hr to fix

    Method txRequestMessageSignedStruct.processTxRequestMessage has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (trms txRequestMessageSignedStruct) processTxRequestMessage() string {
    
        s := "START  processTxRequestMessage() - Request to transfer jeffCoins to a jeffCoin Address"
        log.Debug("TRANSACTION:          " + s)
    
    
    Severity: Minor
    Found in blockchain/transactions.go - About 1 hr to fix

      Function getAddressBalance has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
      Open

      func getAddressBalance(jeffCoinAddress string) (int64, []unspentOutputStruct) {
      
          s := "START  getAddressBalance() - Gets the jeffCoin Address balance"
          log.Debug("BLOCKCHAIN:  GUTS     " + s)
      
      
      Severity: Minor
      Found in blockchain/guts.go - 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

          if _, err := os.Stat("credentials/" + *nodeNamePtr + "-password-hash.json"); err == nil {
              // Read password hash from a file and put in struct
              // Will also check password hash
              s := "READ existing password hash from a file and put in struct"
              log.Info("MAIN:                        " + s)
      Severity: Minor
      Found in jeffCoin.go and 1 other location - About 40 mins to fix
      jeffCoin.go on lines 199..211

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

      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

      Function BroadcastThisNode has 6 return statements (exceeds 4 allowed).
      Open

      func BroadcastThisNode() error {
      
          s := "START  BroadcastThisNode() - Broadcasts thisNode to the Network"
          log.Debug("ROUTINGNODE: I/F      " + s)
      
      
      Severity: Major
      Found in routingnode/routingnode-interface.go - About 40 mins to fix

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

            if _, err := os.Stat("credentials/" + *nodeNamePtr + "-wallet-encrypted.json"); err == nil {
                // READ existing wallet from a file (Keys and jeffCoin Address) and put in struct
                // Will also decrypt encrypted Private Key in file
                s := "READ existing wallet from a file (Keys and jeffCoin Address) and put in struct"
                log.Info("MAIN:                        " + s)
        Severity: Minor
        Found in jeffCoin.go and 1 other location - About 40 mins to fix
        jeffCoin.go on lines 185..196

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

        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

        Function RequestAddressBalance has 5 return statements (exceeds 4 allowed).
        Open

        func RequestAddressBalance(IP string, TCPPort string, jeffCoinAddress string) (string, error) {
        
            s := "START  RequestAddressBalance() - Requests the jeffCoin balance for a jeffCoin Address"
            log.Debug("WALLET:      I/F      " + s)
        
        
        Severity: Major
        Found in wallet/wallet-interface.go - About 35 mins to fix

          Function TransactionRequest has 5 return statements (exceeds 4 allowed).
          Open

          func TransactionRequest(nodeIP string, nodeTCPPort string, transactionRequestMessageSigned string) (string, error) {
          
              s := "START  TransactionRequest() - Request to transfer Coins to a jeffCoin Address"
              log.Debug("WALLET:      I/F      " + s)
          
          
          Severity: Major
          Found in wallet/wallet-interface.go - About 35 mins to fix

            Function RequestBlockchain has 5 return statements (exceeds 4 allowed).
            Open

            func RequestBlockchain(networkIP string, networkTCPPort string) error {
            
                s := "START  RequestBlockchain() - Requests the blockchain and the pendingBlock from a Network Node"
                log.Debug("BLOCKCHAIN:  I/F      " + s)
            
            
            Severity: Major
            Found in blockchain/blockchain-interface.go - About 35 mins to fix

              Line length
              Open

                  _SEND-BLOCKCHAIN (**SBC**)- Sends the blockchain and pendingBlock to another Node_
              Severity: Info
              Found in temp.md by markdownlint

              MD013 - Line length

              Tags: line_length

              Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

              This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

              This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

              You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

              Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

              Trailing spaces
              Open

              * LOCKED BLOCK  
              Severity: Info
              Found in temp.md by markdownlint

              MD009 - Trailing spaces

              Tags: whitespace

              Aliases: no-trailing-spaces

              Parameters: br_spaces (number; default: 0)

              This rule is triggered on any lines that end with whitespace. To fix this, find the line that is triggered and remove any trailing spaces from the end.

              The brspaces parameter allows an exception to this rule for a specific amount of trailing spaces used to insert an explicit line break/br element. For example, set brspaces to 2 to allow exactly 2 spaces at the end of a line.

              Note: you have to set brspaces to 2 or higher for this exception to take effect - you can't insert a br element with just a single trailing space, so if you set brspaces to 1, the exception will be disabled, just as if it was set to the default of 0.

              2: cannot find package "github.com/sirupsen/logrus" in any of:
              Open

                  log "github.com/sirupsen/logrus"
              Severity: Minor
              Found in blockchain/blockchain-interface.go by govet
              Severity
              Category
              Status
              Source
              Language