57Viktor57/project-lvl2-s329

View on GitHub

Showing 9 of 9 total issues

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

  it('plain', () => {
    const before = `${path}tree1.json`;
    const after = `${path}tree2.json`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expectedPlain.txt`, 'utf-8').trim();
    expect(genDiff(before, after, 'plain')).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 1 other location - About 3 hrs to fix
__tests__/gendiff.test.js on lines 37..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 98.

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('jsonOutput', () => {
    const before = `${path}tree1.json`;
    const after = `${path}tree2.json`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expectedJson.txt`, 'utf-8').trim();
    expect(genDiff(before, after, 'json')).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 1 other location - About 3 hrs to fix
__tests__/gendiff.test.js on lines 31..36

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

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

  it('yaml', () => {
    const before = `${path}file1.yaml`;
    const after = `${path}file2.yaml`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expected.txt`, 'utf-8').trim();
    expect(genDiff(before, after)).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 3 other locations - About 3 hrs to fix
__tests__/gendiff.test.js on lines 7..12
__tests__/gendiff.test.js on lines 19..24
__tests__/gendiff.test.js on lines 25..30

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

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

  it('ini', () => {
    const before = `${path}file1.ini`;
    const after = `${path}file2.ini`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expected.txt`, 'utf-8').trim();
    expect(genDiff(before, after)).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 3 other locations - About 3 hrs to fix
__tests__/gendiff.test.js on lines 7..12
__tests__/gendiff.test.js on lines 13..18
__tests__/gendiff.test.js on lines 25..30

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

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

  it('json', () => {
    const before = `${path}file1.json`;
    const after = `${path}file2.json`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expected.txt`, 'utf-8').trim();
    expect(genDiff(before, after)).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 3 other locations - About 3 hrs to fix
__tests__/gendiff.test.js on lines 13..18
__tests__/gendiff.test.js on lines 19..24
__tests__/gendiff.test.js on lines 25..30

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

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

  it('tree', () => {
    const before = `${path}tree1.json`;
    const after = `${path}tree2.json`;
    const content = fs.readFileSync(`${__dirname}/__fixtures__/expectedTree.txt`, 'utf-8').trim();
    expect(genDiff(before, after)).toEqual(content);
Severity: Major
Found in __tests__/gendiff.test.js and 3 other locations - About 3 hrs to fix
__tests__/gendiff.test.js on lines 7..12
__tests__/gendiff.test.js on lines 13..18
__tests__/gendiff.test.js on lines 19..24

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

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 getAst has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getAst = (before, after) => {
  const keys = _.union(Object.keys(before), Object.keys(after));

  return keys.reduce((acc, item) => {
    const beforeItem = before[item];
Severity: Minor
Found in src/getAst.js - About 1 hr to fix

    Avoid too many return statements within this function.
    Open

        return [...acc, {
          type: 'added',
          key: item,
          value: afterItem,
        }];
    Severity: Major
    Found in src/getAst.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return [...acc, {
              type: 'deleted',
              key: item,
              value: beforeItem,
            }];
      Severity: Major
      Found in src/getAst.js - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language