adam-26/tag-messageformat

View on GitHub
src/core.js

Summary

Maintainability
C
7 hrs
Test Coverage

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

        TODO found
        Open

            // TODO: Provide anything else?
        Severity: Minor
        Found in src/core.js by fixme

        There are no issues that match your filters.

        Category
        Status