Showing 164 of 164 total issues

Method generateScratchFile has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean generateScratchFile(String scratchFileName, String privateKey, int numLayers, int numThreads, int keysPerThread) {
        ArrayList<LamportGenThread> threads = new ArrayList<>(); //ArrayList to hold worker threads
        for (int j = 0; j < numThreads; j++) {
            threads.add(new LamportGenThread()); //Initial setup, sanity check, and to make the normal thread removal loop not require a conditional.
        }
Severity: Minor
Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 3 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

Method sortTransactionsBySignatureIndex has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public static ArrayList<String> sortTransactionsBySignatureIndex(ArrayList<String> transactionsToSort)
    {
        for (int i = 0; i < transactionsToSort.size(); i++)
        {
            if (!isTransactionValid(transactionsToSort.get(i)))
Severity: Minor
Found in src/main/java/io/codepace/cozy/TransactionUtility.java - About 3 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

Method generateMerkleTreeFromScratchFile has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public String generateMerkleTreeFromScratchFile(String scratchFileName, int numLayers) {
        try {
            String tempDir = new Random().nextInt(10000000) + ""; //Name of temporary directory to hold progress files. Not deleted on failure for manual recovery purposes.
            File tempDirFile = new File(tempDir);
            tempDirFile.mkdir();
Severity: Major
Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 2 hrs to fix

    File LedgerManager.java has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package io.codepace.cozy;
    
    import javax.xml.bind.DatatypeConverter;
    import java.io.File;
    import java.io.PrintWriter;
    Severity: Minor
    Found in src/main/java/io/codepace/cozy/LedgerManager.java - About 2 hrs to fix

      Method generateScratchFile has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public boolean generateScratchFile(String scratchFileName, String privateKey, int numLayers, int numThreads, int keysPerThread) {
              ArrayList<LamportGenThread> threads = new ArrayList<>(); //ArrayList to hold worker threads
              for (int j = 0; j < numThreads; j++) {
                  threads.add(new LamportGenThread()); //Initial setup, sanity check, and to make the normal thread removal loop not require a conditional.
              }
      Severity: Major
      Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 2 hrs to fix

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

            public void run() {
                try {
                    outputBuffer = new ArrayList<>();
                    PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
                    while (shouldContinue) {
        Severity: Minor
        Found in src/main/java/io/codepace/cozy/p2p/OutputThread.java - About 2 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

        Method reverseTransaction has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public boolean reverseTransaction(String transaction) {
                try {
                    String[] transactionParts = transaction.split(";");
                    String transactionMessage = "";
                    for (int i = 0; i < transactionParts.length - 2; i++) {
        Severity: Major
        Found in src/main/java/io/codepace/cozy/LedgerManager.java - About 2 hrs to fix

          File MerkleTreeGenLimitless.java has 259 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package io.codepace.cozy.address;
          
          import java.io.File;
          import java.io.PrintWriter;
          import java.nio.file.Files;
          Severity: Minor
          Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 2 hrs to fix

            Method executeTransaction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public boolean executeTransaction(String transaction) {
                    try {
                        String[] transactionParts = transaction.split(";");
                        String transactionMessage = "";
                        for (int i = 0; i < transactionParts.length - 2; i++) {
            Severity: Major
            Found in src/main/java/io/codepace/cozy/LedgerManager.java - About 2 hrs to fix

              Method generateMerkleTreeFromScratchFile has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public String generateMerkleTreeFromScratchFile(String scratchFileName, int numLayers) {
                      try {
                          String tempDir = new Random().nextInt(10000000) + ""; //Name of temporary directory to hold progress files. Not deleted on failure for manual recovery purposes.
                          File tempDirFile = new File(tempDir);
                          tempDirFile.mkdir();
              Severity: Minor
              Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 2 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

              Method getTransactionsInvolvingAddress has a Cognitive Complexity of 16 (exceeds 5 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 2 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

              Method reverseTransaction has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public boolean reverseTransaction(String transaction) {
                      try {
                          String[] transactionParts = transaction.split(";");
                          String transactionMessage = "";
                          for (int i = 0; i < transactionParts.length - 2; i++) {
              Severity: Minor
              Found in src/main/java/io/codepace/cozy/LedgerManager.java - About 2 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

              Method getLamportPublicKey has 49 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private String getLamportPublicKey(byte[] seed)
                  {
                      try
                      {
                          lmpPrivGen = SecureRandom.getInstance("SHA1PRNG");
              Severity: Minor
              Found in src/main/java/io/codepace/cozy/address/LamportGenThread.java - About 1 hr to fix

                Method sortTransactionsBySignatureIndex has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static ArrayList<String> sortTransactionsBySignatureIndex(ArrayList<String> transactionsToSort)
                    {
                        for (int i = 0; i < transactionsToSort.size(); i++)
                        {
                            if (!isTransactionValid(transactionsToSort.get(i)))
                Severity: Minor
                Found in src/main/java/io/codepace/cozy/TransactionUtility.java - About 1 hr to fix

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

                      public long getPendingBalance(String address) {
                          long totalChange = 0L;
                          for (int i = 0; i < pendingTransactions.size(); i++) {
                              String transaction = pendingTransactions.get(i);
                              try {
                  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 isTransactionValid has 45 lines of code (exceeds 25 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

                    Method executeTransaction has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public boolean executeTransaction(String transaction) {
                            try {
                                String[] transactionParts = transaction.split(";");
                                String transactionMessage = "";
                                for (int i = 0; i < transactionParts.length - 2; i++) {
                    Severity: Minor
                    Found in src/main/java/io/codepace/cozy/LedgerManager.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 41 lines of code (exceeds 25 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) {
                            System.out.println("Creating block...");
                            System.out.println("timestamp: " + timestamp);
                            System.out.println("blockNum: " + blockNum);
                            System.out.println("previousBlockHash: " + previousBlockHash);
                    Severity: Minor
                    Found in src/main/java/io/codepace/cozy/BlockGenerator.java - About 1 hr to fix

                      Method main has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static void main(String[] args) //A messy test method, in here for convenience. Will be removed before final release.
                          {
                              //launch();
                              Scanner scan = new Scanner(System.in);
                              System.out.println("Generate address (1) normally or (2) from scratch file or (3) just generate scratch file?");
                      Severity: Minor
                      Found in src/main/java/io/codepace/cozy/address/MerkleTreeGenLimitless.java - About 1 hr to fix

                        Method addTransaction has 40 lines of code (exceeds 25 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
                          Severity
                          Category
                          Status
                          Source
                          Language