hirura/hrr_rb_ssh

View on GitHub

Showing 169 of 169 total issues

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

def start_service io, logger=nil
  begin
    require 'hrr_rb_ssh'
  rescue LoadError
    $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
Severity: Minor
Found in demo/subsystem_echo_server.rb - 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 2 locations. Consider refactoring.
Open

                begin
                  pid, status = Process.waitpid2 pid
                  context.log_info { "program exited with status #{status.inspect}" }
                  status.exitstatus
                ensure
lib/hrr_rb_ssh/connection/request_handler/reference_shell_request_handler.rb on lines 43..60

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

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

    def connection_loop_thread
      log_info { "start connection loop" }
      Thread.new do
        begin
          while true
Severity: Minor
Found in lib/hrr_rb_ssh/connection.rb - About 1 hr to fix

    Method connection_loop_thread has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def connection_loop_thread
          log_info { "start connection loop" }
          Thread.new do
            begin
              while true
    Severity: Minor
    Found in lib/hrr_rb_ssh/connection.rb - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method err_receiver_thread has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def err_receiver_thread
            Thread.start {
              log_info { "start err receiver thread" }
              loop do
                begin
    Severity: Minor
    Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method receiver_thread has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def receiver_thread
            Thread.start {
              log_info { "start receiver thread" }
              loop do
                begin
    Severity: Minor
    Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method receive has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def receive
          raise Error::ClosedTransport if @closed
          @receiver_monitor.synchronize do
            begin
              payload = @receiver.receive self
    Severity: Minor
    Found in lib/hrr_rb_ssh/transport.rb - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method out_receiver_thread has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def out_receiver_thread
            Thread.start {
              log_info { "start out receiver thread" }
              loop do
                begin
    Severity: Minor
    Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

    Cognitive Complexity

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

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

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

    Further reading

    Method start_service has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def start_service io, logger=nil
      begin
        require 'hrr_rb_ssh'
      rescue LoadError
        $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
    Severity: Minor
    Found in demo/subsystem_echo_server.rb - About 1 hr to fix

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

                def close
                  begin
                    if @sender_thread_finished && @receiver_thread_finished
                      log_info { "closing direct-tcpip" }
                      @socket.close
      lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb on lines 22..35

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

      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

                def close
                  begin
                    if @sender_thread_finished && @receiver_thread_finished
                      log_info { "closing forwarded-tcpip" }
                      @socket.close
      lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb on lines 26..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 63.

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

          def request_authentication
            authentication_methods = (@options['authentication_preferred_authentication_methods'].dup rescue nil) || Method.list_preferred # rescue nil.dup for Ruby version < 2.4
            log_info { "preferred authentication methods: #{authentication_methods}" }
            next_method_name = "none"
            log_info { "authentication request begins with none method" }
      Severity: Minor
      Found in lib/hrr_rb_ssh/authentication.rb - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

      Method request_authentication has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def request_authentication
            authentication_methods = (@options['authentication_preferred_authentication_methods'].dup rescue nil) || Method.list_preferred # rescue nil.dup for Ruby version < 2.4
            log_info { "preferred authentication methods: #{authentication_methods}" }
            next_method_name = "none"
            log_info { "authentication request begins with none method" }
      Severity: Minor
      Found in lib/hrr_rb_ssh/authentication.rb - About 1 hr to fix

        Method start has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def start transport
                  case transport.mode
                  when Mode::SERVER
                    message = receive_kex_dh_gex_request transport.receive
                    @min = message[:'min']

          Method receiver_thread has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def receiver_thread
                  Thread.start {
                    log_info { "start receiver thread" }
                    loop do
                      begin
          Severity: Minor
          Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

            Method start_service has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def start_service io, logger=nil
              begin
                require 'hrr_rb_ssh'
              rescue LoadError
                $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
            Severity: Minor
            Found in demo/echo_server.rb - About 1 hr to fix

              Method err_receiver_thread has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def err_receiver_thread
                      Thread.start {
                        log_info { "start err receiver thread" }
                        loop do
                          begin
              Severity: Minor
              Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

                Method out_receiver_thread has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def out_receiver_thread
                        Thread.start {
                          log_info { "start out receiver thread" }
                          loop do
                            begin
                Severity: Minor
                Found in lib/hrr_rb_ssh/connection/channel.rb - About 1 hr to fix

                  Method exec has 30 lines of code (exceeds 25 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 1 hr to fix

                    Method request_authentication has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def request_authentication username, service_name
                              message = {
                                :'message number' => Messages::SSH_MSG_USERAUTH_REQUEST::VALUE,
                                :"user name"      => username,
                                :"service name"   => service_name,
                    Severity: Minor
                    Found in lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language