matthsc/gigaset-elements-api

View on GitHub

Showing 36 of 36 total issues

File api.spec.ts has 508 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable @typescript-eslint/no-unused-vars */
import * as sinon from "sinon";
import { IEventRoot, IEventsItem } from "./model";
import { assert, use as chaiUse } from "chai";
import { url, urlParams } from "./requestHelper";
Severity: Major
Found in src/api.spec.ts - About 1 day to fix

    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

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

        it("throws on invalid date object or number", () => {
          const invalids: Array<number | Date> = [
            new Date(NaN),
            new Date(Infinity),
            new Date("not-a-date"),
      Severity: Major
      Found in src/api.spec.ts and 1 other location - About 6 hrs to fix
      src/api.spec.ts on lines 494..517

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

      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

        it("throws on invalid date object or number", () => {
          const invalids: Array<number | Date> = [
            new Date(NaN),
            new Date(Infinity),
            new Date("not-a-date"),
      Severity: Major
      Found in src/api.spec.ts and 1 other location - About 6 hrs to fix
      src/api.spec.ts on lines 379..402

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

      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

      describe("api.getBaseStations", () => {
        const api = new GigasetElementsApi({ email: "", password: "" });
      
        afterEach(() => {
          nock.cleanAll();
      Severity: Major
      Found in src/api.spec.ts and 1 other location - About 4 hrs to fix
      src/api.spec.ts on lines 220..234

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

      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

      describe("api.getElements", () => {
        const api = new GigasetElementsApi({ email: "", password: "" });
      
        afterEach(() => {
          nock.cleanAll();
      Severity: Major
      Found in src/api.spec.ts and 1 other location - About 4 hrs to fix
      src/api.spec.ts on lines 204..218

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

      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

          try {
            await new RequestBase().post(uri);
            assert.fail("no error thrown");
          } catch (err: unknown) {
            assert.isTrue(scope.isDone());
      Severity: Major
      Found in src/requestHelper.spec.ts and 1 other location - About 3 hrs to fix
      src/requestHelper.spec.ts on lines 117..124

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

      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

          try {
            await new RequestBase().get(uri);
            assert.fail("no error thrown");
          } catch (err: unknown) {
            assert.isTrue(scope.isDone());
      Severity: Major
      Found in src/requestHelper.spec.ts and 1 other location - About 3 hrs to fix
      src/requestHelper.spec.ts on lines 190..197

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

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

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

            try {
              await new RequestBase().get(uri);
              assert.fail("no error thrown");
            } catch (err: unknown) {
              assert.isTrue(scope.isDone());
        Severity: Major
        Found in src/requestHelper.spec.ts and 1 other location - About 3 hrs to fix
        src/requestHelper.spec.ts on lines 177..184

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 96.

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

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

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

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

        Refactorings

        Further Reading

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

            try {
              await new RequestBase().post(uri);
              assert.fail("no error thrown");
            } catch (err: unknown) {
              assert.isTrue(scope.isDone());
        Severity: Major
        Found in src/requestHelper.spec.ts and 1 other location - About 3 hrs to fix
        src/requestHelper.spec.ts 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 96.

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

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

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

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

        Refactorings

        Further Reading

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

            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

        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

            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 252..262

            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

            Severity
            Category
            Status
            Source
            Language