RolandJansen/intermix.js

View on GitHub

Showing 131 of 131 total issues

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

        it("removes an event from a given position", () => {
            // cumbersome test because we want to avoid
            // the use of other high level api (part.getActionsAtStep())
            const stepMultiplyer = 64 / part.stepsPerBar;
            part.removeEvent(noteEvent, 4);
Severity: Major
Found in src/seqpart/SeqPart.test.ts and 1 other location - About 2 hrs to fix
src/seqpart/SeqPart.test.ts on lines 65..73

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

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

async function main() {
    await new Promise((resolve, reject) =>
        exec("api-extractor run --local && api-documenter markdown -i temp -o docs/api", (err, stdout, stderr) => {
            console.log(stdout);
            console.error(stderr);
Severity: Major
Found in etc/make-docs.js - About 2 hrs to fix

    File AbstractRegistry.test.ts has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable @typescript-eslint/camelcase */
    import { ActionCreatorsMapObject, Reducer, ReducersMapObject } from "redux";
    import { store } from "../../store/store";
    import AbstractRegistry from "../AbstractRegistry";
    import { IActionHandlerMap, IState, Tuple } from "../../interfaces/interfaces";
    Severity: Minor
    Found in src/registry/__tests__/AbstractRegistry.test.ts - About 2 hrs to fix

      Function rootReducer has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      const rootReducer = (state: IState = initialState, action: AnyAction): IState => {
          if (action.type === ADD_PLUGIN) {
              if (isStringArray(state.plugins)) {
                  const newPluginRefs = addItem(state.plugins, action.payload);
                  const newState: IState = { ...state, plugins: newPluginRefs };
      Severity: Minor
      Found in src/store/rootReducer.ts - 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

      File Sequencer.test.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /// <reference path="../../../../typings/web-audio-test-api.d.ts" />
      import "web-audio-test-api";
      import Sequencer from "../Sequencer";
      import SeqPart from "../../../seqpart/SeqPart";
      import { IntermixNote } from "../../../interfaces/interfaces";
      Severity: Minor
      Found in src/plugins/Sequencer/__tests__/Sequencer.test.ts - About 2 hrs to fix

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

            public remove(itemId: string): void {
                const oldItem = this.itemList.get(itemId);
        
                if (oldItem) {
                    // trigger the items unsubscribe method (decouple from dispatch)
        Severity: Major
        Found in src/registry/PluginRegistry.ts and 1 other location - About 2 hrs to fix
        src/registry/SeqPartRegistry.ts on lines 52..62

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 76.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

            public remove(itemId: string): void {
                const oldItem = this.itemList.get(itemId);
        
                if (oldItem) {
                    // trigger the items unsubscribe method (decouple from dispatch)
        Severity: Major
        Found in src/registry/SeqPartRegistry.ts and 1 other location - About 2 hrs to fix
        src/registry/PluginRegistry.ts on lines 62..72

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 76.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function onChange has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public onChange(changed: Tuple): boolean {
                switch (changed[0]) {
                    case "running":
                        if (changed[1] === 0) {
                            this.stop();
        Severity: Minor
        Found in src/plugins/Sequencer/Sequencer.ts - About 2 hrs to fix

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

                  test("plugin receives savePreset actions", () => {
                      plug.actionCreators.savePreset("myPreset");
                      expect(plug.testValue[0]).toBe("savePreset");
                      expect(plug.testValue[1]).toBe("myPreset");
                  });
          Severity: Major
          Found in src/registry/__tests__/commonActionDefs_Integration.test.ts and 1 other location - About 1 hr to fix
          src/registry/__tests__/commonActionDefs_Integration.test.ts on lines 148..152

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

          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("plugin receives loadPreset actions", () => {
                      plug.actionCreators.loadPreset("myPreset");
                      expect(plug.testValue[0]).toBe("loadPreset");
                      expect(plug.testValue[1]).toBe("myPreset");
                  });
          Severity: Major
          Found in src/registry/__tests__/commonActionDefs_Integration.test.ts and 1 other location - About 1 hr to fix
          src/registry/__tests__/commonActionDefs_Integration.test.ts on lines 122..126

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

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

          export const deepCopy = <T>(original: T): T => {
              // what about:
              // * img data
              // * functions
          
          
          Severity: Minor
          Found in src/helper.ts - About 1 hr to fix

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

                } else if (action.type === ADD_PART) {
                    if (isStringArray(state.seqparts)) {
                        const newPartRefs = addItem(state.seqparts, action.payload);
                        const newState: IState = { ...state, seqparts: newPartRefs };
                        return newState;
            Severity: Major
            Found in src/store/rootReducer.ts and 1 other location - About 1 hr to fix
            src/store/rootReducer.ts on lines 11..72

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

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

            const copyTypedArray = (original: TypedArray): TypedArray => {
                if (original instanceof Int8Array) {
                    return new Int8Array(original);
                }
                if (original instanceof Uint8Array) {
            Severity: Minor
            Found in src/helper.ts - About 1 hr to fix

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

                  if (action.type === ADD_PLUGIN) {
                      if (isStringArray(state.plugins)) {
                          const newPluginRefs = addItem(state.plugins, action.payload);
                          const newState: IState = { ...state, plugins: newPluginRefs };
                          return newState;
              Severity: Major
              Found in src/store/rootReducer.ts and 1 other location - About 1 hr to fix
              src/store/rootReducer.ts on lines 28..72

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

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

              const copyTypedArray = (original: TypedArray): TypedArray => {
                  if (original instanceof Int8Array) {
                      return new Int8Array(original);
                  }
                  if (original instanceof Uint8Array) {
              Severity: Minor
              Found in src/helper.ts - 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

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

              const isPluginState = (value: unknown): value is IPluginState => {
                  const pluginState = value as IPluginState;
                  return pluginState.uid !== undefined && pluginState.actionDefs !== undefined;
              };
              Severity: Major
              Found in src/registry/commonPluginActionDefs.ts and 1 other location - About 1 hr to fix
              src/store/rootReducer.ts on lines 113..116

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

              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 < length; i++) {
                      randomChars[i] = input.charAt(Math.floor(Math.random() * input.length));
                  }
              Severity: Major
              Found in src/benchmarks/helpers.ts and 1 other location - About 1 hr to fix
              src/helper.ts on lines 6..8

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

              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 < length; i++) {
                          randomChars[i] = input.charAt(Math.floor(Math.random() * input.length));
                      }
              Severity: Major
              Found in src/helper.ts and 1 other location - About 1 hr to fix
              src/benchmarks/helpers.ts on lines 26..28

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

              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

              const isPluginState = (value: unknown): value is IPluginState => {
                  const pluginState = value as IPluginState;
                  return pluginState.inputs !== undefined && pluginState.outputs !== undefined;
              };
              Severity: Major
              Found in src/store/rootReducer.ts and 1 other location - About 1 hr to fix
              src/registry/commonPluginActionDefs.ts on lines 126..129

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

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

              const preprocessOSC: Middleware = () => (next) => (action: AnyAction): AnyAction => {
                  let toBeDispatched: AnyAction = action;
              
                  if (itsAnOscAction(action)) {
                      const address: string[] = action.address.split("/");
              Severity: Minor
              Found in src/store/preprocessOscMiddleware.ts - 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

              Severity
              Category
              Status
              Source
              Language