node-opcua/node-opcua-crypto

View on GitHub
packages/node-opcua-crypto/source/crypto_explore_certificate.ts

Summary

Maintainability
D
2 days
Test Coverage

File crypto_explore_certificate.ts has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module node_opcua_crypto
 */
// ---------------------------------------------------------------------------------------------------------------------
// node-opcua-crypto
Severity: Minor
Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - About 7 hrs to fix

    Function readTbsCertificate has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate {
        const blocks = _readStruct(buffer, block);
    
        let version, serialNumber, signature, issuer, validity, subject, subjectFingerPrint, extensions;
        let subjectPublicKeyInfo: SubjectPublicKeyInfo;
    Severity: Major
    Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - About 2 hrs to fix

      Function _readAuthorityKeyIdentifier has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function _readAuthorityKeyIdentifier(buffer: Buffer): AuthorityKeyIdentifier {
          /**
           *  where a CA distributes its public key in the form of a "self-signed"
           *  certificate, the authority key identifier MAY be omitted.  Th
           *  signature on a self-signed certificate is generated with the private
      Severity: Minor
      Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - 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

      Function _readAuthorityKeyIdentifier has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _readAuthorityKeyIdentifier(buffer: Buffer): AuthorityKeyIdentifier {
          /**
           *  where a CA distributes its public key in the form of a "self-signed"
           *  certificate, the authority key identifier MAY be omitted.  Th
           *  signature on a self-signed certificate is generated with the private
      Severity: Minor
      Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - About 1 hr to fix

        Function _readExtension has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function _readExtension(buffer: Buffer, block: BlockInfo): { identifier: { oid: string; name: string }; value: any } {
            const inner_blocks = _readStruct(buffer, block);
        
            if (inner_blocks.length === 3) {
                assert(inner_blocks[1].tag === TagType.BOOLEAN);
        Severity: Minor
        Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - About 1 hr to fix

          Function _readGeneralNames has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _readGeneralNames(buffer: Buffer, block: BlockInfo) {
              const _data: { [key: number]: { name: string; type: string } } = {
                  1: { name: "rfc822Name", type: "IA5String" },
                  2: { name: "dNSName", type: "IA5String" },
                  3: { name: "x400Address", type: "ORAddress" },
          Severity: Minor
          Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - About 1 hr to fix

            Function readTbsCertificate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            export function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate {
                const blocks = _readStruct(buffer, block);
            
                let version, serialNumber, signature, issuer, validity, subject, subjectFingerPrint, extensions;
                let subjectPublicKeyInfo: SubjectPublicKeyInfo;
            Severity: Minor
            Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - 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

            Function _readGeneralNames has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function _readGeneralNames(buffer: Buffer, block: BlockInfo) {
                const _data: { [key: number]: { name: string; type: string } } = {
                    1: { name: "rfc822Name", type: "IA5String" },
                    2: { name: "dNSName", type: "IA5String" },
                    3: { name: "x400Address", type: "ORAddress" },
            Severity: Minor
            Found in packages/node-opcua-crypto/source/crypto_explore_certificate.ts - 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