HabitRPG/habitrpg

View on GitHub
test/api/unit/libs/preening.test.js

Summary

Maintainability
C
1 day
Test Coverage

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

  it('does aggregate data in monthly and yearly entries before cutoff (free users)', () => {
    const h = generateHistory(731); // Jumps to October 21 2012
    const preened = preenHistory(_.cloneDeep(h), false, 0);
    // Keeps 60 days + 11 montly entries and 2 yearly entry for 2011 and 2012
    expect(preened.length).to.eql(73);
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 2 hrs to fix
test/api/unit/libs/preening.test.js on lines 47..52

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

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('does aggregate data in monthly and yearly entries before cutoff (subscribers)', () => {
    const h = generateHistory(1031); // Jumps to October 21 2012
    const preened = preenHistory(_.cloneDeep(h), true, 0);
    // Keeps 365 days + 13 montly entries and 2 yearly entries for 2011 and 2010
    expect(preened.length).to.eql(380);
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 2 hrs to fix
test/api/unit/libs/preening.test.js on lines 40..45

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

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('does aggregate data in monthly entries before cutoff (free users)', () => {
    const h = generateHistory(81); // Jumps to July
    const preened = preenHistory(_.cloneDeep(h), false, 0);
    expect(preened.length).to.eql(62); // Keeps 60 days + 2 entries per august and july
  });
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/preening.test.js on lines 34..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 74.

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('does aggregate data in monthly entries before cutoff (subscribers)', () => {
    const h = generateHistory(396); // Jumps to September 2012
    const preened = preenHistory(_.cloneDeep(h), true, 0);
    expect(preened.length).to.eql(367); // Keeps 365 days + 2 entries per october and september
  });
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/preening.test.js on lines 28..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 74.

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('does not modify history if all entries are more recent than cutoff (subscribers)', () => {
    const h = generateHistory(365);
    expect(preenHistory(_.cloneDeep(h), true, 0)).to.eql(h);
  });
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/preening.test.js on lines 18..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 57.

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('does not modify history if all entries are more recent than cutoff (free users)', () => {
    const h = generateHistory(60);
    expect(preenHistory(_.cloneDeep(h), false, 0)).to.eql(h);
  });
Severity: Major
Found in test/api/unit/libs/preening.test.js and 1 other location - About 1 hr to fix
test/api/unit/libs/preening.test.js on lines 23..26

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

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

There are no issues that match your filters.

Category
Status