mauriciosoares/core.js

View on GitHub

Showing 32 of 32 total issues

Function createCore has 265 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createCore = function () {
    const core = {};

    core.paused = false;
    core.moduleInstances = new Map();
Severity: Major
Found in src/core.js - About 1 day to fix

    File saved_drawings.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    export {
        abstractLines,
        snowMan,
        flower,
    };
    Severity: Major
    Found in examples/draw/settings/saved_drawings.js - About 1 day to fix

      File prebuilts.js has 511 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      export {blinker, glider, leightWeightSpaceShip};
      const leightWeightSpaceShip = [
          [
            0,
            1,
      Severity: Major
      Found in examples/gameOfLife/settings/prebuilts.js - About 1 day to fix

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

        const glider = [
            [
              0,
              1,
              0,
        Severity: Major
        Found in examples/gameOfLife/settings/prebuilts.js and 2 other locations - About 7 hrs to fix
        examples/gameOfLife/settings/prebuilts.js on lines 2..171
        examples/gameOfLife/settings/prebuilts.js on lines 344..513

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

        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

        const leightWeightSpaceShip = [
            [
              0,
              1,
              1,
        Severity: Major
        Found in examples/gameOfLife/settings/prebuilts.js and 2 other locations - About 7 hrs to fix
        examples/gameOfLife/settings/prebuilts.js on lines 173..342
        examples/gameOfLife/settings/prebuilts.js on lines 344..513

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

        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

        const blinker = [
            [
              0,
              1,
              0,
        Severity: Major
        Found in examples/gameOfLife/settings/prebuilts.js and 2 other locations - About 7 hrs to fix
        examples/gameOfLife/settings/prebuilts.js on lines 2..171
        examples/gameOfLife/settings/prebuilts.js on lines 173..342

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

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

        const createCore = function () {
            const core = {};
        
            core.paused = false;
            core.moduleInstances = new Map();
        Severity: Minor
        Found in src/core.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

        File core.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // @ts-check
        export { createCore, ALL, ERROR, prepareWorkerCode };
        export { startEventRecorder, stopEventRecorder } from "./eventRecorder.js";
        export { replayEvents } from "./eventPlayer.js";
        export { useDefaultLogging } from "./logging.js";
        Severity: Minor
        Found in src/core.js - About 3 hrs to fix

          Function startUiInput has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const startUiInput = function (emitter, instance) {
              let paused = false;
              const pauseButton = document.getElementById(`pause`);
              const pauseAction = function () {
                  if (paused) {
          Severity: Major
          Found in examples/gameOfLife/input.js - About 2 hrs to fix

            Function listenForWorkerMessage has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    listenForWorkerMessage(name, worker, resolve, earlyWrapper) {
                        worker.addEventListener(`message`, function (messageEvent)  {
                            const message = messageEvent.data;
                            if (!Object.prototype.hasOwnProperty.call(message, CORE_ACTION_KEY)) {
                                return;
            Severity: Minor
            Found in src/core.js - About 1 hr to fix

              Function startWorker has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      startWorker(moduleUrl, name, data, workerReady) {
                          
                          const earlyWrapper = {
                              module: moduleUrl,
                              name,
              Severity: Minor
              Found in src/core.js - About 1 hr to fix

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

                                workerRessourcePromise.then(workerRessource => {
                                    
                                    const moduleInsideWorker = new Worker(workerRessource, {
                                        type: `module`,
                                        name: String(name), // help debugging
                Severity: Major
                Found in src/core.js and 1 other location - About 1 hr to fix
                src/core.js on lines 149..165

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

                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

                            return Promise.resolve().then(() => {
                                return module.start(emitter, data);
                            }).then(instance => {
                                Object.assign(earlyWrapper, {
                                    instance,
                Severity: Major
                Found in src/core.js and 1 other location - About 1 hr to fix
                src/core.js on lines 190..209

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

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

                        start(module, { 
                            name = Symbol(),
                            data = undefined,
                            worker = false,
                            workerReady = false,
                Severity: Minor
                Found in src/core.js - About 1 hr to fix

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

                          restoreStateInWorker(wrapper) {
                              return new Promise(function (resolve, reject) {
                                  wrapper.setStateResolve = resolve;
                                  wrapper.worker.postMessage({
                                      [CORE_ACTION_KEY]: CORE_SET_STATE,
                  Severity: Major
                  Found in src/core.js and 2 other locations - About 1 hr to fix
                  src/core.js on lines 55..62
                  src/core.js on lines 294..301

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

                  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

                          requestStateFromWorker(wrapper) {
                              return new Promise(function (resolve, reject) {
                                  wrapper.getStateResolve = resolve;
                                  wrapper.worker.postMessage({
                                      [CORE_ACTION_KEY]: CORE_GET_STATE,
                  Severity: Major
                  Found in src/core.js and 2 other locations - About 1 hr to fix
                  src/core.js on lines 104..111
                  src/core.js on lines 294..301

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

                  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

                          stopWorker(wrapper) {
                              return new Promise(function (resolve, reject) {
                                  wrapper.stopResolve = resolve;
                                  wrapper.worker.postMessage({
                                      [CORE_ACTION_KEY]: CORE_STOP,
                  Severity: Major
                  Found in src/core.js and 2 other locations - About 1 hr to fix
                  src/core.js on lines 55..62
                  src/core.js on lines 104..111

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

                  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

                          Promise.resolve().then(() => {
                              return start(localEmitter, message.data);
                          }).then(instance => {
                              localInstance = instance;
                          }).catch(errorModuleStart => {
                  Severity: Major
                  Found in src/workerGlue.js and 3 other locations - About 50 mins to fix
                  src/workerGlue.js on lines 83..94
                  src/workerGlue.js on lines 104..119
                  src/workerGlue.js on lines 123..139

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

                  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

                          Promise.resolve().then(() => {
                              if (typeof stop === `function`) {
                                  return stop(wrapper.instance);
                              }
                          }).catch(errorModuleStop => {
                  Severity: Major
                  Found in src/workerGlue.js and 3 other locations - About 50 mins to fix
                  src/workerGlue.js on lines 60..71
                  src/workerGlue.js on lines 104..119
                  src/workerGlue.js on lines 123..139

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

                  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

                          Promise.resolve().then(() => {
                              if (typeof restoreState === `function`) {
                                  return restoreState(localInstance, message.data);
                              }
                          }).then(() => {
                  Severity: Major
                  Found in src/workerGlue.js and 3 other locations - About 50 mins to fix
                  src/workerGlue.js on lines 60..71
                  src/workerGlue.js on lines 83..94
                  src/workerGlue.js on lines 123..139

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

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language