drg-adaptive/api-gateway-request-signer

View on GitHub

Showing 4 of 4 total issues

File index.ts has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Taken from https://github.com/AnomalyInnovations/sigV4Client and converted to typescript
// For an example of the original library, see https://serverless-stack.com/chapters/connect-to-api-gateway-with-iam-auth.html

import { LibWordArray } from "crypto-js";
import encHex from "crypto-js/enc-hex";
Severity: Minor
Found in src/index.ts - About 3 hrs to fix

    Function signRequest has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      signRequest(request: RequestToSign): SignedRequestData {
        const verb = request.method.toUpperCase();
        const path = this.pathComponent + request.path;
        const queryParams = { ...request.queryParams };
        const headers = { ...request.headers };
    Severity: Major
    Found in src/index.ts - About 2 hrs to fix

      Function signRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        signRequest(request: RequestToSign): SignedRequestData {
          const verb = request.method.toUpperCase();
          const path = this.pathComponent + request.path;
          const queryParams = { ...request.queryParams };
          const headers = { ...request.headers };
      Severity: Minor
      Found in src/index.ts - About 55 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 buildCanonicalRequest has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        method: string,
        path: string,
        queryParams: { [x: string]: string | number | boolean },
        headers: any,
        payload: string
      Severity: Minor
      Found in src/index.ts - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language