cchandler/certificate_authority

View on GitHub
lib/certificate_authority/certificate.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      There are no issues that match your filters.

      Category
      Status