vaziliybober/operlib

View on GitHub

Showing 20 of 20 total issues

Function transformAtomic has 154 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const transformAtomic = (aOper1, aOper2) => {
  const useSymmetry = () => {
    const [aOper2Transformed, aOper1Transformed] = transformAtomic(
      aOper2,
      aOper1,
Severity: Major
Found in src/operation.js - About 6 hrs to fix

    Function transformAtomic has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    export const transformAtomic = (aOper1, aOper2) => {
      const useSymmetry = () => {
        const [aOper2Transformed, aOper1Transformed] = transformAtomic(
          aOper2,
          aOper1,
    Severity: Minor
    Found in src/operation.js - About 3 hrs 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

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

      it('delete-insert: right-left', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 1, length: 3 });
        const a2 = makeAtomic('insert', { pos: 1, content: '+-' });
        checkTransform(str, a1, a2, 'a+-efgh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 1 other location - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 66..71

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

      it('insert-delete: right-left', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('insert', { pos: 5, content: '+-' });
        const a2 = makeAtomic('remove', { pos: 1, length: 3 });
        checkTransform(str, a1, a2, 'ae+-fgh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 2 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 48..53
    __tests__/atomicOperation.test.js on lines 72..77

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

      it('insert-delete: left-right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('insert', { pos: 1, content: '+-' });
        const a2 = makeAtomic('remove', { pos: 1, length: 3 });
        checkTransform(str, a1, a2, 'a+-efgh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 2 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 60..65
    __tests__/atomicOperation.test.js on lines 72..77

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

      it('delete-delete: 1 more left, 2 more right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 1, length: 3 });
        const a2 = makeAtomic('remove', { pos: 2, length: 4 });
        checkTransform(str, a1, a2, 'agh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 4 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 18..23
    __tests__/atomicOperation.test.js on lines 24..29
    __tests__/atomicOperation.test.js on lines 36..41
    __tests__/atomicOperation.test.js on lines 42..47

    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('delete-insert: left-right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 1, length: 3 });
        const a2 = makeAtomic('insert', { pos: 5, content: '+-' });
        checkTransform(str, a1, a2, 'ae+-fgh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 1 other location - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 54..59

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

      it('delete-delete: 1 is bigger', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 1, length: 6 });
        const a2 = makeAtomic('remove', { pos: 3, length: 3 });
        checkTransform(str, a1, a2, 'ah');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 4 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 18..23
    __tests__/atomicOperation.test.js on lines 24..29
    __tests__/atomicOperation.test.js on lines 30..35
    __tests__/atomicOperation.test.js on lines 36..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 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 5 locations. Consider refactoring.
    Open

      it('delete-delete: 2 left, 1 right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 5, length: 3 });
        const a2 = makeAtomic('remove', { pos: 1, length: 2 });
        checkTransform(str, a1, a2, 'ade');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 4 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 18..23
    __tests__/atomicOperation.test.js on lines 30..35
    __tests__/atomicOperation.test.js on lines 36..41
    __tests__/atomicOperation.test.js on lines 42..47

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

      it('delete-delete: 2 more left, 1 more right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 2, length: 4 });
        const a2 = makeAtomic('remove', { pos: 1, length: 3 });
        checkTransform(str, a1, a2, 'agh');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 4 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 18..23
    __tests__/atomicOperation.test.js on lines 24..29
    __tests__/atomicOperation.test.js on lines 30..35
    __tests__/atomicOperation.test.js on lines 42..47

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

      it('insert-delete: insert between', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('insert', { pos: 3, content: '+-' });
        const a2 = makeAtomic('remove', { pos: 1, length: 6 });
        checkTransform(str, a1, a2, 'a+-h');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 2 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 48..53
    __tests__/atomicOperation.test.js on lines 60..65

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

      it('delete-delete: 1 left, 2 right', () => {
        const str = 'abcdefgh';
        const a1 = makeAtomic('remove', { pos: 1, length: 2 });
        const a2 = makeAtomic('remove', { pos: 5, length: 3 });
        checkTransform(str, a1, a2, 'ade');
    Severity: Major
    Found in __tests__/atomicOperation.test.js and 4 other locations - About 2 hrs to fix
    __tests__/atomicOperation.test.js on lines 24..29
    __tests__/atomicOperation.test.js on lines 30..35
    __tests__/atomicOperation.test.js on lines 36..41
    __tests__/atomicOperation.test.js on lines 42..47

    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

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

    export const transformOperations = (oper1, oper2) => {
      const operations1 = oper1.map((aOper1) => makeOperation(aOper1));
      const operations2 = oper2.map((aOper2) => makeOperation(aOper2));
    
      for (let i1 = 0; i1 < operations1.length; i1 += 1) {
    Severity: Minor
    Found in src/operation.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

    Avoid too many return statements within this function.
    Open

          return [
            makeOperation(
              makeAtomic('remove', {
                pos: left1,
                length: length1 - length2,
    Severity: Major
    Found in src/operation.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return useSymmetry();
      Severity: Major
      Found in src/operation.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return [
                makeOperation(
                  makeAtomic('insert', {
                    pos: left,
                    content,
        Severity: Major
        Found in src/operation.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                return [
                  makeOperation(
                    makeAtomic('insert', {
                      pos,
                      content,
          Severity: Major
          Found in src/operation.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return [
                    makeOperation(
                      makeAtomic('insert', {
                        pos: pos - length,
                        content,
            Severity: Major
            Found in src/operation.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return useSymmetry();
              Severity: Major
              Found in src/operation.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return useSymmetry();
                Severity: Major
                Found in src/operation.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language