mysticPrg/catch-light

View on GitHub

Showing 31 of 31 total issues

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

function makeAsyncFunc(func, wait) {
    return (...args) => {
        return new Promise(resolve => {
            if ( wait <= 0 ) {
                resolve(func(...args));
Severity: Major
Found in src/utils/fakeSocket.js and 1 other location - About 2 hrs to fix
src/utils/fakeServer.js on lines 3..16

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

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

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

function makeAsyncFunc(func, wait = defaultWait) {
    return (...args) => {
        return new Promise(resolve => {
            if ( wait <= 0 ) {
                resolve(func(...args));
Severity: Major
Found in src/utils/fakeServer.js and 1 other location - About 2 hrs to fix
src/utils/fakeSocket.js on lines 4..17

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

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

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

        for ( let i=0 ; i<count ; i++ ) {
            lightArr.push({
                id: getFakeKey(),
                color: '#0000FF',
                size: 20,
Severity: Major
Found in src/components/light/LightSpace.test.js and 1 other location - About 2 hrs to fix
src/components/light/LightSpace.test.js on lines 35..44

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

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

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

        for ( let i=0 ; i<count ; i++ ) {
            lightArr.push({
                id: getFakeKey(),
                color: '#0000FF',
                size: 20,
Severity: Major
Found in src/components/light/LightSpace.test.js and 1 other location - About 2 hrs to fix
src/components/light/LightSpace.test.js on lines 62..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 85.

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 Light.test.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import { shallow, mount } from 'enzyme';

import Light from './Light';
import { getFakeKey, getRandomColor } from '~/utils/common';
Severity: Minor
Found in src/components/light/Light.test.js - About 2 hrs to fix

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

        it('should be show circle shape', () => {
            const light = shallow(<Light/>);
    
            const style = light.find('[data-test="light"]').props().style;
            const result = style.borderRadius;
    Severity: Major
    Found in src/components/light/Light.test.js and 1 other location - About 2 hrs to fix
    src/components/light/Light.test.js on lines 319..326

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

    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('mouse cursor should be change to hand when hover', () => {
            const light = shallow(<Light/>);
    
            const style = light.find('[data-test="light"]').props().style;
            const result = style.cursor;
    Severity: Major
    Found in src/components/light/Light.test.js and 1 other location - About 2 hrs to fix
    src/components/light/Light.test.js on lines 310..317

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

    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('y-min should be less than y-max', () => {
            const min = 10;
            const max = 5;
            
            const errSpy = spyOn(console, 'error');
    Severity: Major
    Found in src/components/light/Light.test.js and 1 other location - About 2 hrs to fix
    src/components/light/Light.test.js on lines 118..130

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

    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('x-min should be less than x-max', () => {
            const min = 10;
            const max = 5;
            
            const errSpy = spyOn(console, 'error');
    Severity: Major
    Found in src/components/light/Light.test.js and 1 other location - About 2 hrs to fix
    src/components/light/Light.test.js on lines 132..144

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

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

    export default function LightReducer(state = initialState, action) {
    
        const lights = state.lights;
    
        switch ( action.type ) {
    Severity: Major
    Found in src/reducers/LightReducer.js - About 2 hrs to fix

      Function clone has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      export function clone(obj) {
          let copy;
      
          if (obj === null || typeof obj !== 'object') {
              return obj;
      Severity: Minor
      Found in src/utils/common.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

      Function render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          render() {
              const style = {
                  width: `${this.props.width}px`,
                  height: `${this.props.height}px`
              };
      Severity: Minor
      Found in src/components/light/LightSpace.js - About 1 hr to fix

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

        export function clone(obj) {
            let copy;
        
            if (obj === null || typeof obj !== 'object') {
                return obj;
        Severity: Minor
        Found in src/utils/common.js - About 1 hr to fix

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

              it('should be render without crash', () => {
                  expect(() => {
                      shallow(<LightSpace/>);
                  }).not.toThrow();
              });
          Severity: Major
          Found in src/components/light/LightSpace.test.js and 4 other locations - About 40 mins to fix
          src/components/light/Light.test.js on lines 12..16
          src/components/neon/Button.test.js on lines 8..12
          src/components/neon/CheckBox.test.js on lines 7..11
          src/components/neon/TextField.test.js on lines 8..12

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

          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('should be render without crash', () => {
                  expect(() => {
                      shallow(<Button/>);
                  }).not.toThrow();
              });
          Severity: Major
          Found in src/components/neon/Button.test.js and 4 other locations - About 40 mins to fix
          src/components/light/Light.test.js on lines 12..16
          src/components/light/LightSpace.test.js on lines 8..12
          src/components/neon/CheckBox.test.js on lines 7..11
          src/components/neon/TextField.test.js on lines 8..12

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

          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('should be rendered without crash', () => {
                  expect(() => {
                      shallow(<Light/>);
                  }).not.toThrow();
              });
          Severity: Major
          Found in src/components/light/Light.test.js and 4 other locations - About 40 mins to fix
          src/components/light/LightSpace.test.js on lines 8..12
          src/components/neon/Button.test.js on lines 8..12
          src/components/neon/CheckBox.test.js on lines 7..11
          src/components/neon/TextField.test.js on lines 8..12

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

          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('should be render without crash', () => {
                  expect(() => {
                      shallow(<CheckBox/>);
                  }).not.toThrow();
              });
          Severity: Major
          Found in src/components/neon/CheckBox.test.js and 4 other locations - About 40 mins to fix
          src/components/light/Light.test.js on lines 12..16
          src/components/light/LightSpace.test.js on lines 8..12
          src/components/neon/Button.test.js on lines 8..12
          src/components/neon/TextField.test.js on lines 8..12

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

          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('should be render without crash', () => {
                  expect(() => {
                      shallow(<TextField/>);
                  }).not.toThrow();
              });
          Severity: Major
          Found in src/components/neon/TextField.test.js and 4 other locations - About 40 mins to fix
          src/components/light/Light.test.js on lines 12..16
          src/components/light/LightSpace.test.js on lines 8..12
          src/components/neon/Button.test.js on lines 8..12
          src/components/neon/CheckBox.test.js on lines 7..11

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

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

          export default function LightReducer(state = initialState, action) {
          
              const lights = state.lights;
          
              switch ( action.type ) {
          Severity: Minor
          Found in src/reducers/LightReducer.js - About 35 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 {
                          ...state,
                          lights: nextLights
                      };
          Severity: Major
          Found in src/reducers/LightReducer.js - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language