hirura/hrr_rb_ssh

View on GitHub

Showing 169 of 169 total issues

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

          def sender_thread
            Thread.new(@socket){ |s|
              begin
                loop do
                  begin
lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb on lines 38..62

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

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 out_sender_thread
        Thread.start {
          log_info { "start out sender thread" }
          loop do
            if @r_io_out.closed?
Severity: Major
Found in lib/hrr_rb_ssh/connection/channel.rb and 1 other location - About 2 hrs to fix
lib/hrr_rb_ssh/connection/channel.rb on lines 245..267

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

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 err_sender_thread
        Thread.start {
          log_info { "start err sender thread" }
          loop do
            if @r_io_err.closed?
Severity: Major
Found in lib/hrr_rb_ssh/connection/channel.rb and 1 other location - About 2 hrs to fix
lib/hrr_rb_ssh/connection/channel.rb on lines 219..241

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

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

      def sender_thread
        Thread.start {
          log_info { "start sender thread" }
          loop do
            if @r_io_in.closed?
Severity: Minor
Found in lib/hrr_rb_ssh/connection/channel.rb - 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 out_sender_thread has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def out_sender_thread
        Thread.start {
          log_info { "start out sender thread" }
          loop do
            if @r_io_out.closed?
Severity: Minor
Found in lib/hrr_rb_ssh/connection/channel.rb - 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 err_sender_thread has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def err_sender_thread
        Thread.start {
          log_info { "start err sender thread" }
          loop do
            if @r_io_err.closed?
Severity: Minor
Found in lib/hrr_rb_ssh/connection/channel.rb - 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 sender_thread has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

          def sender_thread
            Thread.new(@socket){ |s|
              begin
                loop do
                  begin
Severity: Minor
Found in lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb - 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 sender_thread has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

          def sender_thread
            Thread.new(@socket){ |s|
              begin
                loop do
                  begin
Severity: Minor
Found in lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb - 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 initialize has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def initialize
          @proc = Proc.new { |context|
            ptm = context.vars[:ptm]
            pts = context.vars[:pts]

    Method channel_loop_thread has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def channel_loop_thread
            Thread.start do
              log_info { "start channel loop thread" }
              begin
                loop do
    Severity: Major
    Found in lib/hrr_rb_ssh/connection/channel.rb - About 2 hrs to fix

      Method exec! has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def exec! command, pty: false, env: {}
            log_info { "start exec!: #{command}" }
            out_buf = StringIO.new
            err_buf = StringIO.new
            begin
      Severity: Major
      Found in lib/hrr_rb_ssh/client.rb - About 2 hrs to fix

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

        def start_service io, logger=nil
          require 'etc'
        
          begin
            require 'hrr_rb_ssh'
        Severity: Major
        Found in demo/more_flexible_auth.rb - About 2 hrs to fix

          Method initialize has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def initialize
                    @proc = Proc.new { |context|
                      ptm = context.vars[:ptm]
                      pts = context.vars[:pts]
          
          

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

                      def receiver_thread
                        Thread.new(@socket){ |s|
                          begin
                            loop do
                              begin
            lib/hrr_rb_ssh/connection/channel/channel_type/direct_tcpip.rb on lines 71..94

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

            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

                      def receiver_thread
                        Thread.new(@socket){ |s|
                          begin
                            loop do
                              begin
            lib/hrr_rb_ssh/connection/channel/channel_type/forwarded_tcpip.rb on lines 67..90

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

            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 receive has 45 lines of code (exceeds 25 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

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

                Method respond_to_authentication has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def respond_to_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}" }
                      loop do
                        payload = @transport.receive
                Severity: Minor
                Found in lib/hrr_rb_ssh/authentication.rb - About 1 hr to fix

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

                      def respond_to_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}" }
                        loop do
                          payload = @transport.receive
                  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

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

                                begin
                                  pid, status = Process.waitpid2 pid
                                  context.log_info { "shell exited with status #{status.inspect}" }
                                  status.exitstatus
                                ensure
                  lib/hrr_rb_ssh/connection/request_handler/reference_exec_request_handler.rb on lines 53..70

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language