Showing 164 of 164 total issues

Method main has a Cognitive Complexity of 384 (exceeds 5 allowed). Consider refactoring.
Open

    public static void main(String[] args) throws IOException{
        launch();
        CozyDatabaseMaster databaseMaster = new CozyDatabaseMaster("cozy-db");
        PendingTransactionContainer pendingTransactionContainer = new PendingTransactionContainer(databaseMaster);

Severity: Minor
Found in src/main/java/io/codepace/cozy/Main.java - About 1 wk 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 addBlock has a Cognitive Complexity of 148 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean addBlock(Block block, boolean fromBlockchainFile) {
        System.out.println("Attempting to add block " + block.blockNum + " with hash " + block.blockHash);
        try {
            boolean isPOS = false;
            if (block.difficulty == 100000) // 0.2.0 Hard-coded PoS difficulty.
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 3 days 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 validateBlock has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean validateBlock(Blockchain blockchain)
    {
        System.out.println("Validating block " + blockNum);
        System.out.println("Difficulty: " + difficulty);
        if (difficulty == 100000)
Severity: Minor
Found in src/main/java/io/codepace/cozy/db/Block.java - About 2 days 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 main has 453 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static void main(String[] args) throws IOException{
        launch();
        CozyDatabaseMaster databaseMaster = new CozyDatabaseMaster("cozy-db");
        PendingTransactionContainer pendingTransactionContainer = new PendingTransactionContainer(databaseMaster);

Severity: Major
Found in src/main/java/io/codepace/cozy/Main.java - About 2 days to fix

    Method validateBlock has 240 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public boolean validateBlock(Blockchain blockchain)
        {
            System.out.println("Validating block " + blockNum);
            System.out.println("Difficulty: " + difficulty);
            if (difficulty == 100000)
    Severity: Major
    Found in src/main/java/io/codepace/cozy/db/Block.java - About 1 day to fix

      File Main.java has 488 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package io.codepace.cozy;
      
      import io.codepace.cozy.address.AddressManager;
      import io.codepace.cozy.db.Block;
      import io.codepace.cozy.db.CozyDatabaseMaster;
      Severity: Minor
      Found in src/main/java/io/codepace/cozy/Main.java - About 7 hrs to fix

        Method addBlock has 191 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean addBlock(Block block, boolean fromBlockchainFile) {
                System.out.println("Attempting to add block " + block.blockNum + " with hash " + block.blockHash);
                try {
                    boolean isPOS = false;
                    if (block.difficulty == 100000) // 0.2.0 Hard-coded PoS difficulty.
        Severity: Major
        Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 7 hrs to fix

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

                          for (int i = 0; i < transactions.size(); i++)
                          {
                              /*
                               * Transaction format:
                               * InputAddress;InputAmount;OutputAddress1;OutputAmount1;OutputAddress2;OutputAmount2...;SignatureData;SignatureIndex
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 1 other location - About 7 hrs to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 302..356

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

          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 < transactions.size(); i++)
                          {
                              /*
                               * Transaction format:
                               * InputAddress;InputAmount;OutputAddress1;OutputAmount1;OutputAddress2;OutputAmount2...;SignatureData;SignatureIndex
          Severity: Major
          Found in src/main/java/io/codepace/cozy/db/Block.java and 1 other location - About 7 hrs to fix
          src/main/java/io/codepace/cozy/db/Block.java on lines 424..478

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

          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

          File Block.java has 422 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package io.codepace.cozy.db;
          
          import io.codepace.cozy.Certificate;
          import io.codepace.cozy.MerkleAddressUtility;
          
          
          Severity: Minor
          Found in src/main/java/io/codepace/cozy/db/Block.java - About 6 hrs to fix

            File MerkleAddressUtility.java has 415 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            package io.codepace.cozy;
            
            import java.io.File;
            import java.math.BigInteger;
            import java.security.MessageDigest;
            Severity: Minor
            Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 5 hrs to fix

              Method getMerkleSignature has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
              Open

                  public String getMerkleSignature(String message, String privateKey, long index, String address)
                  {
                      File infoFile = new File("addresses/" + address + "/info.dta");
                      if (!infoFile.exists())
                      {
              Severity: Minor
              Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 5 hrs 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

                                                      while (!foundNewAddress && j + counter < allPendingTransactions.size())
                                                      {
                                                          transaction = allPendingTransactions.get(j + counter);
                                                          if (!address.equals(transaction.split("::")[0]))
                                                          {
              Severity: Major
              Found in src/main/java/io/codepace/cozy/Main.java and 1 other location - About 4 hrs to fix
              src/main/java/io/codepace/cozy/Main.java on lines 468..498

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

              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

                                                  while (!foundNewAddress && j + counter < allPendingTransactions.size())
                                                  {
                                                      transaction = allPendingTransactions.get(j + counter);
                                                      if (!address.equals(transaction.split("::")[0]))
                                                      {
              Severity: Major
              Found in src/main/java/io/codepace/cozy/Main.java and 1 other location - About 4 hrs to fix
              src/main/java/io/codepace/cozy/Main.java on lines 355..385

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

              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 getMerkleSignature has 105 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public String getMerkleSignature(String message, String privateKey, long index, String address)
                  {
                      File infoFile = new File("addresses/" + address + "/info.dta");
                      if (!infoFile.exists())
                      {
              Severity: Major
              Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 4 hrs to fix

                Method verifyMerkleSignature has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public boolean verifyMerkleSignature(String message, String signature, String address, long index)
                    {
                        try
                        {
                            String lamportSignature = signature.substring(0, signature.indexOf(","));
                Severity: Major
                Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 4 hrs to fix

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

                      private String getLamportPrivateKey()
                      {
                          int len = CS.length();
                          return "" + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) +
                                  CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) +
                  Severity: Major
                  Found in src/main/java/io/codepace/cozy/address/LamportGenThread.java and 1 other location - About 4 hrs to fix
                  src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java on lines 289..296

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

                  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

                      @SuppressWarnings("unused")
                      private String getLamportPrivateKey() {
                          int len = CS.length();
                          return "" + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) +
                                  CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) + CS.charAt(lmpPrivGen.nextInt(len)) +
                  src/main/java/io/codepace/cozy/address/LamportGenThread.java on lines 143..150

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

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

                      public boolean verifyMerkleSignature(String message, String signature, String address, long index)
                      {
                          try
                          {
                              String lamportSignature = signature.substring(0, signature.indexOf(","));
                  Severity: Minor
                  Found in src/main/java/io/codepace/cozy/MerkleAddressUtility.java - About 4 hrs 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

                  File Blockchain.java has 313 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  package io.codepace.cozy.db;
                  
                  import io.codepace.cozy.LedgerManager;
                  
                  import java.io.BufferedWriter;
                  Severity: Minor
                  Found in src/main/java/io/codepace/cozy/db/Blockchain.java - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language