cchandler/certificate_authority

View on GitHub

Showing 17 of 17 total issues

File extensions.rb has 469 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module CertificateAuthority
  module Extensions
    module ExtensionAPI
      def to_s
        raise "Implementation required"
Severity: Minor
Found in lib/certificate_authority/extensions.rb - About 7 hrs to fix

    Method merge_profile_with_extensions has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def merge_profile_with_extensions(signing_profile={})
          return self.extensions if signing_profile["extensions"].nil?
          signing_config = signing_profile["extensions"]
          signing_config.keys.each do |k|
            extension = self.extensions[k]
    Severity: Minor
    Found in lib/certificate_authority/certificate.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

    Class Certificate has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Certificate
        include Validations
        include Revocable
    
        attr_accessor :distinguished_name
    Severity: Minor
    Found in lib/certificate_authority/certificate.rb - About 2 hrs to fix

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

          def to_x509_name
            raise "Invalid Distinguished Name" unless valid?
      
            # NB: the capitalization in the strings counts
            name = OpenSSL::X509::Name.new
      Severity: Minor
      Found in lib/certificate_authority/distinguished_name.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate
            errors.add :base, "Distinguished name must be valid" unless distinguished_name.valid?
            errors.add :base, "Key material must be valid" unless key_material.valid?
            errors.add :base, "Serial number must be valid" unless serial_number.valid?
            errors.add :base, "Extensions must be valid" unless extensions.each do |item|
      Severity: Minor
      Found in lib/certificate_authority/certificate.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 config_extensions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def config_extensions
              config_extension = {}
              custom_policies = {}
              notice = {}
              unless self.policy_identifier.nil?
      Severity: Minor
      Found in lib/certificate_authority/extensions.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 sign! has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def sign!(signing_profile={})
            raise "Invalid certificate #{self.errors.full_messages}" unless valid?
            merge_profile_with_extensions(signing_profile)
      
            openssl_cert = OpenSSL::X509::Certificate.new
      Severity: Minor
      Found in lib/certificate_authority/certificate.rb - About 1 hr to fix

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

            def sign!(signing_profile={})
              raise "No parent entity has been set!" if self.parent.nil?
              raise "Invalid CRL" unless self.valid?
        
              revocations = self.certificates.collect do |revocable|
        Severity: Minor
        Found in lib/certificate_authority/certificate_revocation_list.rb - About 1 hr to fix

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

                def config_extensions
                  config_extension = {}
                  custom_policies = {}
                  notice = {}
                  unless self.policy_identifier.nil?
          Severity: Minor
          Found in lib/certificate_authority/extensions.rb - About 1 hr to fix

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

                def sign!(signing_profile={})
                  raise "Invalid certificate #{self.errors.full_messages}" unless valid?
                  merge_profile_with_extensions(signing_profile)
            
                  openssl_cert = OpenSSL::X509::Certificate.new
            Severity: Minor
            Found in lib/certificate_authority/certificate.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 parse has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.parse(value, critical)
                    obj = self.new
                    return obj if value.nil?
                    obj.critical = critical
                    value.split(/,\s*/).each do |v|
            Severity: Minor
            Found in lib/certificate_authority/extensions.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 to_x509_csr has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_x509_csr
                  raise "Must specify a DN/subject on csr" if @distinguished_name.nil?
                  raise "Invalid DN in request" unless @distinguished_name.valid?
                  raise "CSR must have key material" if @key_material.nil?
                  raise "CSR must include a public key on key material" if @key_material.public_key.nil?
            Severity: Minor
            Found in lib/certificate_authority/signing_request.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 advance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def advance(options)
                  options = options.dup
                  d = self
                  d = d >> options.delete(:years) * 12 if options[:years]
                  d = d >> options.delete(:months)     if options[:months]
            Severity: Minor
            Found in lib/certificate_authority/core_extensions.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

            Method initialize_engine has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize_engine
                  ## We're going to return early and try again later if params weren't passed in
                  ## at initialization.  Any attempt at getting a public/private key will try
                  ## again.
                  return false if self.openssl_pkcs11_engine_lib.nil? or self.pkcs11_lib.nil?
            Severity: Minor
            Found in lib/certificate_authority/pkcs11_key_material.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

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

                def sign!(signing_profile={})
                  raise "No parent entity has been set!" if self.parent.nil?
                  raise "Invalid CRL" unless self.valid?
            
                  revocations = self.certificates.collect do |revocable|
            Severity: Minor
            Found in lib/certificate_authority/certificate_revocation_list.rb - About 35 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 to_csr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_csr
                  csr = SigningRequest.new
                  csr.distinguished_name = self.distinguished_name
                  csr.key_material = self.key_material
                  factory = OpenSSL::X509::ExtensionFactory.new
            Severity: Minor
            Found in lib/certificate_authority/certificate.rb - About 35 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 to_cert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_cert
                  cert = Certificate.new
                  if !@distinguished_name.nil?
                    cert.distinguished_name = @distinguished_name
                  end
            Severity: Minor
            Found in lib/certificate_authority/signing_request.rb - About 35 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