thekuwayama/tttls1.3

View on GitHub

Showing 96 of 96 total issues

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

      Method accept has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
      Open

          def accept
            @transcript = Transcript.new
            key_schedule = nil # TTTLS13::KeySchedule
            priv_key = nil # OpenSSL::PKey::$Object
            hs_wcipher = nil # TTTLS13::Cryptograph::$Object
      Severity: Minor
      Found in lib/tttls1.3/server.rb - About 1 day 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 accept has 167 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def accept
            @transcript = Transcript.new
            key_schedule = nil # TTTLS13::KeySchedule
            priv_key = nil # OpenSSL::PKey::$Object
            hs_wcipher = nil # TTTLS13::Cryptograph::$Object
      Severity: Major
      Found in lib/tttls1.3/server.rb - About 6 hrs to fix

        File server.rb has 438 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module TTTLS13
          using Refinements
        
          module ServerState
            # initial value is 0, eof value is -1
        Severity: Minor
        Found in lib/tttls1.3/server.rb - About 6 hrs to fix

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

            class KeySchedule
              # @param psk [String]
              # @param shared_secret [String]
              # @param cipher_suite [TTTLS13::CipherSuite]
              # @param transcript [TTTLS13::Transcript]
          Severity: Minor
          Found in lib/tttls1.3/key_schedule.rb - About 5 hrs 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

              Class Server has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Server
                  include Logging
              
                  attr_reader :transcript
              
              
              Severity: Minor
              Found in lib/tttls1.3/server.rb - About 3 hrs to fix

                File ech.rb has 288 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module TTTLS13
                  using Refinements
                
                  SUPPORTED_ECHCONFIG_VERSIONS = ["\xfe\x0d"].freeze
                  private_constant :SUPPORTED_ECHCONFIG_VERSIONS
                Severity: Minor
                Found in lib/tttls1.3/ech.rb - About 2 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 deserialize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def self.deserialize(binary)
                            raise Error::ErrorAlerts, :internal_error if binary.nil?
                            return nil if binary.length < 2
                  
                            pskids_len = Convert.bin2i(binary.slice(0, 2))
                  Severity: Minor
                  Found in lib/tttls1.3/message/extension/pre_shared_key.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 deserialize_extension has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def deserialize_extension(binary, extension_type, msg_type)
                            raise Error::ErrorAlerts, :internal_error if binary.nil?
                  
                            case extension_type
                            when ExtensionType::SERVER_NAME
                  Severity: Minor
                  Found in lib/tttls1.3/message/extensions.rb - About 2 hrs to fix

                    Method obj2html has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def obj2html(obj)
                            if obj.is_a?(OpenSSL::X509::Certificate)
                              obj.to_pem.gsub("\n", '<br>')
                            elsif obj.is_a?(Numeric) ||
                                  obj.is_a?(TrueClass) || obj.is_a?(FalseClass)
                    Severity: Minor
                    Found in lib/tttls1.3/utils.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 recv_message has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def recv_message(receivable_ccs:, cipher:)
                          return @message_queue.shift unless @message_queue.empty?
                    
                          messages = nil
                          orig_msgs = []
                    Severity: Minor
                    Found in lib/tttls1.3/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

                    Consider simplifying this complex logical expression.
                    Open

                              raise Error::ErrorAlerts, :internal_error \
                                unless (@msg_type == HandshakeType::CLIENT_HELLO &&
                                        @key_share_entry.length >= 0 &&
                                        @key_share_entry.all?(&:valid_key_share_client_hello?)) ||
                                       (@msg_type == HandshakeType::SERVER_HELLO &&
                    Severity: Critical
                    Found in lib/tttls1.3/message/extension/key_share.rb - About 1 hr to fix

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

                          def read(nst_process)
                            # secure channel has not established yet
                            raise Error::ConfigError \
                              unless (@side == :client && @state == ClientState::CONNECTED) ||
                                     (@side == :server && @state == ServerState::CONNECTED)
                      Severity: Minor
                      Found in lib/tttls1.3/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 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 deserialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def self.deserialize(binary, msg_type)
                                    raise Error::ErrorAlerts, :internal_error if binary.nil?
                          
                                    case msg_type
                                    when HandshakeType::CLIENT_HELLO
                          Severity: Minor
                          Found in lib/tttls1.3/message/extension/key_share.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

                          Severity
                          Category
                          Status
                          Source
                          Language