adam-26/tag-messageformat

View on GitHub

Showing 33 of 33 total issues

Function exports has 206 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        clean: {
Severity: Major
Found in Gruntfile.js - About 1 day to fix

    Function _format has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    MessageFormat.prototype._format = function (pattern, values, builderCtx, builderFactory) {
        var builder = builderFactory(builderCtx);
        var i, len, part, id, value;
    
        for (i = 0, len = pattern.length; i < len; i += 1) {
    Severity: Minor
    Found in src/core.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 compileArgument has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Compiler.prototype.compileArgument = function (element) {
        if (existsIn(this.tagNames, element.id)) {
            throw new Error('Message has conflicting argument and tag name "' + element.id + '".');
        }
    
    
    Severity: Minor
    Found in src/compiler.js - About 1 hr to fix

      Function MessageFormat has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function MessageFormat(message, locales, formats, opts) {
          // Parse string messages into an AST.
          var ast = typeof message === 'string' ?
                  MessageFormat.__parse(message) : message;
      
      
      Severity: Minor
      Found in src/core.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 pluralRuleFunction has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export default {"locale":"en","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}};
      Severity: Minor
      Found in src/en.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 _format has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      MessageFormat.prototype._format = function (pattern, values, builderCtx, builderFactory) {
          var builder = builderFactory(builderCtx);
          var i, len, part, id, value;
      
          for (i = 0, len = pattern.length; i < len; i += 1) {
      Severity: Minor
      Found in src/core.js - About 1 hr to fix

        Function MessageFormat has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function MessageFormat(message, locales, formats, opts) {
            // Parse string messages into an AST.
            var ast = typeof message === 'string' ?
                    MessageFormat.__parse(message) : message;
        
        
        Severity: Minor
        Found in src/core.js - About 1 hr to fix

          Function append has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          ArrayBuilder.prototype.append = function (element) {
              if (typeof element === 'undefined' || element === null) {
                  return;
              }
          
          
          Severity: Minor
          Found in src/messageBuilders.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 compileMessage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Compiler.prototype.compileMessage = function (ast) {
              if (!(ast && ast.type === 'messageFormatPattern')) {
                  throw new Error('Message AST is not of type: "messageFormatPattern"');
              }
          
          
          Severity: Minor
          Found in src/compiler.js - About 1 hr to fix

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

                    case 'dateFormat':
                        options = formats.date[format.style];
                        return {
                            id    : element.id,
                            format: new Intl.DateTimeFormat(locales, options).format
            Severity: Major
            Found in src/compiler.js and 2 other locations - About 55 mins to fix
            src/compiler.js on lines 111..116
            src/compiler.js on lines 125..130

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

            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

                    case 'timeFormat':
                        options = formats.time[format.style];
                        return {
                            id    : element.id,
                            format: new Intl.DateTimeFormat(locales, options).format
            Severity: Major
            Found in src/compiler.js and 2 other locations - About 55 mins to fix
            src/compiler.js on lines 111..116
            src/compiler.js on lines 118..123

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

            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

                    case 'numberFormat':
                        options = formats.number[format.style];
                        return {
                            id    : element.id,
                            format: new Intl.NumberFormat(locales, options).format
            Severity: Major
            Found in src/compiler.js and 2 other locations - About 55 mins to fix
            src/compiler.js on lines 118..123
            src/compiler.js on lines 125..130

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

            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 extend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export function extend(obj) {
                var sources = Array.prototype.slice.call(arguments, 1),
                    i, len, source, key;
            
                for (i = 0, len = sources.length; i < len; i += 1) {
            Severity: Minor
            Found in src/utils.js - About 45 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 _resolveLocale has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            MessageFormat.prototype._resolveLocale = function (locales) {
                if (typeof locales === 'string') {
                    locales = [locales];
                }
            
            
            Severity: Minor
            Found in src/core.js - About 45 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 PluralFormat has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
            Severity: Minor
            Found in src/compiler.js - About 35 mins to fix

              Function _compilePattern has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn, opts) {
              Severity: Minor
              Found in src/core.js - About 35 mins to fix

                minimatch Regular Expression Denial of Service
                Open

                        "minimatch": {
                          "version": "0.3.0",
                          "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz",
                          "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=",
                          "dev": true,
                Severity: Minor
                Found in package-lock.json by nodesecurity

                Regular Expression Denial of Service

                Overview:

                Minimatch is a minimal matching utility that works by converting glob expressions into JavaScript RegExp objects. The primary function, minimatch(path, pattern) is vulnerable to ReDoS in the pattern parameter. This is because of the regular expression on line 521 of minimatch.js: /((?:\\{2})*)(\\?)\|/g,. The problematic portion of the regex is ((?:\\{2})*) which matches against \\.

                A proof of concept is as follows: ``` var minimatch = require(“minimatch”);

                // utility function for generating long strings var genstr = function (len, chr) { var result = “”; for (i=0; i<=len; i++) { result = result + chr; } return result; }

                var exploit = “[!” + genstr(1000000, “\”) + “A”;

                // minimatch exploit. console.log(“starting minimatch”); minimatch(“foo”, exploit); console.log(“finishing minimatch”); ```

                Recommendation:

                Updated to version 3.0.2 or greater

                minimatch Regular Expression Denial of Service
                Open

                        "minimatch": {
                          "version": "2.0.10",
                          "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz",
                          "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=",
                          "dev": true,
                Severity: Minor
                Found in package-lock.json by nodesecurity

                Regular Expression Denial of Service

                Overview:

                Minimatch is a minimal matching utility that works by converting glob expressions into JavaScript RegExp objects. The primary function, minimatch(path, pattern) is vulnerable to ReDoS in the pattern parameter. This is because of the regular expression on line 521 of minimatch.js: /((?:\\{2})*)(\\?)\|/g,. The problematic portion of the regex is ((?:\\{2})*) which matches against \\.

                A proof of concept is as follows: ``` var minimatch = require(“minimatch”);

                // utility function for generating long strings var genstr = function (len, chr) { var result = “”; for (i=0; i<=len; i++) { result = result + chr; } return result; }

                var exploit = “[!” + genstr(1000000, “\”) + “A”;

                // minimatch exploit. console.log(“starting minimatch”); minimatch(“foo”, exploit); console.log(“finishing minimatch”); ```

                Recommendation:

                Updated to version 3.0.2 or greater

                debug Regular Expression Denial of Service
                Open

                    "debug": {
                      "version": "2.2.0",
                      "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz",
                      "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=",
                      "dev": true,
                Severity: Minor
                Found in package-lock.json by nodesecurity

                Regular Expression Denial of Service

                Overview:

                The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the o formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.

                Recommendation:

                Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.

                growl Command Injection
                Open

                    "growl": {
                      "version": "1.9.2",
                      "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
                      "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
                      "dev": true
                Severity: Minor
                Found in package-lock.json by nodesecurity

                Command Injection

                Overview:

                Growl adds growl notification support to nodejs.

                Growl does not properly sanitize input before passing it to exec, allowing for arbitrary command execution.

                Recommendation:

                Update to version 1.10.2 or greater

                Severity
                Category
                Status
                Source
                Language