matthsc/gigaset-elements-api

View on GitHub

Showing 36 of 36 total issues

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

    return (
      getInterceptor(domain + path)
        // .query(new URLSearchParams(query + date.valueOf()))
        .query(params)
        .reply(
Severity: Major
Found in src/api.spec.ts and 1 other location - About 1 hr to fix
src/api.spec.ts on lines 350..360

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

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

    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

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

      async function runTests(method: "get" | "post") {
        const reply1 = {};
        const reply2 = { alpha: 1, beta: "2" };
        const reply3 = { m: "NO" };
        const scope = nock(url)
    Severity: Minor
    Found in src/requestHelper.spec.ts - About 1 hr to fix

      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

        Function Authorize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function Authorize(
          target: GigasetElementsApi,
          title: string,
          descriptor: PropertyDescriptor,
        ) {
        Severity: Minor
        Found in src/api.ts - 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

                  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

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

            @Authorize
            public getBaseStations(): Promise<IBaseStationRoot> {
              return this.get<IBaseStationRoot>(url.basestations);
            }
          Severity: Major
          Found in src/api.ts and 2 other locations - About 40 mins to fix
          src/api.ts on lines 106..109
          src/api.ts on lines 124..127

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 49.

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

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

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

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

          Refactorings

          Further Reading

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

            @Authorize
            public getElements(): Promise<IElementRoot> {
              return this.get<IElementRoot>(url.elements);
            }
          Severity: Major
          Found in src/api.ts and 2 other locations - About 40 mins to fix
          src/api.ts on lines 106..109
          src/api.ts on lines 115..118

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 49.

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

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

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

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

          Refactorings

          Further Reading

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

            @Authorize
            public getSystemHealth(): Promise<IGigasetElementsSystemHealth> {
              return this.get<IGigasetElementsSystemHealth>(url.health);
            }
          Severity: Major
          Found in src/api.ts and 2 other locations - About 40 mins to fix
          src/api.ts on lines 115..118
          src/api.ts on lines 124..127

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 49.

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

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

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

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

          Refactorings

          Further Reading

          Function 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

                        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

            Severity
            Category
            Status
            Source
            Language