connectbot/sshlib

View on GitHub
src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java

Summary

Maintainability
F
5 days
Test Coverage
F
53%

Method decode has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    public static KeyPair decode(PEMStructure ps, String password) throws IOException
    {
        if (isPEMEncrypted(ps) && ps.pemType != PEM_OPENSSH_PRIVATE_KEY)
        {
            if (password == null)
Severity: Minor
Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 1 day 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 PEMDecoder.java has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open


package com.trilead.ssh2.crypto;

import java.io.BufferedReader;
import java.io.CharArrayReader;
Severity: Major
Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 1 day to fix

    Method decode has 194 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static KeyPair decode(PEMStructure ps, String password) throws IOException
        {
            if (isPEMEncrypted(ps) && ps.pemType != PEM_OPENSSH_PRIVATE_KEY)
            {
                if (password == null)
    Severity: Major
    Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 7 hrs to fix

      Method parsePEM has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          public static final PEMStructure parsePEM(char[] pem) throws IOException
          {
              PEMStructure ps = new PEMStructure();
      
              String line = null;
      Severity: Minor
      Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.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

      Method parsePEM has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static final PEMStructure parsePEM(char[] pem) throws IOException
          {
              PEMStructure ps = new PEMStructure();
      
              String line = null;
      Severity: Major
      Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 3 hrs to fix

        Method decryptData has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static byte[] decryptData(byte[] data, byte[] pw, byte[] salt, int rounds, String algo) throws IOException
            {
                BlockCipher bc;
                int keySize;
        
        
        Severity: Major
        Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 2 hrs to fix

          Method decryptData has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              private static byte[] decryptData(byte[] data, byte[] pw, byte[] salt, int rounds, String algo) throws IOException
              {
                  BlockCipher bc;
                  int keySize;
          
          
          Severity: Minor
          Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.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 generateKeyFromPasswordSaltWithMD5 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static byte[] generateKeyFromPasswordSaltWithMD5(byte[] password, byte[] salt, int keyLen)
                      throws IOException
              {
                  if (salt.length < 8)
                      throw new IllegalArgumentException("Salt needs to be at least 8 bytes for key generation.");
          Severity: Minor
          Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 1 hr to fix

            Method generateKeyFromPasswordSaltWithMD5 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private static byte[] generateKeyFromPasswordSaltWithMD5(byte[] password, byte[] salt, int keyLen)
                        throws IOException
                {
                    if (salt.length < 8)
                        throw new IllegalArgumentException("Salt needs to be at least 8 bytes for key generation.");
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method decryptData has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private static byte[] decryptData(byte[] data, byte[] pw, byte[] salt, int rounds, String algo) throws IOException
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 35 mins to fix

              Method hexToInt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private static int hexToInt(char c)
                  {
                      if ((c >= 'a') && (c <= 'f'))
                      {
                          return (c - 'a') + 10;
              Severity: Minor
              Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 25 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

              Method isPEMEncrypted has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static final boolean isPEMEncrypted(PEMStructure ps) throws IOException
                  {
                      if (ps.pemType == PEM_OPENSSH_PRIVATE_KEY) {
                          TypesReader tr = new TypesReader(ps.data);
                          byte[] magic = tr.readBytes(OPENSSH_V1_MAGIC.length);
              Severity: Minor
              Found in src/main/java/com/trilead/ssh2/crypto/PEMDecoder.java - About 25 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

              There are no issues that match your filters.

              Category
              Status