connectbot/sshlib

View on GitHub
src/main/java/com/trilead/ssh2/Connection.java

Summary

Maintainability
F
3 days
Test Coverage
F
32%

File Connection.java has 561 lines of code (exceeds 250 allowed). Consider refactoring.
Open


package com.trilead.ssh2;

import java.io.CharArrayWriter;
import java.io.File;
Severity: Major
Found in src/main/java/com/trilead/ssh2/Connection.java - About 1 day to fix

    Connection has 53 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class Connection implements AutoCloseable
    {
        /**
         * The identifier presented to the SSH-2 server.
         */
    Severity: Major
    Found in src/main/java/com/trilead/ssh2/Connection.java - About 7 hrs to fix

      Method connect has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public synchronized ConnectionInfo connect(ServerHostKeyVerifier verifier, int connectTimeout, int kexTimeout)
                  throws IOException
          {
              final class TimeoutState
              {
      Severity: Major
      Found in src/main/java/com/trilead/ssh2/Connection.java - About 3 hrs to fix

        Method connect has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public synchronized ConnectionInfo connect(ServerHostKeyVerifier verifier, int connectTimeout, int kexTimeout)
                    throws IOException
            {
                final class TimeoutState
                {
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.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 removeDuplicates has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            private String[] removeDuplicates(String[] list)
            {
                if ((list == null) || (list.length < 2))
                    return list;
        
        
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.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

        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

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

            public synchronized LocalPortForwarder createLocalPortForwarder(InetSocketAddress addr, String host_to_connect,
                    int port_to_connect) throws IOException
            {
                if (tm == null)
                    throw new IllegalStateException("Cannot forward ports, you need to establish a connection first.");
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.java and 1 other location - About 35 mins to fix
        src/main/java/com/trilead/ssh2/Connection.java on lines 831..841

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

        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

            public synchronized LocalPortForwarder createLocalPortForwarder(int local_port, String host_to_connect,
                    int port_to_connect) throws IOException
            {
                if (tm == null)
                    throw new IllegalStateException("Cannot forward ports, you need to establish a connection first.");
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.java and 1 other location - About 35 mins to fix
        src/main/java/com/trilead/ssh2/Connection.java on lines 863..873

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

        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

                for (int i = 0; i < methods.length; i++)
                {
                    if (methods[i].compareTo(method) == 0)
                        return true;
                }
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.java and 1 other location - About 30 mins to fix
        src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java on lines 73..77

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

        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 (true)
                {
                    int len = fr.read(buff);
                    if (len < 0)
                        break;
        Severity: Minor
        Found in src/main/java/com/trilead/ssh2/Connection.java and 1 other location - About 30 mins to fix
        src/main/java/com/trilead/ssh2/KnownHosts.java on lines 474..480

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

        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