Showing 20 of 38 total issues
Function from
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
async from(format, {keys, suite, mode}){
// assertion
if((mode.indexOf('encrypt') >= 0 && mode.indexOf('verify') >= 0)
|| (mode.indexOf('encrypt') >= 0 && mode.indexOf('decrypt') >= 0)
|| (mode.indexOf('decrypt') >= 0 && mode.indexOf('sign') >= 0)
- 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 decrypt
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
static async decrypt({encrypted, keys, options}) {
if (typeof encrypted.message === 'undefined') throw new Error('InvalidEncryptedMessage'); // TODO, change according to the class
if (!(encrypted.message.message instanceof Array)) throw new Error('NonArrayMessage');
const jscu = getJscu();
- 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 decrypt
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
async decrypt(){
if(this._cascadeMode !== 'decrypt') throw new Error('NotDecryptionCascade');
// export verificationKey for precedence
const verificationKeys = this._orgKeys.keys.publicKeys;
- 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 decrypt
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async decrypt({encrypted, keys, options}) {
if (typeof encrypted.message === 'undefined') throw new Error('InvalidEncryptedMessage'); // TODO, change according to the class
if (!(encrypted.message.message instanceof Array)) throw new Error('NonArrayMessage');
const jscu = getJscu();
Function _init
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_init({mode, keys, procedure, encrypted}){
// assertions
if (modes.indexOf(mode) < 0) throw new Error('InvalidMode');
if (!(keys instanceof Keys)) throw new Error('NotKeyObject');
if (keys.mode.indexOf(mode) < 0) throw new Error('UnmatchedKeyMode');
- 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 encrypt
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
static async encrypt({message, keys, options}) {
const jscu = getJscu();
// check options
if(typeof options === 'undefined') options = {};
- 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 encrypt
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async encrypt({message, keys, options}) {
const jscu = getJscu();
// check options
if(typeof options === 'undefined') options = {};
Consider simplifying this complex logical expression. Open
if((mode.indexOf('encrypt') >= 0 && mode.indexOf('verify') >= 0)
|| (mode.indexOf('encrypt') >= 0 && mode.indexOf('decrypt') >= 0)
|| (mode.indexOf('decrypt') >= 0 && mode.indexOf('sign') >= 0)
|| (mode.indexOf('sign') >= 0 && mode.indexOf('verify') >= 0)
) throw new Error('InvalidMode');
Function _initEncryptionProcedure
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _initEncryptionProcedure(){
// export signingKey for precedence
const signingKeys = this._orgKeys.keys.privateKeys;
const precedence = this.slice(0, this.length -1);
Function from
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async from(format, {keys, suite, mode}){
// assertion
if((mode.indexOf('encrypt') >= 0 && mode.indexOf('verify') >= 0)
|| (mode.indexOf('encrypt') >= 0 && mode.indexOf('decrypt') >= 0)
|| (mode.indexOf('decrypt') >= 0 && mode.indexOf('sign') >= 0)
Function generateKey
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static async generateKey({params, passphrase=null, encryptOptions={}}) {
const jscu = getJscu();
if (params.type === 'session') {
if (!params.length) throw new Error('params.length must be specified');
- 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 decrypt
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async decrypt(){
if(this._cascadeMode !== 'decrypt') throw new Error('NotDecryptionCascade');
// export verificationKey for precedence
const verificationKeys = this._orgKeys.keys.publicKeys;
Function verify
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async verify({message, signature, keys, options}){
if(!keys.publicKeys) throw new Error('JscuInvalidVerificationKeys');
const jscu = getJscu();
Function createCascadedData
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const createCascadedData = (data) => {
// assertion
if (!(data instanceof Array)) throw new Error('NotArrayForCascadedData');
data.map( (obj) => {
if(typeof obj.message !== 'undefined' && !(obj.message instanceof EncryptedMessage)) throw new Error('InvalidEncryptedMessage');
- 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 encrypt
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const encrypt = async ({message, keys, config}) => {
// assertion
if (typeof config.encrypt === 'undefined') throw new Error('InvalidConfigForEncryption');
if (!keys.canEncrypt()) throw new Error('UnsupportedKeyForEncryption');
- 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
Consider simplifying this complex logical expression. Open
if (
this.constructor.generateKey === undefined ||
this.constructor.encrypt === undefined ||
this.constructor.decrypt === undefined ||
this.constructor.sign === undefined ||
Function importCascadedBuffer
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const importCascadedBuffer = (serialized) => {
if (!(serialized instanceof Uint8Array)) throw new Error('NonUint8ArraySerializedData');
let des;
try {
des = msgpack.decode(serialized);
- 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 generateKey
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const generateKey = async (keyParams) => {
const keyObj = await generateKeyObject(keyParams);
// formatting
if (keyParams.keyParams.type === 'session') {
- 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 decrypt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const decrypt = async ({data, keys}) => {
if(typeof data.message === 'undefined') throw new Error('InvalidEncryptedDataFormat');
if(!keys.canDecrypt()) throw new Error('UnsupportedKeyForDecryption');
// do decryption
- 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 importEncryptedBuffer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const importEncryptedBuffer = (serialized) => {
if (!(serialized instanceof Uint8Array)) throw new Error('NonUint8ArraySerializedData');
let des;
try {
des = msgpack.decode(serialized);
- 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"