Showing 87 of 304 total issues
Function crypto_onetimeauth
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function crypto_onetimeauth (out: Uint8Array, outpos: number, m: Uint8Array, mpos: number, n: number, k: Uint8Array): number {
Function u8aToU8a
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function u8aToU8a (value?: U8aLike | null): Uint8Array {
return isU8a(value)
// NOTE isBuffer needs to go here since it actually extends
// Uint8Array on Node.js environments, so all Buffer are Uint8Array,
// but Uint8Array is not Buffer
- 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 deeply nested control flow statements. Open
if (u8a[i + 2] < 0x80 || u8a[i + 2] > 0xBF) {
// *message = "After a first byte of E0, expecting a 3nd byte between 80 and BF.";
// *faulty_bytes = 3;
return false;
}
Avoid deeply nested control flow statements. Open
if (i + 2 < len) /* Expect a 2nd and 3rd byte */ {
if (u8a[i + 1] < 0x80 || u8a[i + 1] > 0xBF) {
// *message = "After a first byte between E1 and EC, expecting the 2nd byte between 80 and BF.";
// *faulty_bytes = 2;
return false;
Function decodeAddress
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function decodeAddress (encoded?: string | Uint8Array | null, ignoreChecksum?: boolean, ss58Format: Prefix = -1): Uint8Array {
if (!encoded) {
throw new Error('Invalid empty address passed');
}
- 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 deeply nested control flow statements. Open
if (u8a[i + 1] < 0xA0 || u8a[i + 1] > 0xBF) {
// *message = "After a first byte of E0, expecting a 2nd byte between A0 and BF.";
// *faulty_bytes = 2;
return false;
}
Avoid deeply nested control flow statements. Open
} else if (u8a[i] === 0xED) /* ED 80..9F 80..BF */ {
if (i + 2 < len) /* Expect a 2nd and 3rd byte */ {
if (u8a[i + 1] < 0x80 || u8a[i + 1] > 0x9F) {
// *message = "After a first byte of ED, expecting 2nd byte between 80 and 9F.";
// *faulty_bytes = 2;
Function crypto_onetimeauth_verify
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function crypto_onetimeauth_verify (h: Uint8Array, hpos: number, m: Uint8Array, mpos: number, n: number, k: Uint8Array) {
Function toU8a
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function toU8a (value: bigint, isLe: boolean, isNegative: boolean): Uint8Array {
const arr: number[] = [];
const withSigned = isNegative && (value < _0n);
if (withSigned) {
- 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 jsonDecryptData
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function jsonDecryptData (encrypted?: Uint8Array | null, passphrase?: string | null, encType: EncryptedJsonEncoding[] = ENCODING): Uint8Array {
if (!encrypted) {
throw new Error('No encrypted data available to decode');
} else if (encType.includes('xsalsa20-poly1305') && !passphrase) {
throw new Error('Password required to decode encrypted data');
- 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 secp256k1Verify
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function secp256k1Verify (msgHash: string | Uint8Array, signature: string | Uint8Array, address: string | Uint8Array, hashType: HashType = 'blake2', onlyJs?: boolean): boolean {
Function sr25519VrfVerify
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function sr25519VrfVerify (message: string | Uint8Array, signOutput: string | Uint8Array, publicKey: string | Uint8Array, context: string | Uint8Array = EMPTY_U8A, extra: string | Uint8Array = EMPTY_U8A): boolean {
Function crypto_secretbox_open
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function crypto_secretbox_open (m: Uint8Array, c: Uint8Array, d: number, n: Uint8Array, k: Uint8Array): number {
Function secp256k1Recover
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function secp256k1Recover (msgHash: string | Uint8Array, signature: string | Uint8Array, recovery: number, hashType: HashType = 'blake2', onlyJs?: boolean): Uint8Array {
Function createPair
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function createPair ({ toSS58, type }: Setup, { publicKey, secretKey }: PairInfo, meta: KeyringPair$Meta = {}, encoded: Uint8Array | null = null, encTypes?: EncryptedJsonEncoding[]): KeyringPair {
Function vn
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function vn (x: Uint8Array, xi: number, y: Uint8Array, yi: number, n: number): number {
Function lazyMethod
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function lazyMethod <T, K, S> (result: Record<string, T> | AnyFn, item: K, creator: (item: K, index: number, self: S) => T, getName?: (item: K, index: number) => string, index = 0): void {
Function objectProperty
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function objectProperty <S> (that: object, key: string, getter: (key: string, index: number, self: S) => unknown, getName?: (key: string, index: number) => string, index = 0): void {
Function core
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function core (out: Uint8Array, inp: Uint8Array, k: Uint8Array, c: Uint8Array, h: boolean): void {
Function crypto_secretbox
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function crypto_secretbox (c: Uint8Array, m: Uint8Array, d: number, n: Uint8Array, k: Uint8Array) {