junkurihara/cascade

View on GitHub

Showing 38 of 38 total issues

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 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

        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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          try {
            des = msgpack.decode(serialized);
          } catch (e) { throw new Error(`FailedToParseEncryptedMessageBuffer: ${e.message}`); }
        Severity: Major
        Found in src/encrypted_message.js and 2 other locations - About 40 mins to fix
        src/cascaded_data.js on lines 12..14
        src/signature.js on lines 15..17

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          try {
            des = msgpack.decode(serialized);
          } catch (e) { throw new Error(`FailedToParseCascadedBuffer: ${e.message}`); }
        Severity: Major
        Found in src/cascaded_data.js and 2 other locations - About 40 mins to fix
        src/encrypted_message.js on lines 17..19
        src/signature.js on lines 15..17

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

          try {
            des = msgpack.decode(serialized);
          } catch (e) { throw new Error(`FailedToParseSignatureBuffer: ${e.message}`); }
        Severity: Major
        Found in src/signature.js and 2 other locations - About 40 mins to fix
        src/cascaded_data.js on lines 12..14
        src/encrypted_message.js on lines 17..19

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 49.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            if (!des.suite || !des.keyType || !des.message || !des.options) throw new Error('InvalidEncryptedMessageFormat');
          Severity: Minor
          Found in src/encrypted_message.js and 1 other location - About 35 mins to fix
          src/signature.js on lines 19..19

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 47.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            if (!des.suite || !des.keyType || !des.signatures || !des.options) throw new Error('InvalidSignatureFormat');
          Severity: Minor
          Found in src/signature.js and 1 other location - About 35 mins to fix
          src/encrypted_message.js on lines 21..21

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 47.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            moduleFileExtensions: [ 'js', 'jsx' ],
          Severity: Minor
          Found in jest.config.web.js and 1 other location - About 30 mins to fix
          jest.config.node.js on lines 82..82

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

            moduleFileExtensions: [ 'js', 'jsx' ],
          Severity: Minor
          Found in jest.config.node.js and 1 other location - About 30 mins to fix
          jest.config.web.js on lines 82..82

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 45.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

          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

          Severity
          Category
          Status
          Source
          Language