connectbot/sshlib

View on GitHub

Showing 412 of 412 total issues

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

        synchronized (c.channelSendLock) {
            if (c.closeMessageSent)
                throw new IOException("Cannot request PTY on this channel ("
                        + c.getReasonClosed() + ")");
            tm.sendMessage(spr.getPayload());
Severity: Major
Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 6 other locations - About 30 mins to fix
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 661..666
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 697..702
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 755..760
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 790..795
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 822..827
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 857..862

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

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

        synchronized (c.channelSendLock)
        {
            if (c.closeMessageSent)
                throw new IOException("Cannot start shell on this channel (" + c.getReasonClosed() + ")");
            tm.sendMessage(sm.getPayload());
Severity: Major
Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 6 other locations - About 30 mins to fix
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 661..666
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 697..702
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 730..735
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 755..760
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 790..795
src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 822..827

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

Avoid too many return statements within this method.
Open

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

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

            synchronized (c.channelSendLock)
            {
                if (c.closeMessageSent)
                    throw new IOException("Cannot request X11 on this channel (" + c.getReasonClosed() + ")");
                tm.sendMessage(psr.getPayload());
    Severity: Major
    Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.java and 6 other locations - About 30 mins to fix
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 661..666
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 697..702
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 730..735
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 790..795
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 822..827
    src/main/java/com/trilead/ssh2/channel/ChannelManager.java on lines 857..862

    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

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

                if (msg[0] == Packets.SSH_MSG_USERAUTH_SUCCESS)
                {
                    authenticated = true;
                    tm.removeMessageHandler(this, 0, 255);
                    return true;
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java and 1 other location - About 30 mins to fix
    src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java on lines 481..486

    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

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

            for (int i = 0; i < mode.length(); i++)
                if (!Character.isDigit(mode.charAt(i)))
                    throw new IllegalArgumentException("Invalid mode.");
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/SCPClient.java and 1 other location - About 30 mins to fix
    src/main/java/com/trilead/ssh2/SCPClient.java on lines 584..586

    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

    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

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

            for (int i = 0; i < mode.length(); i++)
                if (!Character.isDigit(mode.charAt(i)))
                    throw new IllegalArgumentException("Invalid mode.");
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/SCPClient.java and 1 other location - About 30 mins to fix
    src/main/java/com/trilead/ssh2/SCPClient.java on lines 524..526

    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

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

            if (ar[0] == Packets.SSH_MSG_USERAUTH_SUCCESS)
            {
                authenticated = true;
                tm.removeMessageHandler(this, 0, 255);
                return true;
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java and 1 other location - About 30 mins to fix
    src/main/java/com/trilead/ssh2/auth/AuthenticationManager.java on lines 149..154

    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

    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/KnownHosts.java and 1 other location - About 30 mins to fix
    src/main/java/com/trilead/ssh2/Connection.java on lines 418..424

    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

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

        private final byte[] openDirectory(String path) throws IOException
        {
            int req_id = generateNextRequestID();
    
            TypesWriter tw = new TypesWriter();
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/SFTPv3Client.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 openFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private SFTPv3FileHandle openFile(String fileName, int flags, SFTPv3FileAttributes attr) throws IOException
        {
            int req_id = generateNextRequestID();
    
            TypesWriter tw = new TypesWriter();
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/SFTPv3Client.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 removeIdentity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

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

        @Override
        public void init(String name) throws IOException {
            final ECParameterSpec spec;
    
            if ("ecdh-sha2-nistp256".equals(name)) {
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/crypto/dh/EcDhExchange.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 read has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public int read(byte[] b, int off, int len) throws IOException
        {
            if (b == null)
                throw new NullPointerException();
    
    
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/channel/ChannelInputStream.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 removeAllIdentities has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

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

        private void waitUntilChannelOpen(Channel c) throws IOException
        {
            synchronized (c)
            {
                while (c.state == Channel.STATE_OPENING)
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/channel/ChannelManager.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 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

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

        private static byte[] decode(byte[] input) throws InvalidKeySpecException {
            if (input.length != ENCODED_SIZE) {
                throw new InvalidKeySpecException("Key is not of correct size");
            }
    
    
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/crypto/keys/Ed25519PublicKey.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 setKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private void setKey(byte[] key)
        {
            /*
             * - comments are from _Applied Crypto_, Schneier, p338 please be
             * careful comparing the two, AC numbers the arrays from 1, the enclosed
    Severity: Minor
    Found in src/main/java/com/trilead/ssh2/crypto/cipher/BlowFish.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

    Severity
    Category
    Status
    Source
    Language