Codibre/grpc-base-client

View on GitHub

Showing 5 of 7 total issues

Function applyMiddlewares has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function applyMiddlewares<TService extends GrpcServiceDefinition>(
    client: TService,
    serviceMiddlewares: GrpcMiddlewares<TService> | undefined,
    MetadataClass: new () => Metadata,
) {
Severity: Minor
Found in src/utils/apply-middlewares.ts - About 2 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 overloadServices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export function overloadServices<TService extends GrpcServiceClient>(
    client: TService,
    config: ClientConfig | ReflectedClientConfig,
): TService {
    const prototype = Object.getPrototypeOf(client);
Severity: Minor
Found in src/utils/overload-services.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 applyMiddlewares has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function applyMiddlewares<TService extends GrpcServiceDefinition>(
    client: TService,
    serviceMiddlewares: GrpcMiddlewares<TService> | undefined,
    MetadataClass: new () => Metadata,
) {
Severity: Minor
Found in src/utils/apply-middlewares.ts - About 1 hr to fix

    Avoid deeply nested control flow statements.
    Open

                        if (isGrpcFunction(rawCall)) {
                            client[k] = ((
                                ...args: [
                                    Parameters<TService[keyof TService]>[0],
                                    Partial<CallOptions> | Metadata | undefined,
    Severity: Major
    Found in src/utils/apply-middlewares.ts - About 45 mins to fix

      Function runWrapped has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          rawCall: GrpcFunction<any, any>,
          client: TService,
          newArgs: [
              Parameters<TService[keyof TService]>[0],
              Metadata,
      Severity: Minor
      Found in src/utils/apply-middlewares.ts - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language