zhenkyle/shadowsocks_ruby

View on GitHub

Showing 27 of 37 total issues

Method execute! has 91 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def execute!
        # here sets default options
        options        = {
                           :port => 8388,
                           :local_addr => '0.0.0.0',
Severity: Major
Found in lib/shadowsocks_ruby/cli/sslocal_runner.rb - About 3 hrs to fix

    Method execute! has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def execute!
            # here sets default options
            options        = {
                               :server => '0.0.0.0',
                               :port => 8388,
    Severity: Major
    Found in lib/shadowsocks_ruby/cli/ssserver_runner.rb - About 3 hrs to fix

      Method bytes_to_key1 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def bytes_to_key1(salt, data, count, nkey, niv)
            key = ''
            iv = ''
            md_buf = ''
      
      
      Severity: Minor
      Found in lib/shadowsocks_ruby/cipher/cipher.rb - About 3 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 build! has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def build! conn
              cipher = nil
      
              protocols = @cfg_ary.map do | klass, params|
                case klass.to_s
      Severity: Major
      Found in lib/shadowsocks_ruby/protocols/protocol_stack.rb - About 2 hrs to fix

        File tls_ticket.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'lrucache'
        
        module ShadowsocksRuby
          module Protocols
            # TLS 1.2 Obfuscation Protocol
        Severity: Minor
        Found in lib/shadowsocks_ruby/protocols/obfs/tls_ticket.rb - About 2 hrs to fix

          Method tcp_receive_from_localbackend_first_packet has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                def tcp_receive_from_localbackend_first_packet n
                  data = async_recv 10
                  if (data =~ /^GET|^POST/) == nil
                    if @params[:compatible]
                      @buffer << data << async_recv(n - data.length)
          Severity: Minor
          Found in lib/shadowsocks_ruby/protocols/obfs/http_simple.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 recv_client_hello has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def recv_client_hello
                  data = async_recv 3
                  if data != [CTYPE_Handshake, *VERSION_TLS_1_0].pack("C3")
                    if @params[:compatible]
                      @buffer = data
          Severity: Minor
          Found in lib/shadowsocks_ruby/protocols/obfs/tls_ticket.rb - About 1 hr to fix

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

                  def recv_client_hello
                    data = async_recv 3
                    if data != [CTYPE_Handshake, *VERSION_TLS_1_0].pack("C3")
                      if @params[:compatible]
                        @buffer = data
            Severity: Minor
            Found in lib/shadowsocks_ruby/protocols/obfs/tls_ticket.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 tcp_receive_from_localbackend_first_packet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def tcp_receive_from_localbackend_first_packet n
                    # check version
                    version = async_recv(1).unpack("C").first
                    if version != SOCKS5
                      raise PharseError, "SOCKS version not supported: #{version.inspect}"
            Severity: Minor
            Found in lib/shadowsocks_ruby/protocols/packet/socks5.rb - About 1 hr to fix

              Method tcp_receive_from_client_first_packet has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def tcp_receive_from_client_first_packet n
                      # check version
                      version = async_recv(1).unpack("C").first
                      if version != SOCKS5
                        raise PharseError, "SOCKS version not supported: #{version.inspect}"
              Severity: Minor
              Found in lib/shadowsocks_ruby/protocols/packet/socks5.rb - About 1 hr to fix

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

                      def tcp_send_to_remoteserver_first_packet data
                        if data.length > 30 + 64
                          headlen = 30 + Random.rand(64 + 1)
                        else
                          headlen = data.length
                Severity: Minor
                Found in lib/shadowsocks_ruby/protocols/obfs/http_simple.rb - About 1 hr to fix

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

                        def send_client_hello
                          client_hello = ""
                          
                          client_hello << [*VERSION_TLS_1_2].pack("C2") # ProtocolVersion
                          client_hello << get_random # Random len 32
                  Severity: Minor
                  Found in lib/shadowsocks_ruby/protocols/obfs/tls_ticket.rb - About 1 hr to fix

                    Method execute! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def execute!
                            # here sets default options
                            options        = {
                                               :port => 8388,
                                               :local_addr => '0.0.0.0',
                    Severity: Minor
                    Found in lib/shadowsocks_ruby/cli/sslocal_runner.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 initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def initialize
                          @options = @@options
                    
                          @totalcounter = 0
                          @maxcounter = 0
                    Severity: Minor
                    Found in lib/shadowsocks_ruby/app.rb - About 1 hr to fix

                      Method tcp_receive_from_localbackend_first_packet has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def tcp_receive_from_localbackend_first_packet n
                              data = async_recv 10
                              if (data =~ /^GET|^POST/) == nil
                                if @params[:compatible]
                                  @buffer << data << async_recv(n - data.length)
                      Severity: Minor
                      Found in lib/shadowsocks_ruby/protocols/obfs/http_simple.rb - About 1 hr to fix

                        Method execute! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def execute!
                                # here sets default options
                                options        = {
                                                   :server => '0.0.0.0',
                                                   :port => 8388,
                        Severity: Minor
                        Found in lib/shadowsocks_ruby/cli/ssserver_runner.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 tcp_send_to_remoteserver_first_packet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def tcp_send_to_remoteserver_first_packet data
                                if data.length > 30 + 64
                                  headlen = 30 + Random.rand(64 + 1)
                                else
                                  headlen = data.length
                        Severity: Minor
                        Found in lib/shadowsocks_ruby/protocols/obfs/http_simple.rb - About 55 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 pressure_control has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def pressure_control
                                @plexer ||= nil
                                if @plexer != nil
                                  if get_outbound_data_size >= PressureLevel
                                    @plexer.pause unless @plexer.paused?
                        Severity: Minor
                        Found in lib/shadowsocks_ruby/connections/connection.rb - About 55 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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def initialize
                              @options = @@options
                        
                              @totalcounter = 0
                              @maxcounter = 0
                        Severity: Minor
                        Found in lib/shadowsocks_ruby/app.rb - About 55 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_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def receive_data data
                                if @fiber.alive?
                                  @buffer << data
                                  if @wait_length == -1 || @buffer.size >= @wait_length
                                    @fiber.resume
                        Severity: Minor
                        Found in lib/shadowsocks_ruby/connections/connection.rb - About 45 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