connectbot/sshlib

View on GitHub

Showing 412 of 412 total issues

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

            while (true)
            {
                int c = is.read();
                if (c < 0)
                    throw new IOException("Remote scp terminated unexpectedly.");
Severity: Major
Found in src/main/java/com/trilead/ssh2/SCPClient.java and 1 other location - About 1 hr to fix
src/main/java/com/trilead/ssh2/SCPClient.java on lines 330..355

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

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

    public void initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex,
            int connectTimeout, SecureRandom rnd, ProxyData proxyData) throws IOException
    {
        /* First, establish the TCP connection to the SSH-2 server */

Severity: Minor
Found in src/main/java/com/trilead/ssh2/transport/TransportManager.java - About 1 hr to fix

    Method msgChannelOpenFailure has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void msgChannelOpenFailure(byte[] msg, int msglen) throws IOException
        {
            if (msglen < 5)
                throw new IOException("SSH_MSG_CHANNEL_OPEN_FAILURE message has wrong size (" + msglen + ")");
    
    
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java - About 1 hr to fix

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

                  {
                      copylen = (stdoutAvail > len) ? len : stdoutAvail;
                      System.arraycopy(c.stdoutBuffer, c.stdoutReadpos, target, off, copylen);
                      c.stdoutReadpos += copylen;
      
      
      Severity: Major
      Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 1 other location - About 1 hr to fix
      src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 1070..1082

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

      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

                  {
                      copylen = (stderrAvail > len) ? len : stderrAvail;
                      System.arraycopy(c.stderrBuffer, c.stderrReadpos, target, off, copylen);
                      c.stderrReadpos += copylen;
      
      
      Severity: Major
      Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 1 other location - About 1 hr to fix
      src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 1056..1068

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

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

          public void addHostkey(String[] hostnames, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException
          {
              if (hostnames == null)
                  throw new IllegalArgumentException("hostnames may not be null");
      
      
      Severity: Minor
      Found in src/main/java/com/trilead/ssh2/KnownHosts.java - About 1 hr to fix

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

            private void processSignRequest(TypesReader tr)
            {
                try
                {
                    if (failWhenLocked())
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/channel/AuthAgentForwardThread.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 read has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public int read(SFTPv3FileHandle handle, long fileOffset, byte[] dst, int dstoff, int len) throws IOException
            {
                checkHandleValidAndOpen(handle);
        
                if ((len > 32768) || (len <= 0))
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/SFTPv3Client.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 msgChannelOpen has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public void msgChannelOpen(byte[] msg, int msglen) throws IOException
            {
                TypesReader tr = new TypesReader(msg, 0, msglen);
        
                tr.readByte(); // skip packet type
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.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 verifyHostkey has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public int verifyHostkey(String hostname, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException
            {
                PublicKey remoteKey = null;
        
                if (RSASHA1Verify.ID_SSH_RSA.equals(serverHostKeyAlgorithm) ||
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/KnownHosts.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 run has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public void run()
            {
                try
                {
                    cm.registerThread(this);
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/channel/LocalAcceptThread.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 run has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public void run()
            {
                try
                {
                    c.cm.sendOpenConfirmation(c);
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/channel/RemoteAcceptThread.java - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (tr.readByte() != 0x30 || // ASN.1 sequence
                          tr.readByte() != ENCODED_SIZE - 2 || // Expected size
                          tr.readByte() != 0x02 || // ASN.1 Integer
                          tr.readByte() != 1 || // length
                          tr.readByte() != 0 || // v1
          Severity: Critical
          Found in src/main/java/com/trilead/ssh2/crypto/keys/Ed25519PrivateKey.java - About 1 hr to fix

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

                    synchronized (c)
                    {
                        if (c.state == Channel.STATE_CLOSED)
                            return; // ignore
            
            
            Severity: Major
            Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 1 other location - About 1 hr to fix
            src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 1153..1170

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

            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

                    synchronized (c)
                    {
                        if (c.state == Channel.STATE_CLOSED)
                            return; // ignore
            
            
            Severity: Major
            Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 1 other location - About 1 hr to fix
            src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 899..917

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

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

                public boolean authenticateInteractive(String user, String[] submethods, InteractiveCallback cb) throws IOException
                {
                    try
                    {
                        initialize(user);
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java - About 1 hr to fix

              Method readAttrs has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private SFTPv3FileAttributes readAttrs(TypesReader tr) throws IOException
                  {
                      /*
                       * uint32   flags
                       * uint64   size           present only if flag SSH_FILEXFER_ATTR_SIZE
              Severity: Minor
              Found in src/main/java/com/trilead/ssh2/SFTPv3Client.java - About 1 hr to fix

                Method rawFingerPrint has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static byte[] rawFingerPrint(String type, String keyType, byte[] hostkey)
                    {
                        MessageDigest dig = null;
                
                        try {
                Severity: Minor
                Found in src/main/java/com/trilead/ssh2/KnownHosts.java - About 1 hr to fix

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

                      public void requestX11Forwarding(String hostname, int port, byte[] cookie, boolean singleConnection)
                              throws IOException
                      {
                          if (hostname == null)
                              throw new IllegalArgumentException("hostname argument may not be null");
                  Severity: Minor
                  Found in src/main/java/com/trilead/ssh2/Session.java - About 1 hr to fix

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

                        private byte[] decodeSSHECDSASignature(byte[] sig) throws IOException {
                            byte[] rsArray;
                    
                            TypesReader tr = new TypesReader(sig);
                    
                    
                    Severity: Minor
                    Found in src/main/java/com/trilead/ssh2/signature/ECDSASHA2Verify.java - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language