RocketChat/Rocket.Chat

View on GitHub

Showing 3,268 of 8,229 total issues

Function constructor has 375 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(service: IServiceClass, notifications: NotificationsModule) {
        const logger = new Logger('ListenersModule');

        service.onEvent('license.sync', () => notifications.notifyAllInThisInstance('license'));
        service.onEvent('license.actions', () => notifications.notifyAllInThisInstance('license'));
Severity: Major
Found in apps/meteor/server/modules/listeners/listeners.module.ts - About 1 day to fix

    Function createGeneralSettings has 375 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        settingsRegistry.addGroup('General', async function () {
            await this.section('REST API', async function () {
                await this.add('API_Upper_Count_Limit', 100, { type: 'int', public: false });
                await this.add('API_Default_Count', 50, { type: 'int', public: false });
                await this.add('API_Allow_Infinite_Count', true, { type: 'boolean', public: false });
    Severity: Major
    Found in apps/meteor/server/settings/general.ts - About 1 day to fix

      Function createMessageSettings has 365 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          settingsRegistry.addGroup('Message', async function () {
              await this.section('Message_Attachments', async function () {
                  await this.add('Message_Attachments_Thumbnails_Enabled', true, {
                      type: 'boolean',
                      public: true,
      Severity: Major
      Found in apps/meteor/server/settings/message.ts - About 1 day to fix

        File accounts.ts has 767 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Random } from '@rocket.chat/random';
        
        import { settingsRegistry } from '../../app/settings/server';
        
        export const createAccountSettings = () =>
        Severity: Major
        Found in apps/meteor/server/settings/accounts.ts - About 1 day to fix

          Function AppearanceForm has 341 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const AppearanceForm = () => {
              const t = useTranslation();
              const isEnterprise = useHasLicenseModule('livechat-enterprise');
          
              const { control, watch } = useFormContext();
          Severity: Major
          Found in apps/meteor/client/views/omnichannel/appearance/AppearanceForm.tsx - About 1 day to fix

            Function ComposerPopupProvider has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
            Open

            const ComposerPopupProvider = ({ children, room }: { children: ReactNode; room: IRoom }) => {
                const { _id: rid } = room;
                const userSpotlight = useMethod('spotlight');
                const suggestionsCount = useSetting<number>('Number_of_users_autocomplete_suggestions');
                const cannedResponseEnabled = useSetting<boolean>('Canned_Responses_Enable');
            Severity: Minor
            Found in apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx - 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 RoomServiceReceiver.ts has 722 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // TODO: Refactor this file splitting it into smaller files + removing the complexity of the most important method (changeMembership)
            import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
            import { isDirectMessageRoom, isQuoteAttachment } from '@rocket.chat/core-typings';
            
            import { DirectMessageFederatedRoom, FederatedRoom } from '../../../domain/FederatedRoom';

              File chat.ts has 704 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Message } from '@rocket.chat/core-services';
              import type { IMessage } from '@rocket.chat/core-typings';
              import { Messages, Users, Rooms, Subscriptions } from '@rocket.chat/models';
              import { isChatReportMessageProps, isChatGetURLPreviewProps } from '@rocket.chat/rest-typings';
              import { escapeRegExp } from '@rocket.chat/string-helpers';
              Severity: Major
              Found in apps/meteor/app/api/server/v1/chat.ts - About 1 day to fix

                File VoIPUser.ts has 702 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /**
                 * Class representing SIP UserAgent
                 * @remarks
                 * This class encapsulates all the details of sip.js and exposes
                 * a very simple functions and callback handlers to the outside world.
                Severity: Major
                Found in apps/meteor/client/lib/voip/VoIPUser.ts - About 1 day to fix

                  Function useComposerBoxPopup has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
                      configurations,
                  }: {
                      configurations: ComposerBoxPopupOptions<T>[];
                  }): ComposerBoxPopupResult<T> => {
                  Severity: Minor
                  Found in apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.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 LivechatRooms.ts has 684 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import type {
                      ILivechatPriority,
                      IOmnichannelRoom,
                      IOmnichannelServiceLevelAgreements,
                      RocketChatRecordDeleted,
                  Severity: Major
                  Found in apps/meteor/ee/server/models/raw/LivechatRooms.ts - About 1 day to fix

                    File Connection.ts has 683 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import type {
                        ILDAPConnectionOptions,
                        LDAPEncryptionType,
                        LDAPSearchScope,
                        ILDAPEntry,
                    Severity: Major
                    Found in apps/meteor/server/lib/ldap/Connection.ts - About 1 day to fix

                      File Agenda.ts has 680 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { EventEmitter } from 'events';
                      
                      import debugInitializer from 'debug';
                      import humanInterval from 'human-interval';
                      import { MongoClient } from 'mongodb';
                      Severity: Major
                      Found in packages/agenda/src/Agenda.ts - About 1 day to fix

                        Function MessageBox has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const MessageBox = ({
                            tmid,
                            onSend,
                            onJoin,
                            onNavigateToNextMessage,
                        Severity: Minor
                        Found in apps/meteor/client/views/room/composer/messageBox/MessageBox.tsx - 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 initWatchers has 303 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function initWatchers(watcher: DatabaseWatcher, broadcast: BroadcastCallback): void {
                            // watch for changes on the database and broadcast them to the other instances
                            if (!dbWatchersDisabled) {
                                watcher.on<IMessage>(Messages.getCollectionName(), async ({ clientAction, id, data }) => {
                                    switch (clientAction) {
                        Severity: Major
                        Found in apps/meteor/server/modules/watchers/watchers.module.ts - About 1 day to fix

                          Function value has 301 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              const value: ComposerPopupContextValue = useMemo(() => {
                                  return [
                                      createMessageBoxPopupConfig({
                                          trigger: '@',
                                          title: t('People'),
                          Severity: Major
                          Found in apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx - About 1 day to fix

                            File Bridge.ts has 665 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import type { IMessage } from '@rocket.chat/core-typings';
                            import type { AppServiceOutput, Bridge } from '@rocket.chat/forked-matrix-appservice-bridge';
                            import { serverFetch as fetch } from '@rocket.chat/server-fetch';
                            
                            import type { IExternalUserProfileInformation, IFederationBridge, IFederationBridgeRegistrationFile } from '../../domain/IFederationBridge';

                              Function createSettings has 297 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export const createSettings = async (): Promise<void> => {
                                  await settingsRegistry.add('Livechat_abandoned_rooms_action', 'none', {
                                      type: 'select',
                                      group: 'Omnichannel',
                                      section: 'Sessions',
                              Severity: Major
                              Found in apps/meteor/ee/app/livechat-enterprise/server/settings.ts - About 1 day to fix

                                Function createFileUploadSettings has 286 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    settingsRegistry.addGroup('FileUpload', async function () {
                                        await this.add('FileUpload_Enabled', true, {
                                            type: 'boolean',
                                            public: true,
                                        });
                                Severity: Major
                                Found in apps/meteor/server/settings/file-upload.ts - About 1 day to fix

                                  Function useQuickActions has 285 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const useQuickActions = (): {
                                      quickActions: QuickActionsActionConfig[];
                                      actionDefault: (actionId: string) => void;
                                  } => {
                                      const room = useOmnichannelRoom();
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language