hirura/hrr_rb_ssh

View on GitHub

Showing 169 of 169 total issues

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

  class DataTypes
    # Uint32 provides methods to convert integer value and 32-bit unsigned binary string each other.
    class Uint32 < DataTypes
      # Convert integer value into 32-bit unsigned binary string.
      #
Severity: Minor
Found in lib/hrr_rb_ssh/data_types/uint32.rb and 1 other location - About 40 mins to fix
lib/hrr_rb_ssh/data_types/byte.rb on lines 2..24

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

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

  class DataTypes
    # Byte provides methods to convert integer value and 8-bit unsigned binary string each other.
    class Byte < DataTypes
      # Convert integer value into 8-bit unsigned binary string.
      #
Severity: Minor
Found in lib/hrr_rb_ssh/data_types/byte.rb and 1 other location - About 40 mins to fix
lib/hrr_rb_ssh/data_types/uint32.rb on lines 2..24

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

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

        def build_key(_k, h, _x, session_id, key_length)
Severity: Minor
Found in lib/hrr_rb_ssh/transport/kex_algorithms/iv_computable.rb - About 35 mins to fix

    Method generate_signature has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                def generate_signature session_id, username, service_name, method_name, secret_key
    Severity: Minor
    Found in lib/hrr_rb_ssh/authentication/method/publickey/algorithm/functionable.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

                def initialize transport, username, submethods, variables, authentication_methods, logger: nil
      Severity: Minor
      Found in lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb - About 35 mins to fix

        Method start_service has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def start_service io, logger=nil
          require 'etc'
        
          begin
            require 'hrr_rb_ssh'
        Severity: Minor
        Found in demo/more_flexible_auth.rb - About 35 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 receive_version has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def receive_version
              str_io = StringIO.new
              loop do
                str_io.write @io.read(1)
                if str_io.string[-2..-1] == "#{CR}#{LF}"
        Severity: Minor
        Found in lib/hrr_rb_ssh/transport.rb - About 35 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 start_service has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def start_service io, logger=nil
          require 'etc'
        
          begin
            require 'hrr_rb_ssh'
        Severity: Minor
        Found in demo/multi_step_auth.rb - About 35 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 encode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.encode arg
                unless arg.kind_of? ::Integer
                  raise ArgumentError, "must be a kind of Integer, but got #{arg.inspect}"
                end
                bn = ::OpenSSL::BN.new(arg)
        Severity: Minor
        Found in lib/hrr_rb_ssh/data_types/mpint.rb - About 35 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 exec has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def exec command, pty: false, env: {}
              log_info { "start exec: #{command}" }
              begin
                log_info { "Opning channel" }
                channel = @connection.request_channel_open "session"
        Severity: Minor
        Found in lib/hrr_rb_ssh/client.rb - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

                  begin
                    t.join if t.instance_of? Thread
                  rescue => e
                    log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
                  end
        Severity: Minor
        Found in lib/hrr_rb_ssh/connection/channel.rb and 1 other location - About 30 mins to fix
        lib/hrr_rb_ssh/connection/channel.rb on lines 145..149

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

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

                if channel
                  log_info { "closing channel IOs" }
                  channel.io.each{ |io| io.close rescue nil }
                  log_info { "channel IOs closed" }
                  log_info { "closing channel" }
        Severity: Major
        Found in lib/hrr_rb_ssh/client.rb and 3 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/client.rb on lines 124..132
        lib/hrr_rb_ssh/client.rb on lines 157..165
        lib/hrr_rb_ssh/client.rb on lines 188..196

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

        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

                  begin
                    t.join if t.instance_of? Thread
                  rescue => e
                    log_error { [e.backtrace[0], ": ", e.message, " (", e.class.to_s, ")\n\t", e.backtrace[1..-1].join("\n\t")].join }
                  end
        Severity: Minor
        Found in lib/hrr_rb_ssh/connection/channel.rb and 1 other location - About 30 mins to fix
        lib/hrr_rb_ssh/connection/channel.rb on lines 96..100

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

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

                if channel
                  log_info { "closing channel IOs" }
                  channel.io.each{ |io| io.close rescue nil }
                  log_info { "channel IOs closed" }
                  log_info { "closing channel" }
        Severity: Major
        Found in lib/hrr_rb_ssh/client.rb and 3 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/client.rb on lines 124..132
        lib/hrr_rb_ssh/client.rb on lines 157..165
        lib/hrr_rb_ssh/client.rb on lines 215..223

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

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

                if channel
                  log_info { "closing channel IOs" }
                  channel.io.each{ |io| io.close rescue nil }
                  log_info { "channel IOs closed" }
                  log_info { "closing channel" }
        Severity: Major
        Found in lib/hrr_rb_ssh/client.rb and 3 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/client.rb on lines 157..165
        lib/hrr_rb_ssh/client.rb on lines 188..196
        lib/hrr_rb_ssh/client.rb on lines 215..223

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

        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

          auth_password = HrrRbSsh::Authentication::Authenticator.new { |context|
            user_and_pass = [
              ['user1',  'password1'],
              ['user2',  'password2'],
            ]
        Severity: Minor
        Found in demo/multi_step_auth.rb and 1 other location - About 30 mins to fix
        demo/more_flexible_auth.rb on lines 34..44

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

        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

          auth_password = HrrRbSsh::Authentication::Authenticator.new { |context|
            user_and_pass = [
              ['user1',  'password1'],
              ['user2',  'password2'],
            ]
        Severity: Minor
        Found in demo/more_flexible_auth.rb and 1 other location - About 30 mins to fix
        demo/multi_step_auth.rb on lines 29..39

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

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

                if channel
                  log_info { "closing channel IOs" }
                  channel.io.each{ |io| io.close rescue nil }
                  log_info { "channel IOs closed" }
                  log_info { "closing channel" }
        Severity: Major
        Found in lib/hrr_rb_ssh/client.rb and 3 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/client.rb on lines 124..132
        lib/hrr_rb_ssh/client.rb on lines 188..196
        lib/hrr_rb_ssh/client.rb on lines 215..223

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

        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

            def channel_extended_data payload
              log_info { 'received ' + Messages::SSH_MSG_CHANNEL_EXTENDED_DATA::ID }
              message = Messages::SSH_MSG_CHANNEL_EXTENDED_DATA.new(logger: logger).decode payload
              local_channel = message[:'recipient channel']
              @channels[local_channel].receive_message_queue.enq message if @channels.has_key? local_channel
        Severity: Major
        Found in lib/hrr_rb_ssh/connection.rb and 4 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/connection.rb on lines 219..223
        lib/hrr_rb_ssh/connection.rb on lines 226..230
        lib/hrr_rb_ssh/connection.rb on lines 233..237
        lib/hrr_rb_ssh/connection.rb on lines 247..251

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

        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

            def channel_eof payload
              log_info { 'received ' + Messages::SSH_MSG_CHANNEL_EOF::ID }
              message = Messages::SSH_MSG_CHANNEL_EOF.new(logger: logger).decode payload
              local_channel = message[:'recipient channel']
              @channels[local_channel].receive_message_queue.enq message if @channels.has_key? local_channel
        Severity: Major
        Found in lib/hrr_rb_ssh/connection.rb and 4 other locations - About 30 mins to fix
        lib/hrr_rb_ssh/connection.rb on lines 219..223
        lib/hrr_rb_ssh/connection.rb on lines 226..230
        lib/hrr_rb_ssh/connection.rb on lines 233..237
        lib/hrr_rb_ssh/connection.rb on lines 240..244

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

        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

        Severity
        Category
        Status
        Source
        Language