Showing 164 of 164 total issues

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

        for (int i = 0; i < chains.size(); i++) {
            if (chains.get(i).size() > longestChainLength) {
                longestChainNum = i;
                longestChainLength = chains.get(i).size();
            }
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Blockchain.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/db/Blockchain.java on lines 128..133

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

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

                    {
                        lamportPublicKey[i*2] = lamportSignatureParts[i*2];
                        lamportPublicKey[i*2+1] = SHA512(lamportSignatureParts[i*2+1]);
                    }
Severity: Minor
Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/MerkleAddressUtility.java on lines 113..116

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

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

        for (int i = 0; i < chains.size(); i++) {
            if (chains.get(i).size() > longestChainLength) {
                longestChain = i;
                longestChainLength = chains.get(i).size();
            }
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Blockchain.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/db/Blockchain.java on lines 422..427

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

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

            for (int i = 2; i < transactionParts.length - 2; i += 2) //-2 because last two parts of transaction are the signature and signature index
            {
                destinationAddresses.add(transactionParts[i]);
                destinationAmounts.add(Long.parseLong(transactionParts[i + 1]));
            }
Severity: Minor
Found in src/main/java/io/codepace/cozy/LedgerManager.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/LedgerManager.java on lines 142..146

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

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

            for (int i = 2; i < transactionParts.length - 2; i += 2) //-2 because last two parts of transaction are the signature and signature index
            {
                destinationAddresses.add(transactionParts[i]);
                destinationAmounts.add(Long.parseLong(transactionParts[i + 1]));
            }
Severity: Minor
Found in src/main/java/io/codepace/cozy/LedgerManager.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/LedgerManager.java on lines 205..209

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

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

        try
        {
            md = MessageDigest.getInstance("SHA-256");
            md512 = MessageDigest.getInstance("SHA-512");
        } catch (Exception e)
Severity: Minor
Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/address/LamportGenThread.java on lines 19..28

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

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

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

                                    if (loopCount > 10000) {
                                        System.out.println(ANSI_RED + "[node] " + ANSI_RESET + "- Infinite block detected! Hash: " + aChain.blockHash + " and height: " + aChain.blockNum);
                                        System.exit(-1);
                                    }
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Blockchain.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/db/Blockchain.java on lines 308..311

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

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

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

                                    if (loopCount > 10000) {
                                        System.out.println(ANSI_RED + "[node] " + ANSI_RESET + "- Infinite block detected! Hash: " + block.blockHash + " and height: " + block.blockNum);
                                        System.exit(-1);
                                    }
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Blockchain.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/db/Blockchain.java on lines 281..284

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

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

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

        try
        {
            md = MessageDigest.getInstance("SHA-256"); //Initializes md for SHA256 functions to use
            md512 = MessageDigest.getInstance("SHA-512"); //Initializes md512 for SHA-512
        } catch (Exception e)
Severity: Minor
Found in src/main/java/io/codepace/cozy/address/LamportGenThread.java and 1 other location - About 50 mins to fix
src/main/java/io/codepace/cozy/MerkleAddressUtility.java on lines 38..47

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

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

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

        rawBlock = "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{";
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Block.java and 1 other location - About 45 mins to fix
src/main/java/io/codepace/cozy/BlockGenerator.java on lines 52..52

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

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

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

        block += "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{";
Severity: Minor
Found in src/main/java/io/codepace/cozy/BlockGenerator.java and 1 other location - About 45 mins to fix
src/main/java/io/codepace/cozy/db/Block.java on lines 544..544

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

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

Avoid deeply nested control flow statements.
Open

                        if (parts.length > 1){
                            rpcAgent.rpcThreads.get(i).res = databaseMaster.getAddressBalance(parts[1]) + "";
                        } else {
                            rpcAgent.rpcThreads.get(i).res = databaseMaster.getAddressBalance(addressManager.getDefaultAddress()) + "";
                        }
Severity: Major
Found in src/main/java/io/codepace/cozy/Main.java - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                if (ledgerManager.executeTransaction(transactionsToApply.get(k))) {
                                    transactionsToApply.remove(k); //Executed correctly
                                    k--; //Compensate for changed ArrayList size
                                }
    Severity: Major
    Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if (outputBuffer.get(i).length() > 20) {
                                      System.out.println("Sending " + outputBuffer.get(i).substring(0, 20) + " to " + socket.getInetAddress());
                                  } else {
                                      System.out.println("Sending " + outputBuffer.get(i) + " to " + socket.getInetAddress());
                                  }
      Severity: Major
      Found in src/main/java/io/codepace/cozy/p2p/OutputThread.java - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                                    if (!address.equals(transaction.split("::")[0]))
                                                    {
                                                        foundNewAddress = true;
                                                        address = transaction.split("::")[0];
                                                        j = j + counter;
        Severity: Major
        Found in src/main/java/io/codepace/cozy/Main.java - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if(parts[0].equalsIgnoreCase("NETWORK_STATE")){
                                      topBlock = Integer.parseInt(parts[1]);
                                  } else if (parts[0].equalsIgnoreCase("REQUEST_NET_STATE")){
                                      System.out.println("DBLEN: " + databaseMaster.getBlockchainLength());
                                      System.out.println("HASH: " + databaseMaster.getLatestBlock().blockHash);
          Severity: Major
          Found in src/main/java/io/codepace/cozy/Main.java - About 45 mins to fix

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

                public void run(){
                    try{
                        req = null;
                        res = null;
                        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            Severity: Minor
            Found in src/main/java/io/codepace/cozy/p2p/RPCThread.java - 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

            Avoid deeply nested control flow statements.
            Open

                                        for (int j = largestChain.size() - 1; j > 0; j--) {
                                            ArrayList<String> transactionsToReverse = largestChain.get(j).transactions;
                                            for (String aTransactionsToReverse : transactionsToReverse) {
                                                ledgerManager.reverseTransaction(aTransactionsToReverse);
                                            }
            Severity: Major
            Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 45 mins to fix

              Method signTransaction has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static String signTransaction(String privateKey, String inputAddress, long inputAmount, ArrayList<String> outputAddresses, ArrayList<Long> outputAmounts, long index)
              Severity: Minor
              Found in src/main/java/io/codepace/cozy/TransactionUtility.java - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            for (Block aChain : chain) {
                                                //We can't directly assign transactionsToApply to block.transactions as we are going to edit it, and we don't want to delete transactions from the actual block.
                                                ArrayList<String> transactionsToApply = new ArrayList<>(block.transactions);
                                                int loopCount = 0;
                                                while (transactionsToApply.size() > 0) {
                Severity: Major
                Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language