connectbot/sshlib

View on GitHub

Showing 412 of 412 total issues

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

    public PacketUserauthRequestPublicKey(String serviceName, String user,
            String pkAlgorithmName, byte[] pk, byte[] sig)
    {
        this.serviceName = serviceName;
        this.userName = user;
src/main/java/com/trilead/ssh2/packets/PacketSessionPtyResize.java on lines 12..18

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

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 5 locations. Consider refactoring.
Open

    public synchronized void setServer2ClientMACs(String[] macs)
    {
        if ((macs == null) || (macs.length == 0))
            throw new IllegalArgumentException();

Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java and 4 other locations - About 50 mins to fix
src/main/java/com/trilead/ssh2/Connection.java on lines 1257..1264
src/main/java/com/trilead/ssh2/Connection.java on lines 1271..1278
src/main/java/com/trilead/ssh2/Connection.java on lines 1302..1309
src/main/java/com/trilead/ssh2/Connection.java on lines 1339..1347

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

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 5 locations. Consider refactoring.
Open

    public synchronized void setClient2ServerCiphers(String[] ciphers)
    {
        if ((ciphers == null) || (ciphers.length == 0))
            throw new IllegalArgumentException();
        ciphers = removeDuplicates(ciphers);
Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java and 4 other locations - About 50 mins to fix
src/main/java/com/trilead/ssh2/Connection.java on lines 1271..1278
src/main/java/com/trilead/ssh2/Connection.java on lines 1302..1309
src/main/java/com/trilead/ssh2/Connection.java on lines 1316..1324
src/main/java/com/trilead/ssh2/Connection.java on lines 1339..1347

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

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 5 locations. Consider refactoring.
Open

    public synchronized void setClient2ServerMACs(String[] macs)
    {
        if ((macs == null) || (macs.length == 0))
            throw new IllegalArgumentException();
        macs = removeDuplicates(macs);
Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java and 4 other locations - About 50 mins to fix
src/main/java/com/trilead/ssh2/Connection.java on lines 1257..1264
src/main/java/com/trilead/ssh2/Connection.java on lines 1302..1309
src/main/java/com/trilead/ssh2/Connection.java on lines 1316..1324
src/main/java/com/trilead/ssh2/Connection.java on lines 1339..1347

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

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 5 locations. Consider refactoring.
Open

    public synchronized void setServer2ClientCiphers(String[] ciphers)
    {
        if ((ciphers == null) || (ciphers.length == 0))
            throw new IllegalArgumentException();
        ciphers = removeDuplicates(ciphers);
Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java and 4 other locations - About 50 mins to fix
src/main/java/com/trilead/ssh2/Connection.java on lines 1257..1264
src/main/java/com/trilead/ssh2/Connection.java on lines 1271..1278
src/main/java/com/trilead/ssh2/Connection.java on lines 1316..1324
src/main/java/com/trilead/ssh2/Connection.java on lines 1339..1347

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

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 5 locations. Consider refactoring.
Open

    public synchronized void setServerHostKeyAlgorithms(String[] algos)
    {
        if ((algos == null) || (algos.length == 0))
            throw new IllegalArgumentException();

Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java and 4 other locations - About 50 mins to fix
src/main/java/com/trilead/ssh2/Connection.java on lines 1257..1264
src/main/java/com/trilead/ssh2/Connection.java on lines 1271..1278
src/main/java/com/trilead/ssh2/Connection.java on lines 1302..1309
src/main/java/com/trilead/ssh2/Connection.java on lines 1316..1324

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

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

            while (n < len) {
                int cnt = bi.read(b, off + n, len - n);
                if (cnt < 0)
                    throw new IOException("Cannot fill buffer, EOF reached.");
                n += cnt;
src/main/java/com/trilead/ssh2/crypto/cipher/CipherInputStream.java on lines 103..109

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

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 (msg[0] == Packets.SSH_MSG_USERAUTH_FAILURE)
            {
                PacketUserauthFailure puf = new PacketUserauthFailure(msg, 0, msg.length);

                remainingMethods = puf.getAuthThatCanContinue();
Severity: Minor
Found in src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java and 1 other location - About 45 mins to fix
src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java on lines 488..496

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

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

        while (n < len)
        {
            int cnt = bi.read(b, off + n, len - n);
            if (cnt < 0)
                throw new IOException("Cannot fill buffer, EOF reached.");
src/main/java/com/trilead/ssh2/crypto/cipher/CipherInputStream.java on lines 121..126

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

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 (ar[0] == Packets.SSH_MSG_USERAUTH_FAILURE)
        {
            PacketUserauthFailure puf = new PacketUserauthFailure(ar, 0, ar.length);

            remainingMethods = puf.getAuthThatCanContinue();
Severity: Minor
Found in src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java and 1 other location - About 45 mins to fix
src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java on lines 156..163

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

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

    private void init() throws IOException
    {
        /* Send SSH_FXP_INIT (version 3) */

        final int client_version = 3;
Severity: Minor
Found in src/main/java/com/trilead/ssh2/SFTPv3Client.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 deeply nested control flow statements.
Open

                        if ((c >= 32) && (c <= 126))
                            continue;
Severity: Major
Found in src/main/java/com/trilead/ssh2/transport/TransportManager.java - About 45 mins to fix

    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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public void initialize(CryptoWishList cwl, ServerHostKeyVerifier verifier, DHGexParameters dhgex,
                  int connectTimeout, SecureRandom rnd, ProxyData proxyData) throws IOException
      Severity: Minor
      Found in src/main/java/com/trilead/ssh2/transport/TransportManager.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

        Method calculateKey has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private static byte[] calculateKey(HashForSSH2Types sh, BigInteger K, byte[] H, byte type, byte[] SessionID,
                    int keyLength)
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/crypto/KeyMaterial.java - About 45 mins to fix

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

              public static char[] encode(byte[] content)
              {
                  CharArrayWriter cw = new CharArrayWriter((4 * content.length) / 3);
          
                  int idx = 0;
          Severity: Minor
          Found in src/main/java/com/trilead/ssh2/crypto/Base64.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

          Method requestPTY has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public void requestPTY(String term, int term_width_characters, int term_height_characters, int term_width_pixels,
                      int term_height_pixels, byte[] terminal_modes) throws IOException
          Severity: Minor
          Found in src/main/java/com/trilead/ssh2/Session.java - About 45 mins to fix

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

                public int read() throws IOException
                {
                    synchronized (synchronizer)
                    {
                        if (isClosed)
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/StreamGobbler.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

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

                @Override
                public void init(String name) throws IOException {
                    final DHParameterSpec spec;
                    if ("diffie-hellman-group18-sha512".equals(name)) {
                        spec = new DHParameterSpec(P18, G);
            Severity: Minor
            Found in src/main/java/com/trilead/ssh2/crypto/dh/DhExchange.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

            Severity
            Category
            Status
            Source
            Language