airdcpp-web/airdcpp-apisocket-js

View on GitHub

Showing 10 of 12 total issues

Function ApiSocket has 327 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ApiSocket = (userOptions: Options.APISocketOptions, WebSocketImpl: WebSocket) => {
  const options: FullOptions = {
    ...defaultOptions, 
    ...userOptions
  };
Severity: Major
Found in src/SocketBase.ts - About 1 day to fix

    Function ApiSocket has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
    Open

    const ApiSocket = (userOptions: Options.APISocketOptions, WebSocketImpl: WebSocket) => {
      const options: FullOptions = {
        ...defaultOptions, 
        ...userOptions
      };
    Severity: Minor
    Found in src/SocketBase.ts - About 1 day 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 SocketSubscriptionHandler has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    const SocketSubscriptionHandler = (
      socket: () => Socket.APISocket, 
      logger: Logger, 
      { ignoredListenerEvents = [] }: Options.SocketSubscriptionOptions
    ) => {
    Severity: Minor
    Found in src/SocketSubscriptionHandler.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 SocketRequestHandler has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    const SocketRequestHandler = (
      socket: () => Socket.APISocket,
      logger: Logger, 
      { requestTimeout = 30, ignoredRequestPaths }: Options.SocketRequestOptions
    ) => {
    Severity: Minor
    Found in src/SocketRequestHandler.ts - About 5 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

    File SocketBase.ts has 351 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import ApiConstants from './ApiConstants.js';
    
    import SocketLogger from './SocketLogger.js';
    import SocketSubscriptionHandler from './SocketSubscriptionHandler.js';
    import SocketRequestHandler from './SocketRequestHandler.js';
    Severity: Minor
    Found in src/SocketBase.ts - About 4 hrs to fix

      Function addContextMenuItems has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      export const addContextMenuItems = async <IdT, EntityIdT extends EntityId | undefined = undefined>(
        socket: APISocket,
        menuItems: ContextMenuItem<IdT, EntityIdT>[],
        menuTypeId: string,
        menu: ContextMenu
      Severity: Minor
      Found in src/PublicHelpers.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 addContextMenuItems has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const addContextMenuItems = async <IdT, EntityIdT extends EntityId | undefined = undefined>(
        socket: APISocket,
        menuItems: ContextMenuItem<IdT, EntityIdT>[],
        menuTypeId: string,
        menu: ContextMenu
      Severity: Minor
      Found in src/PublicHelpers.ts - About 2 hrs to fix

        Function sendRequest has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const sendRequest = <DataT extends object | undefined>(
            method: string, path: string, data?: DataT, authenticating: boolean = false
          ) => {
            // Pre-checks
            if (!authenticating && !socket().isConnected()) {
        Severity: Minor
        Found in src/SocketRequestHandler.ts - About 1 hr to fix

          Function handleMessage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              handleMessage(messageObj: APIInternal.RequestSuccessResponse | APIInternal.RequestErrorResponse) {
                const id = messageObj.callback_id;
                if (!callbacks.hasOwnProperty(id)) {
                  logger.warn('No pending request for an API response', id, messageObj);
                  return;
          Severity: Minor
          Found in src/SocketRequestHandler.ts - About 1 hr to fix

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

            const parseCallbackData = async <IdT, EntityIdT extends EntityId | undefined = undefined>(
              item: ContextMenuItem<IdT, EntityIdT>,
              data: MenuItemListHookData<IdT, EntityIdT>
            ): Promise<ResponseMenuItemCallbackFields> => {
              const { selected_ids, entity_id, permissions, supports } = data;
            Severity: Minor
            Found in src/PublicHelpers.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

            Severity
            Category
            Status
            Source
            Language