matthsc/gigaset-elements-api

View on GitHub
test-data/data-tools.ts

Summary

Maintainability
F
4 days
Test Coverage

File data-tools.ts has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  IBaseStationRoot,
  IElementRoot,
  IEndnodesItem,
  IEventRoot,
Severity: Minor
Found in test-data/data-tools.ts - About 6 hrs to fix

    Function reduceTestData has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function reduceTestData(
      baseStations: IBaseStationRoot,
      elementRoot: IElementRoot,
      eventRoot: IEventRoot,
    ) {
    Severity: Major
    Found in test-data/data-tools.ts - About 3 hrs to fix

      Function tryStripPersonalDataFromBaseStation has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      function tryStripPersonalDataFromBaseStation(
        baseStations: IBaseStationRoot,
        maps: IPersonalDataMaps,
      ) {
        for (const base of baseStations) {
      Severity: Minor
      Found in test-data/data-tools.ts - 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

      Function reduceTestData has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      export function reduceTestData(
        baseStations: IBaseStationRoot,
        elementRoot: IElementRoot,
        eventRoot: IEventRoot,
      ) {
      Severity: Minor
      Found in test-data/data-tools.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

      Function tryStripPersonalDataFromEvents has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function tryStripPersonalDataFromEvents(
        events: IEventsItem[],
        maps: IPersonalDataMaps,
      ) {
        for (const event of events) {
      Severity: Minor
      Found in test-data/data-tools.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

      Function mergeEventRoots has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function mergeEventRoots(
        eventRoots: IEventRoot[],
        baseStationRoots: IBaseStationRoot[],
        mergedBaseStationRoot: IBaseStationRoot,
        elementRoots: IElementRoot[],
      Severity: Minor
      Found in test-data/data-tools.ts - About 1 hr to fix

        Function mergeElementsRoots has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        function mergeElementsRoots(elementRoots: IElementRoot[]) {
          const mergedElementsRoot = elementRoots[0];
          for (let i = 1; i < elementRoots.length; i++) {
            const currentElementRoot = elementRoots[i];
            // bs01
        Severity: Minor
        Found in test-data/data-tools.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

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

        function tryStripPersonalDataFromEvents(
          events: IEventsItem[],
          maps: IPersonalDataMaps,
        ) {
          for (const event of events) {
        Severity: Minor
        Found in test-data/data-tools.ts - About 1 hr to fix

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

          export function tryStripPersonalDataAndGiveUniqueIds(
            baseStations: IBaseStationRoot,
            elementRoot: IElementRoot,
            eventRoot: IEventRoot,
          ): void {
          Severity: Minor
          Found in test-data/data-tools.ts - About 1 hr to fix

            Function tryStripPersonalDataFromRooms has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function tryStripPersonalDataFromRooms(
              objectWithRoomData: unknown,
              maps: IPersonalDataMaps,
            ) {
              const item = objectWithRoomData as ISubelementsItem;
            Severity: Minor
            Found in test-data/data-tools.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

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

            export function mergeTestData(
              baseStationRoots: IBaseStationRoot[],
              elementRoots: IElementRoot[],
              eventRoots: IEventRoot[],
            ): [IBaseStationRoot, IElementRoot, IEventRoot] {
            Severity: Minor
            Found in test-data/data-tools.ts - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                        for (const setting of settings) {
                          if (setting.endnode_id)
                            setting.endnode_id = maps.elementIds.get(
                              setting.endnode_id,
                            ) as string;
              Severity: Major
              Found in test-data/data-tools.ts - About 45 mins to fix

                Function mergeEventRoots has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  eventRoots: IEventRoot[],
                  baseStationRoots: IBaseStationRoot[],
                  mergedBaseStationRoot: IBaseStationRoot,
                  elementRoots: IElementRoot[],
                  mergedElementRoots: IElementRoot,
                Severity: Minor
                Found in test-data/data-tools.ts - About 35 mins to fix

                  Function mergeBaseStationRoots has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function mergeBaseStationRoots(baseStationRoots: IBaseStationRoot[]) {
                    const mergedBaseStationRoot = baseStationRoots[0];
                    for (let i = 1; i < baseStationRoots.length; i++) {
                      const currentBaseStationRoot = baseStationRoots[i];
                      for (let j = 0; j < baseStationRoots[i].length; j++) {
                  Severity: Minor
                  Found in test-data/data-tools.ts - 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

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

                      for (const subelement of bs01.subelements) {
                        const key = getElementKey(subelement);
                        if (uniqueElementTypeMap.has(key)) {
                          elementIdRemapping.set(
                            subelement.id,
                  Severity: Major
                  Found in test-data/data-tools.ts and 1 other location - About 2 hrs to fix
                  test-data/data-tools.ts on lines 302..309

                  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

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

                    for (const gp02 of elementRoot.gp02) {
                      const key = getGp02Key(gp02);
                      if (uniqueGp02TypeMap.has(key)) {
                        gp02IdRemapping.set(gp02.id, uniqueGp02TypeMap.get(key) as IGp02Item);
                      } else {
                  Severity: Major
                  Found in test-data/data-tools.ts and 1 other location - About 2 hrs to fix
                  test-data/data-tools.ts on lines 288..298

                  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

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

                      base.sensors = base.sensors.filter(
                        (s) => !elementIdRemapping.has(`${base.id}.${s.id}`),
                      );
                  Severity: Major
                  Found in test-data/data-tools.ts and 1 other location - About 1 hr to fix
                  test-data/data-tools.ts on lines 313..315

                  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

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

                      base.endnodes = base.endnodes.filter(
                        (e) => !elementIdRemapping.has(`${base.id}.${e.id}`),
                      );
                  Severity: Major
                  Found in test-data/data-tools.ts and 1 other location - About 1 hr to fix
                  test-data/data-tools.ts on lines 316..318

                  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

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

                              if (newEvent.o?.friendly_name && !newEvent.o?.id)
                                newEvent.o.friendly_name = base.friendly_name;
                  Severity: Minor
                  Found in test-data/data-tools.ts and 1 other location - About 30 mins to fix
                  test-data/data-tools.ts on lines 430..431

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

                  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

                              if (newEvent.o?.friendly_name && !newEvent.o?.id)
                                newEvent.o.friendly_name = element.friendlyName;
                  Severity: Minor
                  Found in test-data/data-tools.ts and 1 other location - About 30 mins to fix
                  test-data/data-tools.ts on lines 447..448

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status