RocketChat/Rocket.Chat

View on GitHub

Showing 3,268 of 8,229 total issues

File Helper.ts has 638 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { LivechatTransferEventType } from '@rocket.chat/apps-engine/definition/livechat';
import { api, Message, Omnichannel } from '@rocket.chat/core-services';
import type {
    ILivechatVisitor,
    IOmnichannelRoom,
Severity: Major
Found in apps/meteor/app/livechat/server/lib/Helper.ts - About 1 day to fix

    Function AccountProfileForm has 280 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactElement => {
        const t = useTranslation();
        const user = useUser();
        const dispatchToastMessage = useToastMessageDispatch();
    
    
    Severity: Major
    Found in apps/meteor/client/views/account/profile/AccountProfileForm.tsx - About 1 day to fix

      File FileUpload.ts has 629 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Buffer } from 'buffer';
      import type { WriteStream } from 'fs';
      import fs from 'fs';
      import { unlink, rename, writeFile } from 'fs/promises';
      import type * as http from 'http';
      Severity: Major
      Found in apps/meteor/app/file-upload/server/lib/FileUpload.ts - About 1 day to fix

        Function createComposerAPI has 275 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const createComposerAPI = (input: HTMLTextAreaElement, storageID: string): ComposerAPI => {
            const triggerEvent = (input: HTMLTextAreaElement, evt: string): void => {
                const event = new Event(evt, { bubbles: true });
                // TODO: Remove this hack for react to trigger onChange
                const tracker = (input as any)._valueTracker;
        Severity: Major
        Found in apps/meteor/app/ui-message/client/messageBox/createComposerAPI.ts - About 1 day to fix

          Function prepareUsingLocalFile has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
          Open

              async prepareUsingLocalFile(fullFilePath: string): Promise<ImporterProgress> {
                  this.logger.debug('start preparing import operation');
                  await this.converter.clearImportData();
          
                  const zip = new this.AdmZip(fullFilePath);
          Severity: Minor
          Found in apps/meteor/app/importer-csv/server/CsvImporter.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

          File SlackImporter.ts has 614 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type { IImportUser, IImportMessage, IImportPendingFile } from '@rocket.chat/core-typings';
          import { Messages, Settings, ImportData } from '@rocket.chat/models';
          import type { IZipEntry } from 'adm-zip';
          
          import { Importer, ProgressStep, ImporterWebsocket } from '../../importer/server';
          Severity: Major
          Found in apps/meteor/app/importer-slack/server/SlackImporter.ts - About 1 day to fix

            Function prepareMessageObject has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
            Open

                async prepareMessageObject(message: SlackMessage, missedTypes: Record<string, SlackMessage>, slackChannelId: string): Promise<void> {
                    const id = this.makeSlackMessageId(slackChannelId, message.ts);
                    const newMessage: IImportMessage = {
                        _id: id,
                        rid: slackChannelId,
            Severity: Minor
            Found in apps/meteor/app/importer-slack/server/SlackImporter.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 addOAuthService has 256 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function addOAuthService(name: string, values: { [k: string]: string | boolean | undefined } = {}): Promise<void> {
                name = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
                name = capitalize(name);
                await settingsRegistry.add(`Accounts_OAuth_Custom-${name}`, values.enabled || false, {
                    type: 'boolean',
            Severity: Major
            Found in apps/meteor/server/lib/oauth/addOAuthService.ts - About 1 day to fix

              Function NewImportPage has 256 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function NewImportPage() {
                  const t = useTranslation();
                  const dispatchToastMessage = useToastMessageDispatch();
                  const handleError = useErrorHandler();
              
              
              Severity: Major
              Found in apps/meteor/client/views/admin/import/NewImportPage.tsx - About 1 day to fix

                File VideoConfManager.ts has 583 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import type { IRoom, IUser } from '@rocket.chat/core-typings';
                import { Emitter } from '@rocket.chat/emitter';
                import { Meteor } from 'meteor/meteor';
                import { Tracker } from 'meteor/tracker';
                
                
                Severity: Major
                Found in apps/meteor/client/lib/VideoConfManager.ts - About 1 day to fix

                  File EmailInboxForm.tsx has 581 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import type { IEmailInboxPayload } from '@rocket.chat/core-typings';
                  import {
                      Accordion,
                      Button,
                      ButtonGroup,
                  Severity: Major
                  Found in apps/meteor/client/views/admin/emailInbox/EmailInboxForm.tsx - About 1 day to fix

                    File triggerHandler.js has 580 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import { Integrations, Users, Rooms, Messages } from '@rocket.chat/models';
                    import { serverFetch as fetch } from '@rocket.chat/server-fetch';
                    import { wrapExceptions } from '@rocket.chat/tools';
                    import { Meteor } from 'meteor/meteor';
                    import _ from 'underscore';
                    Severity: Major
                    Found in apps/meteor/app/integrations/server/lib/triggerHandler.js - About 1 day to fix

                      File widget.ts has 576 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import type { UserStatus } from '@rocket.chat/core-typings';
                      import type { LivechatRoomEvents } from '@rocket.chat/ddp-client/dist/livechat/types/LivechatSDK';
                      import mitt from 'mitt';
                      
                      import { isDefined } from './helpers/isDefined';
                      Severity: Major
                      Found in packages/livechat/src/widget.ts - About 1 day to fix

                        Function createDataAPI has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage['_id'] | undefined }): DataAPI => {
                            const composeMessage = async (
                                text: string,
                                { sendToChannel, quotedMessages, originalMessage }: { sendToChannel?: boolean; quotedMessages: IMessage[]; originalMessage?: IMessage },
                            ): Promise<IMessage> => {
                        Severity: Minor
                        Found in apps/meteor/client/lib/chats/data.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 addUser has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async addUser(slackUserID) {
                                rocketLogger.debug('Adding Rocket.Chat user from Slack', slackUserID);
                                let addedUser;
                                for await (const slack of this.slackAdapters) {
                                    if (addedUser) {
                        Severity: Minor
                        Found in apps/meteor/app/slackbridge/server/RocketAdapter.js - 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

                        File teams.ts has 565 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { Team } from '@rocket.chat/core-services';
                        import type { ITeam, UserStatus } from '@rocket.chat/core-typings';
                        import { TEAM_TYPE } from '@rocket.chat/core-typings';
                        import { Users, Rooms } from '@rocket.chat/models';
                        import {
                        Severity: Major
                        Found in apps/meteor/app/api/server/v1/teams.ts - About 1 day to fix

                          File index.js has 553 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /*
                          
                              Node.js POP3 client library
                          
                              Copyright (C) 2011-2013 by Ditesh Shashikant Gathani <ditesh@gathani.org>
                          Severity: Major
                          Found in packages/node-poplib/src/index.js - About 1 day to fix

                            Function executeTriggerUrl has 229 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                async executeTriggerUrl(url, trigger, { event, message, room, owner, user }, theHistoryId, tries = 0) {
                                    if (!this.isTriggerEnabled(trigger)) {
                                        outgoingLogger.warn(`The trigger "${trigger.name}" is no longer enabled, stopping execution of it at try: ${tries}`);
                                        return;
                                    }
                            Severity: Major
                            Found in apps/meteor/app/integrations/server/lib/triggerHandler.js - About 1 day to fix

                              Function reducer has 229 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const reducer = (state: initialStateType, action: IAction) => {
                                const { activeProject, activeScreen } = state;
                                switch (action.type) {
                                  case ActionTypes.IsMobile:
                                    return { ...state, isMobile: action.payload };
                              Severity: Major
                              Found in packages/uikit-playground/src/Context/reducer.ts - About 1 day to fix

                                Function RoomBody has 229 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const RoomBody = (): ReactElement => {
                                    const chat = useChat();
                                    if (!chat) {
                                        throw new Error('No ChatContext provided');
                                    }
                                Severity: Major
                                Found in apps/meteor/client/views/room/body/RoomBody.tsx - About 1 day to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language