martinheidegger/i18n-core

View on GitHub

Showing 25 of 46 total issues

Function onContextChange has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function onContextChange (type, fn) {
  if (type !== 'contextChange' || typeof fn !== 'function' || this.listener === fn) {
    return
  }
  if (this.off === noop) {
Severity: Minor
Found in lib/createNode.js - About 1 hr to fix

Function ____n has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ____n (node, singular, plural, count, namedValues, a, b, c, d, e, f, g, h, i, j) {
  var args
  if (j !== undefined) {
    args = [count, a, b, c, d, e, f, g, h, i, j]
  } else if (i !== undefined) {
Severity: Minor
Found in simple.js - About 1 hr to fix

Function _____n has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

function _____n (node, singular, plural, count, namedValues, args) {
Severity: Minor
Found in simple.js - About 45 mins to fix

Function onContextChange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function onContextChange (type, fn) {
  if (type !== 'contextChange' || typeof fn !== 'function' || this.listener === fn) {
    return
  }
  if (this.off === noop) {
Severity: Minor
Found in lib/createNode.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 mustacheSimple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  render: function mustacheSimple (value, namedValues) {
    return value.replace(/{{\s?({?[^}]*}?)\s?}}/ig, function (match, param) {
      var unescaped = /^{.*}$/.test(param)
      if (unescaped) {
        param = param.substring(1, param.length - 1)
Severity: Minor
Found in lib/mustacheSimple.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

Severity
Category
Status
Source
Language