JulienPradet/react-flip

View on GitHub

Showing 39 of 39 total issues

File ReactFlipContainer.test.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component } from 'react';
import { mount, shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import ReactFlipContainer, { STATIC } from './ReactFlipContainer';
import ReactFlipElement from './ReactFlipElement';
Severity: Minor
Found in src/ReactFlipContainer.test.js - About 4 hrs to fix

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

      test('Last method on a group should only call the non deferred elements if deferred option is false', () => {
        const element = new Flip();
        const deferredElement = new Flip();
        const group = new FlipGroup();
        group.addElement(element);
    Severity: Major
    Found in src/FlipGroup.test.js and 3 other locations - About 2 hrs to fix
    src/FlipGroup.test.js on lines 59..68
    src/FlipGroup.test.js on lines 70..79
    src/FlipGroup.test.js on lines 89..98

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

    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

      test('First method on a group should only call the deferred elements if deferred option is true', () => {
        const element = new Flip();
        const deferredElement = new Flip();
        const group = new FlipGroup();
        group.addElement(element);
    Severity: Major
    Found in src/FlipGroup.test.js and 3 other locations - About 2 hrs to fix
    src/FlipGroup.test.js on lines 70..79
    src/FlipGroup.test.js on lines 89..98
    src/FlipGroup.test.js on lines 100..109

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

    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

      test('First method on a group should only call the non deferred elements if deferred option is false', () => {
        const element = new Flip();
        const deferredElement = new Flip();
        const group = new FlipGroup();
        group.addElement(element);
    Severity: Major
    Found in src/FlipGroup.test.js and 3 other locations - About 2 hrs to fix
    src/FlipGroup.test.js on lines 59..68
    src/FlipGroup.test.js on lines 89..98
    src/FlipGroup.test.js on lines 100..109

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

    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

      test('Last method on a group should only call the deferred elements if deferred option is true', () => {
        const element = new Flip();
        const deferredElement = new Flip();
        const group = new FlipGroup();
        group.addElement(element);
    Severity: Major
    Found in src/FlipGroup.test.js and 3 other locations - About 2 hrs to fix
    src/FlipGroup.test.js on lines 59..68
    src/FlipGroup.test.js on lines 70..79
    src/FlipGroup.test.js on lines 100..109

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

    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

      last({ deferred } = {}) {
        if (process.env.NODE_ENV === 'development' && this.props.debug) {
          const type = getDeferType(deferred);
          console.groupCollapsed(`ReactFlip: Last ${type}`);
        }
    Severity: Major
    Found in src/ReactFlipContainer.js and 1 other location - About 2 hrs to fix
    src/ReactFlipContainer.js on lines 115..124

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

    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

      first({ deferred } = {}) {
        if (process.env.NODE_ENV === 'development' && this.props.debug) {
          const type = getDeferType(deferred);
          console.groupCollapsed(`ReactFlip: First ${type}`);
        }
    Severity: Major
    Found in src/ReactFlipContainer.js and 1 other location - About 2 hrs to fix
    src/ReactFlipContainer.js on lines 126..135

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

    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

      test('Invert method should return a truthy value if at least one element returns a truthy value', () => {
        const element = new Flip();
        element.invert.mockImplementation(() => false);
    
        const element2 = new Flip();
    Severity: Major
    Found in src/FlipGroup.test.js and 1 other location - About 2 hrs to fix
    src/FlipGroup.test.js on lines 134..148

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

    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

      test('Invert method should return a falsy value if each invert returns a falsy value', () => {
        const element = new Flip();
        element.invert.mockImplementation(() => false);
    
        const element2 = new Flip();
    Severity: Major
    Found in src/FlipGroup.test.js and 1 other location - About 2 hrs to fix
    src/FlipGroup.test.js on lines 150..164

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

    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

    File Flip.test.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import Flip from './Flip';
    
    const createMock = () => {
      let current;
      return {
    Severity: Minor
    Found in src/Flip.test.js - About 2 hrs to fix

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

          expect({
            first: FlipGroup.prototype.first.mock.calls.length,
            last: FlipGroup.prototype.last.mock.calls.length,
            invert: FlipGroup.prototype.invert.mock.calls.length,
            play: FlipGroup.prototype.play.mock.calls.length
      Severity: Major
      Found in src/ReactFlipContainer.test.js and 1 other location - About 2 hrs to fix
      src/ReactFlipContainer.test.js on lines 102..112

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

      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

          expect({
            first: FlipGroup.prototype.first.mock.calls.length,
            last: FlipGroup.prototype.last.mock.calls.length,
            invert: FlipGroup.prototype.invert.mock.calls.length,
            play: FlipGroup.prototype.play.mock.calls.length
      Severity: Major
      Found in src/ReactFlipContainer.test.js and 1 other location - About 2 hrs to fix
      src/ReactFlipContainer.test.js on lines 121..131

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

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

      const ReactFlipElement = (options = {}) =>
        BaseComponent => {
          const getOptions = props =>
            typeof options === 'function' ? () => options(props()) : options;
      
      
      Severity: Minor
      Found in src/ReactFlipElement.js - About 2 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 3 locations. Consider refactoring.
      Open

        test('should set a default zIndex at 0', () => {
          const element = document.createElement('div');
          window.getComputedStyle = jest.fn();
          window.getComputedStyle.mockImplementation(() => ({
            zIndex: ''
      Severity: Major
      Found in src/getElementStyle.test.js and 2 other locations - About 2 hrs to fix
      src/getElementStyle.test.js on lines 43..54
      src/getElementStyle.test.js on lines 56..67

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

      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

        test('should set a default opacity at 1', () => {
          const element = document.createElement('div');
          window.getComputedStyle = jest.fn();
          window.getComputedStyle.mockImplementation(() => ({
            opacity: ''
      Severity: Major
      Found in src/getElementStyle.test.js and 2 other locations - About 2 hrs to fix
      src/getElementStyle.test.js on lines 30..41
      src/getElementStyle.test.js on lines 56..67

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

      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

        test('should set a 0 opacity at 0', () => {
          const element = document.createElement('div');
          window.getComputedStyle = jest.fn();
          window.getComputedStyle.mockImplementation(() => ({
            opacity: '0'
      Severity: Major
      Found in src/getElementStyle.test.js and 2 other locations - About 2 hrs to fix
      src/getElementStyle.test.js on lines 30..41
      src/getElementStyle.test.js on lines 43..54

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

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

        invert() {
          if (!this._first || !this._last) {
            if (process.env.NODE_ENV === 'development' && this.debug) {
              console.warn(
                this.options.id,
      Severity: Minor
      Found in src/Flip.js - About 1 hr to fix

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

          test('Should not animate if shouldAnimate is a function that returns false', () => {
            FlipGroup.prototype.invert.mockImplementation(() => true);
            FlipGroup.prototype.play.mockImplementation(() => new Promise(() => {}));
        
            const tree = mount(<Wrapper shouldAnimate={props => false} />);
        Severity: Major
        Found in src/ReactFlipContainer.test.js and 1 other location - About 1 hr to fix
        src/ReactFlipContainer.test.js on lines 174..182

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

        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

          test('Should animate if shouldAnimate is a function that returns true', () => {
            FlipGroup.prototype.invert.mockImplementation(() => true);
            FlipGroup.prototype.play.mockImplementation(() => new Promise(() => {}));
        
            const tree = mount(<Wrapper shouldAnimate={props => true} />);
        Severity: Major
        Found in src/ReactFlipContainer.test.js and 1 other location - About 1 hr to fix
        src/ReactFlipContainer.test.js on lines 164..172

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

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

          BaseComponent => {
            const getOptions = props =>
              typeof options === 'function' ? () => options(props()) : options;
        
            class ReactFlipElement extends Component {
        Severity: Minor
        Found in src/ReactFlipElement.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language