RocketChat/Rocket.Chat

View on GitHub

Showing 3,291 of 8,320 total issues

Function RegisterForm has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

export const RegisterForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
    const { t } = useTranslation();

    const requireNameForRegister = Boolean(useSetting('Accounts_RequireNameForSignUp'));
    const requiresPasswordConfirmation = useSetting('Accounts_RequirePasswordConfirmation');
Severity: Minor
Found in packages/web-ui-registration/src/RegisterForm.tsx - 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 ThreadList has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ThreadList: VFC = () => {
    const t = useTranslation();

    const { closeTab } = useRoomToolbox();

Severity: Major
Found in apps/meteor/client/views/room/contextualBar/Threads/ThreadList.tsx - About 6 hrs to fix

    Function ChatTable has 152 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ChatTable = () => {
        const t = useTranslation();
        const [text, setText] = useState('');
        const userIdLoggedIn = useUserId();
        const directoryRoute = useRoute('omnichannel-directory');
    Severity: Major
    Found in apps/meteor/client/views/omnichannel/directory/chats/ChatTable.tsx - About 6 hrs to fix

      Function MailerPage has 151 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const MailerPage = () => {
          const t = useTranslation();
          const dispatchToastMessage = useToastMessageDispatch();
      
          const {
      Severity: Major
      Found in apps/meteor/client/views/admin/mailer/MailerPage.tsx - About 6 hrs to fix

        MatrixBridge has 44 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class MatrixBridge implements IFederationBridge {
            protected bridgeInstance: Bridge;
        
            protected isRunning = false;
        
        

          Function MonitorsTable has 150 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const MonitorsTable = () => {
              const t = useTranslation();
              const setModal = useSetModal();
          
              const [text, setText] = useState('');
          Severity: Major
          Found in apps/meteor/ee/client/omnichannel/monitors/MonitorsTable.tsx - About 6 hrs to fix

            Function updateIncomingIntegration has 148 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async updateIncomingIntegration(integrationId, integration) {
                    if (!this.userId) {
                        throw new Meteor.Error('error-invalid-user', 'Invalid user', {
                            method: 'updateOutgoingIntegration',
                        });

              Function ContactTable has 148 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function ContactTable(): ReactElement {
                  const { current, itemsPerPage, setItemsPerPage, setCurrent, ...paginationProps } = usePagination();
                  const { sortBy, sortDirection, setSort } = useSort<'username' | 'phone' | 'name' | 'visitorEmails.address' | 'lastchat'>('username');
                  const isCallReady = useIsCallReady();
              
              

                Function convertMessages has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                    async convertMessages({
                        beforeImportFn,
                        afterImportFn,
                        onErrorFn,
                        afterImportAllMessagesFn,
                Severity: Minor
                Found in apps/meteor/app/importer/server/classes/ImportDataConverter.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

                Function NewImportPage has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                function NewImportPage() {
                    const t = useTranslation();
                    const dispatchToastMessage = useToastMessageDispatch();
                    const handleError = useErrorHandler();
                
                
                Severity: Minor
                Found in apps/meteor/client/views/admin/import/NewImportPage.tsx - 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

                Function RoomBody has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                Open

                const RoomBody = (): ReactElement => {
                    const chat = useChat();
                    if (!chat) {
                        throw new Error('No ChatContext provided');
                    }
                Severity: Minor
                Found in apps/meteor/client/views/room/body/RoomBody.tsx - 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 rocketchat.e2e.ts has 413 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import QueryString from 'querystring';
                import URL from 'url';
                
                import type { IE2EEMessage, IMessage, IRoom, ISubscription } from '@rocket.chat/core-typings';
                import { isE2EEMessage } from '@rocket.chat/core-typings';
                Severity: Minor
                Found in apps/meteor/app/e2e/client/rocketchat.e2e.ts - About 5 hrs to fix

                  File push.ts has 412 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import type { IAppsTokens, RequiredField, Optional, IPushNotificationConfig } from '@rocket.chat/core-typings';
                  import { AppsTokens } from '@rocket.chat/models';
                  import { serverFetch as fetch } from '@rocket.chat/server-fetch';
                  import { pick } from '@rocket.chat/tools';
                  import Ajv from 'ajv';
                  Severity: Minor
                  Found in apps/meteor/app/push/server/push.ts - About 5 hrs to fix

                    Function ImportProgressPage has 147 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const ImportProgressPage = function ImportProgressPage() {
                        const queryClient = useQueryClient();
                        const streamer = useStream('importers');
                        const t = useTranslation();
                        const dispatchToastMessage = useToastMessageDispatch();
                    Severity: Major
                    Found in apps/meteor/client/views/admin/import/ImportProgressPage.tsx - About 5 hrs to fix

                      File templates.ts has 411 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import type { LayoutBlock } from '@rocket.chat/ui-kit';
                      import { SurfaceOptions } from '../Components/Preview/Display/Surface/constant';
                      
                      type payload = {
                        surface: SurfaceOptions;
                      Severity: Minor
                      Found in packages/uikit-playground/src/utils/templates.ts - About 5 hrs to fix

                        File listeners.module.ts has 411 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import type { AppStatus } from '@rocket.chat/apps-engine/definition/AppStatus';
                        import type { ISetting as AppsSetting } from '@rocket.chat/apps-engine/definition/settings';
                        import type { IServiceClass } from '@rocket.chat/core-services';
                        import { EnterpriseSettings } from '@rocket.chat/core-services';
                        import { isSettingColor, isSettingEnterprise, UserStatus } from '@rocket.chat/core-typings';
                        Severity: Minor
                        Found in apps/meteor/server/modules/listeners/listeners.module.ts - About 5 hrs to fix

                          File SAML.ts has 409 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import type { ServerResponse } from 'http';
                          
                          import type { IUser, IIncomingMessage, IPersonalAccessToken } from '@rocket.chat/core-typings';
                          import { CredentialTokens, Rooms, Users } from '@rocket.chat/models';
                          import { Random } from '@rocket.chat/random';
                          Severity: Minor
                          Found in apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts - About 5 hrs to fix

                            Function insertAdminUserFromEnv has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export async function insertAdminUserFromEnv() {
                                if (process.env.ADMIN_PASS) {
                                    if ((await (await getUsersInRole('admin')).count()) === 0) {
                                        const adminUser = {
                                            name: 'Administrator',
                            Severity: Minor
                            Found in apps/meteor/server/startup/initialData.js - 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

                            Function onUserStream has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                            Open

                                async onUserStream(type: string, data: IOnUserStreamData): Promise<void> {
                                    switch (type) {
                                        case 'handshake':
                                            let timeout: NodeJS.Timeout;
                            
                            
                            Severity: Minor
                            Found in apps/meteor/app/otr/client/OTRRoom.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

                            Function createRetentionSettings has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                settingsRegistry.addGroup('RetentionPolicy', async function () {
                                    const globalQuery = {
                                        _id: 'RetentionPolicy_Enabled',
                                        value: true,
                                    };
                            Severity: Major
                            Found in apps/meteor/server/settings/retention-policy.ts - About 5 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language