TyrealGray/Qin.js

View on GitHub

Showing 32 of 32 total issues

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

export const characterInfo = (state = initialState, action) =>
    produce(state, draft => {
        switch (action.type) {
            case STORE_CONNECT_REACTOR:
                return action.payload.characterInfo;
packages/qin.js/src/core/reactorCore/reduxCore/reducers/npcInfo.js on lines 11..37
packages/qin.js/src/core/reactorCore/reduxCore/reducers/terrainInfo.js on lines 11..37

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

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

export const npcInfo = (state = initialState, action) =>
    produce(state, draft => {
        switch (action.type) {
            case STORE_CONNECT_REACTOR:
                return action.payload.npcInfo;
packages/qin.js/src/core/reactorCore/reduxCore/reducers/characterInfo.js on lines 11..38
packages/qin.js/src/core/reactorCore/reduxCore/reducers/terrainInfo.js on lines 11..37

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

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

export const terrainInfo = (state = initialState, action) =>
    produce(state, draft => {
        switch (action.type) {
            case STORE_CONNECT_REACTOR:
                return action.payload.terrainInfo;
packages/qin.js/src/core/reactorCore/reduxCore/reducers/characterInfo.js on lines 11..38
packages/qin.js/src/core/reactorCore/reduxCore/reducers/npcInfo.js on lines 11..37

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

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

        factor.npcs.forEach((n,i) => {
            this._content.npcInfo.dataSet.push({
                ...n.attribute,
                index: i,
                eventMap: n.eventMap,
Severity: Major
Found in packages/qin.js/src/core/reactorCore/shuoCore/Shuo.js and 1 other location - About 3 hrs to fix
packages/qin.js/src/core/reactorCore/shuoCore/Shuo.js on lines 34..42

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

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

        factor.terrains.forEach((t,i) => {
            this._content.terrainInfo.dataSet.push({
                ...t.attribute,
                index: i,
                eventMap: t.eventMap,
Severity: Major
Found in packages/qin.js/src/core/reactorCore/shuoCore/Shuo.js and 1 other location - About 3 hrs to fix
packages/qin.js/src/core/reactorCore/shuoCore/Shuo.js on lines 24..32

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

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

    async _update(delta: number, tick: number): Promise<void> {
        const { terrainInfo, npcInfo, gameInfo, eventTimeInfo } = this._storeData;

        const rules = await this.getRules();

Severity: Major
Found in packages/qin.js/src/core/reactorCore/Reactor.js - About 2 hrs to fix

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

            this._renderer.stage.mouseup = (e) => {
                this._controller.onMouseUp({
                    layerX: e.data.originalEvent.layerX,
                    layerY: e.data.originalEvent.layerY,
                });
    Severity: Major
    Found in packages/qin-renderer.js/src/render/QinStageAgent.js and 1 other location - About 2 hrs to fix
    packages/qin-renderer.js/src/render/QinStageAgent.js on lines 53..58

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

    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

            this._renderer.stage.mousedown = (e) => {
                this._controller.onMouseDown({
                    layerX: e.data.originalEvent.layerX,
                    layerY: e.data.originalEvent.layerY,
                });
    Severity: Major
    Found in packages/qin-renderer.js/src/render/QinStageAgent.js and 1 other location - About 2 hrs to fix
    packages/qin-renderer.js/src/render/QinStageAgent.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 75.

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

    export const checkCondition = (
        data: Object,
        conditions: Object,
        condition: string,
        checkCallback: (Object, Object) => boolean,
    Severity: Minor
    Found in packages/qin.js/src/core/reactorCore/conditionCheck.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

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

    const dynamicReact = (data: Object, reaction: Object, action:{type: string, triggerBy: any, triggerTo: any, stamp: { seed: string, time: number }}): void => {
        if (typeof reaction.rate !== 'undefined' && !checkChance(data, reaction, action.stamp)) {
            return;
        }
    
    
    Severity: Major
    Found in packages/qin.js/src/core/reactorCore/processReaction.js and 1 other location - About 1 hr to fix
    packages/qin.js/src/core/reactorCore/processReaction.js on lines 115..146

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

    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

    const commonReact = (data: Object, reaction: Object, action:{type: string, triggerBy: any, triggerTo: any, stamp: { seed: string, time: number }}): void => {
        const { peeledPropArray } = peelPropsString(reaction.attribute);
    
        let value = data;
        let accessProp = null;
    Severity: Major
    Found in packages/qin.js/src/core/reactorCore/processReaction.js and 1 other location - About 1 hr to fix
    packages/qin.js/src/core/reactorCore/processReaction.js on lines 97..113

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

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

    const commonReact = (data: Object, reaction: Object, action:{type: string, triggerBy: any, triggerTo: any, stamp: { seed: string, time: number }}): void => {
        const { peeledPropArray } = peelPropsString(reaction.attribute);
    
        let value = data;
        let accessProp = null;
    Severity: Minor
    Found in packages/qin.js/src/core/reactorCore/processReaction.js - About 1 hr to fix

      Function getCorrectNode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static getCorrectNode(
              paths: Array<PathNode>,
          ): {
              node: PathNode | null,
              closedPaths: Array<PathNode>,

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

            async _getOne(query: Object): Promise<any> {
                return await this._promiseDBQuery(
                    (q, c) => this._db.findOne(q, c),
                    query,
                );
        Severity: Major
        Found in packages/qin.js/src/core/reactorCore/dbCore/DBClient.js and 1 other location - About 1 hr to fix
        packages/qin.js/src/core/reactorCore/dbCore/DBClient.js on lines 35..37

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

        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

            async _get(query: Object): Promise<any> {
                return await this._promiseDBQuery((q, c) => this._db.find(q, c), query);
            }
        Severity: Major
        Found in packages/qin.js/src/core/reactorCore/dbCore/DBClient.js and 1 other location - About 1 hr to fix
        packages/qin.js/src/core/reactorCore/dbCore/DBClient.js on lines 39..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 57.

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

            getCorrectPath(startNode: PathNode): Array<Grid> {
                const pathNodes = startNode.getNeighbors();
                const scannedPaths: Array<PathNode> = [startNode];
                const correctPath = [];
        
        

          Function _initMouseEvent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _initMouseEvent() {
          
                  this._initControllerEvent();
          
                  this._renderer.stage.mousedown = (e) => {
          Severity: Minor
          Found in packages/qin-renderer.js/src/render/QinStageAgent.js - About 1 hr to fix

            Function getCorrectNode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                static getCorrectNode(
                    paths: Array<PathNode>,
                ): {
                    node: PathNode | null,
                    closedPaths: Array<PathNode>,

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

            const commonReact = (data: Object, reaction: Object, action:{type: string, triggerBy: any, triggerTo: any, stamp: { seed: string, time: number }}): void => {
                const { peeledPropArray } = peelPropsString(reaction.attribute);
            
                let value = data;
                let accessProp = null;
            Severity: Minor
            Found in packages/qin.js/src/core/reactorCore/processReaction.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 deeply nested control flow statements.
            Open

                                        if (
                                            trigger.triggerLimit &&
                                            !eventTimeInfo.dataSet[trigger.name]
                                        ) {
                                            await this._store.dispatch({
            Severity: Major
            Found in packages/qin.js/src/core/reactorCore/Reactor.js - About 45 mins to fix
              Severity
              Category
              Status
              Source
              Language