Apollon77/daikin-controller

View on GitHub

Showing 19 of 19 total issues

Function getRequestDict has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    public getRequestDict(): RequestDict {
        const dict: RequestDict = {};
        if (this.power === undefined) throw new Error('Required Field power do not exists');
        if (this.mode === undefined) throw new Error('Required Field mode do not exists');
        if (this.targetTemperature === undefined) throw new Error('Required Field targetTemperature do not exists');
Severity: Minor
Found in src/models/ControlInfo.ts - About 6 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 overwrite has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public overwrite(obj: Partial<ControlInfo>) {
        if (obj.power !== undefined) this.power = obj.power;
        if (obj.mode !== undefined) this.mode = obj.mode;
        if (obj.targetTemperature !== undefined) this.targetTemperature = obj.targetTemperature;
        if (obj.targetHumidity !== undefined) this.targetHumidity = obj.targetHumidity;
Severity: Minor
Found in src/models/ControlInfo.ts - About 6 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

DaikinAC has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

export class DaikinAC {
    get currentACModelInfo(): ModelInfoResponse | null {
        return this._currentACModelInfo;
    }
    get currentACControlInfo(): ControlInfo | null {
Severity: Minor
Found in src/DaikinAC.ts - About 3 hrs to fix

    Function getRequestDict has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public getRequestDict(): RequestDict {
            const dict: RequestDict = {};
            if (this.power === undefined) throw new Error('Required Field power do not exists');
            if (this.mode === undefined) throw new Error('Required Field mode do not exists');
            if (this.targetTemperature === undefined) throw new Error('Required Field targetTemperature do not exists');
    Severity: Major
    Found in src/models/ControlInfo.ts - About 2 hrs to fix

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

          private addDevices(devices: { [name: string]: string }, logInitialDeviceConnection: boolean = false): void {
              const expectedAmount: number = Object.keys(devices).length;
              let connectedAmount: number = 0;
              let triedAmmount: number = 0;
              for (const key in devices) {
      Severity: Minor
      Found in src/DaikinManager.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 parseResponse has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static parseResponse(dict: ResponseDict, cb: DaikinResponseCb<ControlInfo>): void {
              const result = new ControlInfo();
              result.power = DaikinDataParser.resolveBool(dict, 'pow', Power);
              result.mode = DaikinDataParser.resolveInteger(dict, 'mode', Mode);
              result.targetTemperature = DaikinDataParser.resolveFloat(dict, 'stemp', AlternativeTemperatureTargets);
      Severity: Minor
      Found in src/models/ControlInfo.ts - About 1 hr to fix

        Function doPost has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public doPost(url: string, parameters: { [key: string]: any }, callback: ResponseHandler) {
                if (this.useGetToPost) {
                    this.doGet(url, parameters, callback);
                    return;
                }
        Severity: Minor
        Found in src/DaikinACRequest.ts - About 1 hr to fix

          Function overwrite has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public overwrite(obj: Partial<ControlInfo>) {
                  if (obj.power !== undefined) this.power = obj.power;
                  if (obj.mode !== undefined) this.mode = obj.mode;
                  if (obj.targetTemperature !== undefined) this.targetTemperature = obj.targetTemperature;
                  if (obj.targetHumidity !== undefined) this.targetHumidity = obj.targetHumidity;
          Severity: Minor
          Found in src/models/ControlInfo.ts - About 1 hr to fix

            Function doGet has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public doGet(url: string, parameters: RequestDict, callback: ResponseHandler) {
                    const reqParams = Object.assign({}, this.defaultParameters, parameters);
            
                    const data: any = {
                        parameters: reqParams,
            Severity: Minor
            Found in src/DaikinACRequest.ts - About 1 hr to fix

              Function processResponse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static processResponse<T>(
                      inputData: Error | string | Buffer,
                      callback?: DaikinResponseCb<T>,
                      requestDict: RequestDict = {},
                  ): ResponseDict | null {
              Severity: Minor
              Found in src/DaikinDataParser.ts - About 1 hr to fix

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

                    public static resolveFloat<T>(
                        dict: ResponseDict,
                        key: string,
                        altValues?: { [key: string]: number | T },
                    ): number | undefined | T {
                Severity: Minor
                Found in src/DaikinDataParser.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 parseResponse has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static parseResponse(dict: ResponseDict, cb: DaikinResponseCb<BasicInfoResponse>): void {
                        const result = new BasicInfoResponse();
                        result.type = DaikinDataParser.resolveString(dict, 'type', Type);
                        result.region = DaikinDataParser.resolveString(dict, 'reg');
                        result.dst = DaikinDataParser.resolveBool(dict, 'dst');
                Severity: Minor
                Found in src/models/responses/BasicInfoResponse.ts - About 1 hr to fix

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

                      public static resolveInteger<T>(
                          dict: ResponseDict,
                          key: string,
                          altValues?: { [key: string]: number | T },
                      ): number | undefined | T {
                  Severity: Minor
                  Found in src/DaikinDataParser.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

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

                      public static resolveString(
                          dict: ResponseDict,
                          key: string,
                          altValues?: { [key: string]: string },
                      ): string | undefined {
                  Severity: Minor
                  Found in src/DaikinDataParser.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 too many return statements within this function.
                  Open

                                  return null;
                  Severity: Major
                  Found in src/DaikinDataParser.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return dict;
                    Severity: Major
                    Found in src/DaikinDataParser.ts - About 30 mins to fix

                      Parsing error: parser.parse is not a function
                      Open

                      /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
                      Severity: Minor
                      Found in jest.config.js by eslint

                      For more information visit Source: http://eslint.org/docs/rules/

                      TODO found
                      Open

                              // TODO: Which parameterrs are really needed
                      Severity: Minor
                      Found in src/DaikinDiscovery.ts by fixme

                      TODO found
                      Open

                              // TODO: Also initialize DaicinAC instances?
                      Severity: Minor
                      Found in src/DaikinDiscovery.ts by fixme
                      Severity
                      Category
                      Status
                      Source
                      Language