junkurihara/cascade

View on GitHub
src/suite_jscu.js

Summary

Maintainability
C
1 day
Test Coverage

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();

Severity: Minor
Found in src/suite_jscu.js - About 4 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

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();

Severity: Minor
Found in src/suite_jscu.js - About 1 hr to fix

    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 = {};
    Severity: Minor
    Found in src/suite_jscu.js - 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 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 = {};
    Severity: Minor
    Found in src/suite_jscu.js - About 1 hr to fix

      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');
      Severity: Minor
      Found in src/suite_jscu.js - 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 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();
      
      
      Severity: Minor
      Found in src/suite_jscu.js - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status