thekuwayama/tttls1.3

View on GitHub
lib/tttls1.3/client.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method connect has a Cognitive Complexity of 173 (exceeds 5 allowed). Consider refactoring.
Open

    def connect
      @transcript = Transcript.new
      key_schedule = nil # TTTLS13::KeySchedule
      psk = nil
      priv_keys = {} # Hash of NamedGroup => OpenSSL::PKey::$Object
Severity: Minor
Found in lib/tttls1.3/client.rb - About 3 days 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

File client.rb has 823 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module TTTLS13
  using Refinements

  module ClientState
    # initial value is 0, eof value is -1
Severity: Major
Found in lib/tttls1.3/client.rb - About 1 day to fix

    Method connect has 298 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def connect
          @transcript = Transcript.new
          key_schedule = nil # TTTLS13::KeySchedule
          psk = nil
          priv_keys = {} # Hash of NamedGroup => OpenSSL::PKey::$Object
    Severity: Major
    Found in lib/tttls1.3/client.rb - About 1 day to fix

      Class Client has 42 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Client
          include Logging
      
          HpkeSymmetricCipherSuit = \
            ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite
      Severity: Minor
      Found in lib/tttls1.3/client.rb - About 5 hrs to fix

        Method valid_settings? has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def valid_settings?
              mod = CipherSuite
              defined_cipher_suites = mod.constants.map { |c| mod.const_get(c) }
              return false \
                unless (@settings[:cipher_suites] - defined_cipher_suites).empty?
        Severity: Minor
        Found in lib/tttls1.3/client.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 send_client_hello has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def send_client_hello(extensions, binder_key = nil)
              ch = Message::ClientHello.new(
                cipher_suites: CipherSuites.new(@settings[:cipher_suites]),
                extensions: extensions
              )
        Severity: Minor
        Found in lib/tttls1.3/client.rb - About 1 hr to fix

          Method gen_ch_extensions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def gen_ch_extensions
                exs = Message::Extensions.new
                # server_name
                exs << Message::Extension::ServerName.new(@hostname)
          
          
          Severity: Minor
          Found in lib/tttls1.3/client.rb - About 1 hr to fix

            Method send_new_client_hello has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def send_new_client_hello(ch1,
                                          hrr,
                                          extensions,
                                          binder_key = nil,
                                          ech_state = nil)
            Severity: Minor
            Found in lib/tttls1.3/client.rb - About 1 hr to fix

              Method sign_grease_psk_binder has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def sign_grease_psk_binder(ch1: nil,
                                             hrr: nil,
                                             ch_outer:,
                                             inner_psk:,
                                             binder_key:)
              Severity: Minor
              Found in lib/tttls1.3/client.rb - About 1 hr to fix

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

                    def gen_ch_extensions
                      exs = Message::Extensions.new
                      # server_name
                      exs << Message::Extension::ServerName.new(@hostname)
                
                
                Severity: Minor
                Found in lib/tttls1.3/client.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 check_invalid_certificate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def check_invalid_certificate(ct, ch)
                      return :illegal_parameter unless ct.appearable_extensions?
                
                      return :unsupported_extension \
                        unless ct.certificate_list.map(&:extensions)
                Severity: Minor
                Found in lib/tttls1.3/client.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 softfail_check_certificate_status has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.softfail_check_certificate_status(res, cert, chain)
                      ocsp_response = res
                      cid = OpenSSL::OCSP::CertificateId.new(cert, chain.first)
                
                      # When NOT received OCSPResponse in TLS handshake, this method will
                Severity: Minor
                Found in lib/tttls1.3/client.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 send_new_client_hello has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def send_new_client_hello(ch1,
                                              hrr,
                                              extensions,
                                              binder_key = nil,
                                              ech_state = nil)
                Severity: Minor
                Found in lib/tttls1.3/client.rb - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return false if @settings[:check_certificate_status] &&
                  Severity: Major
                  Found in lib/tttls1.3/client.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return false \
                    Severity: Major
                    Found in lib/tttls1.3/client.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return false if !rsl.nil? && (rsl < 64 || rsl > 2**14 + 1)
                      Severity: Major
                      Found in lib/tttls1.3/client.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return false if !@settings[:ech_config].nil? && ehcs.empty?
                        Severity: Major
                        Found in lib/tttls1.3/client.rb - About 30 mins to fix

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

                              def send_new_client_hello(ch1,
                                                        hrr,
                                                        extensions,
                                                        binder_key = nil,
                                                        ech_state = nil)
                          Severity: Minor
                          Found in lib/tttls1.3/client.rb - 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

                          There are no issues that match your filters.

                          Category
                          Status