Showing 31 of 107 total issues
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;
- Read upRead up
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 10 (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" },
- Read upRead up
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 exploreAsn1
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function exploreAsn1(buffer: Buffer) {
console.log(hexDump(buffer));
function dump(offset: number, depth: number) {
const blockInfo = readTag(buffer, offset);
- Read upRead up
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 publicEncrypt_long
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
buffer: Buffer,
publicKey: KeyLike,
blockSize: number,
padding?: number,
paddingAlgorithm?: PaddingAlgorithm
Function toStringInternal
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public toStringInternal(sep: string): string {
// https://reference.opcfoundation.org/v104/GDS/docs/7.6.4/
// The format of the subject name is a sequence of name value pairs separated by a ‘/’.
// The name shall be one of ‘CN’, ‘O’, ‘OU’, ‘DC’, ‘L’, ‘S’ or ‘C’ and
// shall be followed by a ‘=’ and then followed by the value.
- Read upRead up
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 toPem2
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function toPem2(raw_key: Buffer | string | KeyObject | PrivateKey, pem: string): string {
if ((raw_key as PrivateKey).hidden) {
return toPem2((raw_key as PrivateKey).hidden, pem);
}
assert(raw_key, "expecting a key");
- Read upRead up
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
Avoid too many return
statements within this function. Open
return {
status: "Good",
reason: `certificate chain is valid(length = ${certificateChain.length})`,
};
Avoid too many return
statements within this function. Open
return {
status: "BadCertificateInvalid",
reason: "subjectKeyIdentifier authorityKeyIdentifier in child certificate do not match subjectKeyIdentifier of parent certificate",
};
Function toPem
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function toPem(raw_key: Buffer | string, pem: string): string {
assert(raw_key, "expecting a key");
assert(typeof pem === "string");
let pemType = identifyPemType(raw_key);
if (pemType) {
- Read upRead up
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 parseBitString
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function parseBitString(buffer: Buffer, start: number, end: number, maxLength: number): string {
const unusedBit = buffer.readUInt8(start),
lenBit = ((end - start - 1) << 3) - unusedBit,
intro = "(" + lenBit + " bit)\n";
- Read upRead up
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 _coercePrivateKey
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export async function _coercePrivateKey(privateKey: any): Promise<KeyObject> {
const KeyObject = (crypto as any).KeyObject;
if (privateKey instanceof Buffer) {
const privateKey1 = await derToPrivateKey(privateKey); //
return KeyObject.from(privateKey1);
- Read upRead up
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"