adam-26/tag-messageformat

View on GitHub

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

            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

                Avoid too many return statements within this function.
                Open

                            return new SelectFormat(element.id, options);
                Severity: Major
                Found in src/compiler.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return new PluralFormat(
                                  element.id, format.ordinal, format.offset, options, pluralFn
                              );
                  Severity: Major
                  Found in src/compiler.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language