avegao/aws-athena-node-client

View on GitHub

Showing 8 of 8 total issues

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

    private setColumnParsers(results: ResultSet): Column[] {
        return results.ResultSetMetadata?.ColumnInfo?.map((columnInfo, index) => {
            const name = columnInfo.Name ?? `column_${index}`;
            let parse: ColumnParse;

Severity: Minor
Found in src/index.ts - About 1 hr to fix

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

        private async startQueryExecution<T>(query: Query<T>): Promise<string> {
            const input: StartQueryExecutionCommandInput = {
                QueryExecutionContext: {
                    Database: this._config.database,
                },
    Severity: Minor
    Found in src/index.ts - About 1 hr to fix

      Function getQueryResults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private async getQueryResults<T extends object>(query: Query<T>, nextToken?: string): Promise<T[]> {
              const input: GetQueryResultsInput = {
                  NextToken: nextToken,
                  QueryExecutionId: query.athenaId,
              };
      Severity: Minor
      Found in src/index.ts - About 25 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 parseArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public static parseArray(arrayInString: string): number[] | string[] {
              arrayInString = arrayInString.replace(/[\[\]]/gi, '');
      
              if (arrayInString == null || arrayInString === '') {
                  return [];
      Severity: Minor
      Found in src/Column.ts - About 25 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

      Shadowed name: 'query'
      Open

              const query = this.queries.find((query) => query.id === id);
      Severity: Minor
      Found in src/Queue.ts by tslint

      Rule: no-shadowed-variable

      Disallows shadowing variable declarations.

      Rationale

      When a variable in a local scope and a variable in the containing scope have the same name, shadowing occurs. Shadowing makes it impossible to access the variable in the containing scope and obscures to what value an identifier actually refers. Compare the following snippets:

      const a = 'no shadow';
      function print() {
          console.log(a);
      }
      print(); // logs 'no shadow'.
      const a = 'no shadow';
      function print() {
          const a = 'shadow'; // TSLint will complain here.
          console.log(a);
      }
      print(); // logs 'shadow'.

      ESLint has an equivalent rule. For more background information, refer to this MDN closure doc.

      Config

      You can optionally pass an object to disable checking for certain kinds of declarations. Possible keys are "class", "enum", "function", "import", "interface", "namespace", "typeAlias" and "typeParameter". You can also pass "underscore" to ignore variable names that begin with _. Just set the value to false for the check you want to disable. All checks default to true, i.e. are enabled by default. Note that you cannot disable variables and parameters.

      The option "temporalDeadZone" defaults to true which shows errors when shadowing block scoped declarations in their temporal dead zone. When set to false parameters, classes, enums and variables declared with let or const are not considered shadowed if the shadowing occurs within their temporal dead zone.

      The following example shows how the "temporalDeadZone" option changes the linting result:

      function fn(value) {
          if (value) {
              const tmp = value; // no error on this line if "temporalDeadZone" is false
              return tmp;
          }
          let tmp = undefined;
          if (!value) {
              const tmp = value; // this line always contains an error
              return tmp;
          }
      }
      Examples
      "no-shadowed-variable": true
      "no-shadowed-variable": true,[object Object]
      Schema
      {
        "type": "object",
        "properties": {
          "class": {
            "type": "boolean"
          },
          "enum": {
            "type": "boolean"
          },
          "function": {
            "type": "boolean"
          },
          "import": {
            "type": "boolean"
          },
          "interface": {
            "type": "boolean"
          },
          "namespace": {
            "type": "boolean"
          },
          "typeAlias": {
            "type": "boolean"
          },
          "typeParameter": {
            "type": "boolean"
          },
          "temporalDeadZone": {
            "type": "boolean"
          },
          "underscore": {
            "type": "boolean"
          }
        }
      }

      For more information see this page.

      Identifier 'numberValue' is never reassigned; use 'const' instead of 'let'.
      Open

                  let numberValue = Number(value);
      Severity: Minor
      Found in src/Column.ts by tslint

      Rule: prefer-const

      Requires that variable declarations use const instead of let and var if possible.

      If a variable is only assigned to once when it is declared, it should be declared using 'const'

      Notes
      • Has Fix

      Config

      An optional object containing the property "destructuring" with two possible values:

      • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
      • "all" - Only warns if all variables in destructuring can be const.
      Examples
      "prefer-const": true
      "prefer-const": true,[object Object]
      Schema
      {
        "type": "object",
        "properties": {
          "destructuring": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          }
        }
      }

      For more information see this page.

      Missing semicolon
      Open

      })
      Severity: Minor
      Found in vitest.config.ts by tslint

      Rule: semicolon

      Enforces consistent semicolon usage at the end of every statement.

      Notes
      • Has Fix

      Config

      One of the following arguments must be provided:

      • "always" enforces semicolons at the end of every statement.
      • "never" disallows semicolons at the end of every statement except for when they are necessary.

      The following arguments may be optionally provided:

      • "ignore-interfaces" skips checking semicolons at the end of interface members.
      • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
      • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
      Examples
      "semicolon": true,always
      "semicolon": true,never
      "semicolon": true,always,ignore-interfaces
      "semicolon": true,always,ignore-bound-class-methods
      Schema
      {
        "type": "array",
        "items": [
          {
            "type": "string",
            "enum": [
              "always",
              "never"
            ]
          },
          {
            "type": "string",
            "enum": [
              "ignore-interfaces"
            ]
          }
        ],
        "additionalItems": false
      }

      For more information see this page.

      Type assertion on object literals is forbidden, use a type annotation instead.
      Open

              const result = {} as T;
      Severity: Minor
      Found in src/index.ts by tslint

      Rule: no-object-literal-type-assertion

      Forbids an object literal to appear in a type assertion expression. Casting to any or to unknown is still allowed.

      Rationale

      Always prefer const x: T = { ... }; to const x = { ... } as T;. The type assertion in the latter case is either unnecessary or hides an error. The compiler will warn for excess properties with this syntax, but not missing required fields. For example: const x: { foo: number } = {} will fail to compile, but const x = {} as { foo: number } will succeed. Additionally, the const assertion const x = { foo: 1 } as const, introduced in TypeScript 3.4, is considered beneficial and is ignored by this rule.

      Notes
      • TypeScript Only

      Config

      One option may be configured:

      • allow-arguments allows type assertions to be used on object literals inside call expressions.
      Examples
      "no-object-literal-type-assertion": true
      "no-object-literal-type-assertion": true,[object Object]
      Schema
      {
        "type": "object",
        "properties": {
          "allow-arguments": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }

      For more information see this page.

      Severity
      Category
      Status
      Source
      Language