Abikimoz/frontend-project-46

View on GitHub

Showing 14 of 14 total issues

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

describe('plain', () => {
  test('json', () => {
    expect(showDiff('./__fixtures__/file1.json', './__fixtures__/file2.json', 'plain')).toBe(resultPlain);
  });
  test('yaml', () => {
Severity: Major
Found in __tests__/index.test.js and 1 other location - About 4 hrs to fix
__tests__/index.test.js on lines 31..41

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

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

describe('json', () => {
  test('json', () => {
    expect(showDiff('./__fixtures__/file1.json', './__fixtures__/file2.json', 'json')).toBe(resultJSON);
  });
  test('yaml', () => {
Severity: Major
Found in __tests__/index.test.js and 1 other location - About 4 hrs to fix
__tests__/index.test.js on lines 19..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 115.

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

const buildAST = (data1, data2) => {
  const data1Keys = _.keys(data1);
  const data2Keys = _.keys(data2);
  const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));

Severity: Minor
Found in src/buildAST.js - About 1 hr to fix

    Function children has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const children = sortedKeys.map((key) => {
        if (!_.has(data1, key)) {
          return {
            type: 'added',
            key,
    Severity: Minor
    Found in src/buildAST.js - About 1 hr to fix

      Function makeStylishDiff has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const makeStylishDiff = (tree) => {
        const iter = (node, depth) => {
          switch (node.type) {
            case 'root': {
              const result = node.children.flatMap((child) => iter(child, depth));
      Severity: Minor
      Found in src/formatters/stylish.js - About 1 hr to fix

        Function buildAST has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const buildAST = (data1, data2) => {
          const data1Keys = _.keys(data1);
          const data2Keys = _.keys(data2);
          const sortedKeys = _.sortBy(_.union(data1Keys, data2Keys));
        
        
        Severity: Minor
        Found in src/buildAST.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 iter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const iter = (node, depth) => {
            switch (node.type) {
              case 'root': {
                const result = node.children.flatMap((child) => iter(child, depth));
                return joinStrings(result, depth);
        Severity: Minor
        Found in src/formatters/stylish.js - About 1 hr to fix

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

                case 'unchanged': {
                  return `${currentIndent(depth)}  ${node.key}: ${stringify(node.value, depth + 1)}`;
                }
          Severity: Minor
          Found in src/formatters/stylish.js and 2 other locations - About 40 mins to fix
          src/formatters/stylish.js on lines 34..36
          src/formatters/stylish.js on lines 37..39

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

          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

                case 'removed': {
                  return `${currentIndent(depth)}- ${node.key}: ${stringify(node.value, depth + 1)}`;
                }
          Severity: Minor
          Found in src/formatters/stylish.js and 2 other locations - About 40 mins to fix
          src/formatters/stylish.js on lines 34..36
          src/formatters/stylish.js on lines 44..46

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

          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

                case 'added': {
                  return `${currentIndent(depth)}+ ${node.key}: ${stringify(node.value, depth + 1)}`;
                }
          Severity: Minor
          Found in src/formatters/stylish.js and 2 other locations - About 40 mins to fix
          src/formatters/stylish.js on lines 37..39
          src/formatters/stylish.js on lines 44..46

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

          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

          Avoid too many return statements within this function.
          Open

                  return `${currentIndent(depth)}  ${node.key}: ${stringify(node.value, depth + 1)}`;
          Severity: Major
          Found in src/formatters/stylish.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return {
                  type: 'changed',
                  key,
                  value: data1[key],
                  value2: data2[key],
            Severity: Major
            Found in src/buildAST.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return null;
              Severity: Major
              Found in src/formatters/plain.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return [`${currentIndent(depth)}- ${node.key}: ${stringify(node.value, depth + 1)}`,
                          `${currentIndent(depth)}+ ${node.key}: ${stringify(node.value2, depth + 1)}`];
                Severity: Major
                Found in src/formatters/stylish.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language