Showing 164 of 164 total issues

Method isTransactionValid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static boolean isTransactionValid(String transaction)
    {
        System.out.println("Checking transaction: " + transaction);
        MerkleAddressUtility merkleAddressUtility = new MerkleAddressUtility();
        try
Severity: Minor
Found in src/main/java/io/codepace/cozy/TransactionUtility.java - 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 compileBlock has 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static String compileBlock(long timestamp, int blockNum, String previousBlockHash, long difficulty, int winningNonce, String ledgerHash, ArrayList<String> transactions, Certificate certificate, String signingAddress, String privateKey, long minerSignatureIndex) {
Severity: Major
Found in src/main/java/io/codepace/cozy/BlockGenerator.java - About 1 hr to fix

    Method run has 32 lines of code (exceeds 25 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 1 hr to fix

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

                      if (!MerkleAddressUtility.verifyMerkleSignature(fullBlock, minerSignature, certificate.redeemAddress, minerSignatureIndex))
                      {
                          System.out.println("Block didn't verify for " + certificate.redeemAddress + " with index " + minerSignatureIndex);
                          System.out.println("Signature mismatch error");
                          System.out.println("fullBlock: " + fullBlock);
      Severity: Major
      Found in src/main/java/io/codepace/cozy/db/Block.java and 1 other location - About 1 hr to fix
      src/main/java/io/codepace/cozy/db/Block.java on lines 284..291

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

      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 (!MerkleAddressUtility.verifyMerkleSignature(fullBlock, minerSignature, certificate.redeemAddress, minerSignatureIndex))
                      {
                          System.out.println("Block didn't verify for " + certificate.redeemAddress + " with index " + minerSignatureIndex);
                          System.out.println("Signature mismatch error");
                          System.out.println("fullBlock: " + fullBlock);
      Severity: Major
      Found in src/main/java/io/codepace/cozy/db/Block.java and 1 other location - About 1 hr to fix
      src/main/java/io/codepace/cozy/db/Block.java on lines 406..413

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

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

          public void tryBlockQueue() {
              boolean addedABlock = false;
              do //Some blocks in the queue may be attempted before other dependency blocks, so while we are able to add blocks, we will continue to add them.
              {
                  addedABlock = false;
      Severity: Minor
      Found in src/main/java/io/codepace/cozy/db/Blockchain.java - 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 addTransaction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public boolean addTransaction(String transaction) {
              try {
                  for (int i = 0; i < pendingTransactions.size(); i++) {
                      if (pendingTransactions.get(i).equals(transaction)) {
                          return false;
      Severity: Minor
      Found in src/main/java/io/codepace/cozy/PendingTransactionContainer.java - 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 getTransactionsInvolvingAddress has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public ArrayList<String> getTransactionsInvolvingAddress(String addressToFind)
          {
              ArrayList<String> relevantTransactionParts = new ArrayList<>();
              for (int i = 0; i < transactions.size(); i++)
              {
      Severity: Minor
      Found in src/main/java/io/codepace/cozy/db/Block.java - About 1 hr to fix

        Method isAddressFormattedCorrectly has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean isAddressFormattedCorrectly(String address)
            {
                try
                {
                    String prefix = address.substring(0, 2); //Prefix is 2 characters long
        Severity: Minor
        Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 1 hr to fix

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

                          String blockData = "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{" + transactionsString + "}," + certificate.getFullCertificate();
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 3 other locations - About 1 hr to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 97..97
          src/main/java/io/codepace/cozy/db/Block.java on lines 402..402
          src/main/java/io/codepace/cozy/db/Block.java on lines 280..280

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

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

                          String blockData = "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{" + transactionsString + "}," + certificate.getFullCertificate();
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 3 other locations - About 1 hr to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 97..97
          src/main/java/io/codepace/cozy/db/Block.java on lines 190..190
          src/main/java/io/codepace/cozy/db/Block.java on lines 280..280

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

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

                      String blockData = "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{" + transactionsString + "}," + certificate.getFullCertificate();
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 3 other locations - About 1 hr to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 190..190
          src/main/java/io/codepace/cozy/db/Block.java on lines 402..402
          src/main/java/io/codepace/cozy/db/Block.java on lines 280..280

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

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

                          String blockData = "{" + timestamp + ":" + blockNum + ":" + previousBlockHash + ":" + difficulty + ":" + winningNonce + "},{" + ledgerHash + "},{" + transactionsString + "}," + certificate.getFullCertificate();
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 3 other locations - About 1 hr to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 97..97
          src/main/java/io/codepace/cozy/db/Block.java on lines 190..190
          src/main/java/io/codepace/cozy/db/Block.java on lines 402..402

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

          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

              public void run() {
                  try {
                      ServerSocket listenSocket = new ServerSocket(listenPort);
                      while (shouldRun) //Doesn't actually quit right when shouldRun is changed, as while loop is pending.
                      {
          Severity: Minor
          Found in src/main/java/io/codepace/cozy/p2p/PeerNetwork.java and 1 other location - About 55 mins to fix
          src/main/java/io/codepace/cozy/p2p/RPC.java on lines 46..61

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

          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

              public void run()
              {
                  try
                  {
                      ServerSocket socket = new ServerSocket(listenPort);
          Severity: Minor
          Found in src/main/java/io/codepace/cozy/p2p/RPC.java and 1 other location - About 55 mins to fix
          src/main/java/io/codepace/cozy/p2p/PeerNetwork.java on lines 63..76

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

          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) {
                          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] = SHA256Short(lamportSignatureParts[i*2]);
                                  lamportPublicKey[i*2+1] = 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 105..108

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

                  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

          Severity
          Category
          Status
          Source
          Language