junkurihara/cascade

View on GitHub

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)
Severity: Minor
Found in src/keys.js - About 5 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 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 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;
Severity: Minor
Found in src/cascade.js - About 2 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 _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');
    Severity: Minor
    Found in src/cascade.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 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

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

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

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

              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

                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');
                Severity: Minor
                Found in src/cascaded_data.js - About 55 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

                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');
                
                
                Severity: Minor
                Found in src/core.js - About 55 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

                Consider simplifying this complex logical expression.
                Open

                    if (
                      this.constructor.generateKey === undefined ||
                      this.constructor.encrypt === undefined ||
                      this.constructor.decrypt === undefined ||
                      this.constructor.sign === undefined ||
                Severity: Major
                Found in src/suite.js - About 40 mins to fix

                  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);
                  Severity: Minor
                  Found in src/cascaded_data.js - About 35 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

                  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') {
                  Severity: Minor
                  Found in src/core.js - About 35 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

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

                  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);
                  Severity: Minor
                  Found in src/encrypted_message.js - 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

                  Severity
                  Category
                  Status
                  Source
                  Language