clay/handlebars

View on GitHub

Showing 112 of 113 total issues

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

  it('returns random 8 character string', function () {
    expect(hbs.compile('{{ randomString }}')().length).to.equal(8);
  });
Severity: Minor
Found in helpers/strings/randomString.test.js and 1 other location - About 35 mins to fix
helpers/strings/randomString.test.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 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 3 locations. Consider refactoring.
Open

  it('should replace the string with "" if `b` is undefined', function () {
    expect(tpl({str: 'a b c', a: 'a'})).to.equal(' b c');
  });
Severity: Minor
Found in helpers/strings/replace.test.js and 2 other locations - About 35 mins to fix
helpers/misc/indexOf.test.js on lines 14..16
helpers/strings/concat.test.js on lines 6..8

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

  it('always rounds up when given the option "up"', function () {
    expect(tpl({x: 1.01, direction: 'up'})).to.equal('2');
  });
Severity: Minor
Found in helpers/numbers/round.test.js and 1 other location - About 35 mins to fix
helpers/numbers/round.test.js on lines 31..33

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

  it('allows alternate lengths without a prefix', function () {
    expect(hbs.compile('{{ randomString characters=1 }}')().length).to.equal(1);
  });
Severity: Minor
Found in helpers/strings/randomString.test.js and 1 other location - About 35 mins to fix
helpers/strings/randomString.test.js on lines 5..7

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 8 locations. Consider refactoring.
Open

  it('shortens strings longer than given length', function () {
    expect(tpl({str: 'foo bar bar', len: 5})).to.equal('foo b…');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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 3 locations. Consider refactoring.
Open

  it('concats two strings', function () {
    expect(tpl({a: 'a', b: 'b'})).to.equal('ab');
  });
Severity: Minor
Found in helpers/strings/concat.test.js and 2 other locations - About 35 mins to fix
helpers/misc/indexOf.test.js on lines 14..16
helpers/strings/replace.test.js on lines 19..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

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

  it('finds substring within string', function () {
    expect(tpl({a: 'foo', b: 'f'})).to.be.ok;
  });
Severity: Minor
Found in helpers/strings/includes.test.js and 1 other location - About 35 mins to fix
helpers/strings/includes.test.js on lines 30..32

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 8 locations. Consider refactoring.
Open

  it('trims whitespace when non-whitespace string is shorter than given length', function () {
    expect(tpl({str: '  foo  ', len: 5})).to.equal('foo');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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 8 locations. Consider refactoring.
Open

  it('trims whitespace after truncating', function () {
    expect(tpl({str: 'foo bar bar', len: 4})).to.equal('foo…');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 40..42

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 8 locations. Consider refactoring.
Open

  it('accepts a suffix to append', function () {
    expect(tplSuffix({str: 'foo bar bar', len: 5})).to.equal('foo b TBC');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38

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 8 locations. Consider refactoring.
Open

  it('trims whitespace when entire string is shorter than given length', function () {
    expect(tpl({str: ' fo ', len: 5})).to.equal('fo');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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 8 locations. Consider refactoring.
Open

  it('does not change strings shorter than given length', function () {
    expect(tpl({str: 'foo', len: 5})).to.equal('foo');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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 8 locations. Consider refactoring.
Open

  it('trims whitespace where non-whitespace string is longer than given length', function () {
    expect(tpl({str: ' foo bar bar ', len: 5})).to.equal('foo b…');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 16..18
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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 3 locations. Consider refactoring.
Open

  it('finds indexes in strings', function () {
    expect(tpl({a: 'foo', b: 'f'})).to.equal('0');
  });
Severity: Minor
Found in helpers/misc/indexOf.test.js and 2 other locations - About 35 mins to fix
helpers/strings/concat.test.js on lines 6..8
helpers/strings/replace.test.js on lines 19..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

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

  it('does not change strings equal to given length', function () {
    expect(tpl({str: 'fooba', len: 5})).to.equal('fooba');
  });
Severity: Major
Found in helpers/strings/truncate.test.js and 7 other locations - About 35 mins to fix
helpers/strings/truncate.test.js on lines 12..14
helpers/strings/truncate.test.js on lines 20..22
helpers/strings/truncate.test.js on lines 24..26
helpers/strings/truncate.test.js on lines 28..30
helpers/strings/truncate.test.js on lines 32..34
helpers/strings/truncate.test.js on lines 36..38
helpers/strings/truncate.test.js on lines 40..42

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

  it('always rounds down when given the option "down"', function () {
    expect(tpl({x: 1.99, direction: 'down'})).to.equal('1');
  });
Severity: Minor
Found in helpers/numbers/round.test.js and 1 other location - About 35 mins to fix
helpers/numbers/round.test.js on lines 27..29

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

  it('returns empty if substring is not found', function () {
    expect(tpl({a: 'foo', b: 'p'})).to.be.empty;
  });
Severity: Minor
Found in helpers/strings/includes.test.js and 1 other location - About 35 mins to fix
helpers/strings/includes.test.js on lines 26..28

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

module.exports = function (value, defaultValue) {
  if (_isObject(value) || _isArray(value)) {
    return !_isEmpty(value) ? value : defaultValue;
  } else {
    return !!value ? value : defaultValue;
Severity: Minor
Found in helpers/misc/default.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 exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (str, a, b) {
  if (str && typeof str === 'string') {
    if (!a || typeof a !== 'string') return str;
    if (!b || typeof b !== 'string') b = '';
    return str.split(a).join(b);
Severity: Minor
Found in helpers/strings/replace.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

const name = getName(__filename),
  filterName = __filename.split('/').pop().split('.').shift(),
  filter = require('./' + filterName);
Severity: Minor
Found in helpers/components/addAnnotatedTextAria.test.js and 1 other location - About 35 mins to fix
helpers/components/filterComponents.test.js on lines 2..4

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

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

Severity
Category
Status
Source
Language