litleleprikon/socket-io-vscode

View on GitHub

Showing 5 of 6 total issues

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

export function start(context: ExtensionContext, connectFn: Connect) {

    function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable {
        const registeredCommand: Disposable = commands.registerCommand(command, callback);
        context.subscriptions.push(registeredCommand);
Severity: Minor
Found in src/extension.ts - About 1 hr to fix

    Function createConnection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private createConnection(url: string, timeout: number): Promise<any> {
            const _self = this;
    
            const makeConnection: Promise<any> = new Promise((resolve, reject) => {
                const socket: ISocket = _self.connectFn(url, { timeout });
    Severity: Minor
    Found in src/SocketIOConnectionFactory.ts - About 1 hr to fix

      Function makeConnection has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              const makeConnection: Promise<any> = new Promise((resolve, reject) => {
                  const socket: ISocket = _self.connectFn(url, { timeout });
                  socket
                      .on('connect', () => {
                          resolve(new SocketIOConnection(socket, async (event: string, data: any) => {
      Severity: Minor
      Found in src/SocketIOConnectionFactory.ts - About 1 hr to fix

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

            public getChildren(element?: SocketIOEventsItem | SocketIOEventsCollectionItem | SocketIOConnectionItem):
                Array<SocketIOEventsItem | SocketIOEventsCollectionItem | SocketIOConnectionItem> {
                if (!element) {
                    const elements: SocketIOConnectionItem[] = [];
                    for (const connection of this.collector.connections()) {
        Severity: Minor
        Found in src/SocketIOEventsTreeProvider.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

        Consider simplifying this complex logical expression.
        Open

                if (tmp['connection'] === undefined || !(typeof tmp['connection'] === 'string')
                    || tmp['event'] === undefined || !(typeof tmp['event'] === 'string')
                    || tmp['index'] === undefined || !(Number.isInteger(tmp['index']))) {
                    throw Errors.InvalidURI;
                }
        Severity: Major
        Found in src/SocketIOEventContentProvider.ts - About 40 mins to fix
          Severity
          Category
          Status
          Source
          Language