connectbot/sshlib

View on GitHub
src/main/java/com/trilead/ssh2/transport/KexManager.java

Summary

Maintainability
F
6 days
Test Coverage
B
85%

Method handleMessage has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring.
Open

    public synchronized void handleMessage(byte[] msg, int msglen) throws IOException
    {
        PacketKexInit kip;

        if (msg == null)
Severity: Minor
Found in src/main/java/com/trilead/ssh2/transport/KexManager.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 KexManager.java has 607 lines of code (exceeds 250 allowed). Consider refactoring.
Open


package com.trilead.ssh2.transport;

import com.trilead.ssh2.signature.RSASHA256Verify;
import com.trilead.ssh2.signature.RSASHA512Verify;
Severity: Major
Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 1 day to fix

    Method handleMessage has 225 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public synchronized void handleMessage(byte[] msg, int msglen) throws IOException
        {
            PacketKexInit kip;
    
            if (msg == null)
    Severity: Major
    Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 1 day to fix

      Method filterHostKeyTypes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          private void filterHostKeyTypes(CryptoWishList cwl) {
              if (verifier instanceof ExtendedServerHostKeyVerifier) {
                  ExtendedServerHostKeyVerifier extendedVerifier = (ExtendedServerHostKeyVerifier) verifier;
      
                  List<String> knownAlgorithms = extendedVerifier.getKnownKeyAlgorithmsForHost(hostname, port);
      Severity: Minor
      Found in src/main/java/com/trilead/ssh2/transport/KexManager.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 mergeKexParameters has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private NegotiatedParameters mergeKexParameters(KexParameters client, KexParameters server)
          {
              NegotiatedParameters np = new NegotiatedParameters();
      
              try
      Severity: Major
      Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    if (kxs.np.kex_algo.equals(Curve25519Exchange.NAME)
                            || kxs.np.kex_algo.equals(Curve25519Exchange.ALT_NAME)
                            || kxs.np.kex_algo.equals("ecdh-sha2-nistp521")
                            || kxs.np.kex_algo.equals("ecdh-sha2-nistp384")
                            || kxs.np.kex_algo.equals("ecdh-sha2-nistp256")
        Severity: Critical
        Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  if (kxs.np.kex_algo.equals("diffie-hellman-group1-sha1")
                          || kxs.np.kex_algo.equals("diffie-hellman-group14-sha1")
                          || kxs.np.kex_algo.equals("diffie-hellman-group14-sha256")
                          || kxs.np.kex_algo.equals("diffie-hellman-group16-sha512")
                          || kxs.np.kex_algo.equals("diffie-hellman-group18-sha512")
          Severity: Critical
          Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 2 hrs to fix

            Method verifySignature has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private boolean verifySignature(byte[] sig, byte[] hostkey) throws IOException {
                    SSHSignature sshSignature;
                    if (kxs.np.server_host_key_algo.equals(Ed25519Verify.get().getKeyFormat())) {
                        sshSignature = Ed25519Verify.get();
                    } else if (kxs.np.server_host_key_algo.equals(ECDSASHA2Verify.ECDSASHA2NISTP256Verify.get().getKeyFormat())) {
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/transport/KexManager.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 getFirstMatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private String getFirstMatch(String[] client, String[] server) throws NegotiateException
                {
                    if (client == null || server == null)
                        throw new IllegalArgumentException();
            
            
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/transport/KexManager.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

            Avoid deeply nested control flow statements.
            Open

                                    if (capableAlgo.equals(knownAlgo)) {
                                        filteredAlgorithms.add(knownAlgo);
                                    }
            Severity: Major
            Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 45 mins to fix

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

                  public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws IOException
                  {
                      synchronized (accessLock)
                      {
                          while (true)
              Severity: Minor
              Found in src/main/java/com/trilead/ssh2/transport/KexManager.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 too many return statements within this method.
              Open

                              return;
              Severity: Major
              Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return;
                Severity: Major
                Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return;
                  Severity: Major
                  Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return;
                    Severity: Major
                    Found in src/main/java/com/trilead/ssh2/transport/KexManager.java - About 30 mins to fix

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

                          private boolean compareFirstOfNameList(String[] a, String[] b)
                          {
                              if (a == null || b == null)
                                  throw new IllegalArgumentException();
                      
                      
                      Severity: Minor
                      Found in src/main/java/com/trilead/ssh2/transport/KexManager.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

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

                                      if (verifier != null)
                                      {
                                          boolean vres = false;
                      
                                          try
                      Severity: Major
                      Found in src/main/java/com/trilead/ssh2/transport/KexManager.java and 1 other location - About 1 hr to fix
                      src/main/java/com/trilead/ssh2/transport/KexManager.java on lines 723..739

                      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

                                      if (verifier != null)
                                      {
                                          boolean vres = false;
                      
                                          try
                      Severity: Major
                      Found in src/main/java/com/trilead/ssh2/transport/KexManager.java and 1 other location - About 1 hr to fix
                      src/main/java/com/trilead/ssh2/transport/KexManager.java on lines 658..674

                      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

                                  {
                                      cbc = BlockCipherFactory.createCipher(kxs.np.enc_algo_server_to_client, false,
                                              km.enc_key_server_to_client, km.initial_iv_server_to_client);
                      
                                      mac = new HMAC(kxs.np.mac_algo_server_to_client, km.integrity_key_server_to_client);
                      Severity: Minor
                      Found in src/main/java/com/trilead/ssh2/transport/KexManager.java and 1 other location - About 50 mins to fix
                      src/main/java/com/trilead/ssh2/transport/KexManager.java on lines 408..416

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

                      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

                              {
                                  cbc = BlockCipherFactory.createCipher(kxs.np.enc_algo_client_to_server, true, km.enc_key_client_to_server,
                                          km.initial_iv_client_to_server);
                      
                                  mac = new HMAC(kxs.np.mac_algo_client_to_server, km.integrity_key_client_to_server);
                      Severity: Minor
                      Found in src/main/java/com/trilead/ssh2/transport/KexManager.java and 1 other location - About 50 mins to fix
                      src/main/java/com/trilead/ssh2/transport/KexManager.java on lines 594..601

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status