RocketChat/Rocket.Chat

View on GitHub

Showing 3,448 of 8,947 total issues

Function onTestEnd has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async onTestEnd(test: TestCase, result: TestResult) {
        if (process.env.REPORTER_ROCKETCHAT_REPORT !== 'true') {
            return;
        }

Severity: Major
Found in apps/meteor/reporters/jira.ts - About 5 hrs to fix

    File LivechatDepartment.ts has 398 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import type { ILivechatDepartment, RocketChatRecordDeleted } from '@rocket.chat/core-typings';
    import type { ILivechatDepartmentModel } from '@rocket.chat/model-typings';
    import { LivechatDepartmentAgents, LivechatUnitMonitors } from '@rocket.chat/models';
    import { escapeRegExp } from '@rocket.chat/string-helpers';
    import type {
    Severity: Minor
    Found in apps/meteor/server/models/raw/LivechatDepartment.ts - About 5 hrs to fix

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

          constructor(options: StoreOptions) {
              options = {
                  onCopyError: this.onCopyError,
                  onFinishUpload: this.onFinishUpload,
                  onRead: this.onRead,
      Severity: Major
      Found in apps/meteor/server/ufs/ufs-store.ts - About 5 hrs to fix

        File service.ts has 396 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import type { IOmnichannelVoipService, FindVoipRoomsParams } from '@rocket.chat/core-services';
        import { api, ServiceClassInternal, VoipAsterisk } from '@rocket.chat/core-services';
        import type {
            IVoipExtensionBase,
            IVoipExtensionWithAgentInfo,
        Severity: Minor
        Found in apps/meteor/server/services/omnichannel-voip/service.ts - About 5 hrs to fix

          File license.ts has 396 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type {
              ILicenseTag,
              LicenseEvents,
              ILicenseV2,
              ILicenseV3,
          Severity: Minor
          Found in ee/packages/license/src/license.ts - About 5 hrs to fix

            VideoConfManager has 41 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export const VideoConfManager = new (class VideoConfManager extends Emitter<VideoConfEvents> {
                private userId: string | undefined;
            
                private currentCallHandler: ReturnType<typeof setTimeout> | undefined;
            
            
            Severity: Minor
            Found in apps/meteor/client/lib/VideoConfManager.ts - About 5 hrs to fix

              Function LeaveMessage has 136 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const LeaveMessage: FunctionalComponent<{ path: string }> = () => {
                  const {
                      config: {
                          departments = [],
                          messages: { offlineMessage, offlineSuccessMessage, offlineUnavailableMessage },
              Severity: Major
              Found in packages/livechat/src/routes/LeaveMessage/index.tsx - About 5 hrs to fix

                Function onChangeRoomMembership has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public async onChangeRoomMembership(roomChangeMembershipInput: FederationRoomChangeMembershipDto): Promise<void> {
                        const {
                            externalRoomId,
                            normalizedInviteeId,
                            normalizedRoomId,

                  Function PruneMessagesWithData has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const PruneMessagesWithData = (): ReactElement => {
                      const t = useTranslation();
                      const room = useRoom();
                      const setModal = useSetModal();
                      const { closeTab: close } = useRoomToolbox();

                    Function saveUserProfile has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function saveUserProfile(
                        this: Meteor.MethodThisType,
                        settings: {
                            email?: string;
                            username?: string;
                    Severity: Minor
                    Found in apps/meteor/server/methods/saveUserProfile.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 inviteAll has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function inviteAll<T extends string>(type: T): SlashCommand<T>['callback'] {
                        return async function inviteAll({ command, params, message, userId }: SlashCommandCallbackParams<T>): Promise<void> {
                            if (!/invite\-all-(to|from)/.test(command)) {
                                return;
                            }
                    Severity: Minor
                    Found in apps/meteor/app/slashcommands-inviteall/server/server.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 insertOrUpdateSAMLUser has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static async insertOrUpdateSAMLUser(userObject: ISAMLUser): Promise<{ userId: string; token: string }> {
                            const {
                                generateUsername,
                                immutableProperty,
                                nameOverwrite,
                    Severity: Minor
                    Found in apps/meteor/app/meteor-accounts-saml/server/lib/SAML.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 RoomBody has a Cognitive Complexity of 36 (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/RoomBodyV2.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 compareBSONValues has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export const compareBSONValues = (a: unknown, b: unknown): number => {
                        if (a === undefined) {
                            return b === undefined ? 0 : -1;
                        }
                    
                    
                    Severity: Minor
                    Found in apps/meteor/client/lib/minimongo/bson.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 LivechatInquiry.ts has 392 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import type {
                        ILivechatInquiryRecord,
                        IMessage,
                        RocketChatRecordDeleted,
                        OmnichannelSortingMechanismSettingType,
                    Severity: Minor
                    Found in apps/meteor/server/models/raw/LivechatInquiry.ts - About 5 hrs to fix

                      Function onEmailReceived has 135 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function onEmailReceived(email: ParsedMail, inbox: string, department = ''): Promise<void> {
                          logger.info(`New email conversation received on inbox ${inbox}. Will be assigned to department ${department}`);
                          if (!email.from?.value?.[0]?.address) {
                              return;
                          }
                      Severity: Major
                      Found in apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.ts - About 5 hrs to fix

                        File saveUser.js has 391 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { Apps, AppEvents } from '@rocket.chat/apps';
                        import { isUserFederated } from '@rocket.chat/core-typings';
                        import { Users } from '@rocket.chat/models';
                        import Gravatar from 'gravatar';
                        import { Accounts } from 'meteor/accounts-base';
                        Severity: Minor
                        Found in apps/meteor/app/lib/server/functions/saveUser.js - About 5 hrs to fix

                          File ModerationReports.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import type {
                              IMessage,
                              IModerationAudit,
                              IModerationReport,
                              RocketChatRecordDeleted,
                          Severity: Minor
                          Found in apps/meteor/server/models/raw/ModerationReports.ts - About 5 hrs to fix

                            File MessageTypes.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import type { MessageTypesValues as MessageTypesValuesType } from '@rocket.chat/core-typings';
                            import { Meteor } from 'meteor/meteor';
                            
                            import { MessageTypes } from '../../ui-utils/lib/MessageTypes';
                            // import { callbacks } from '../../../lib/callbacks';
                            Severity: Minor
                            Found in apps/meteor/app/lib/lib/MessageTypes.ts - About 5 hrs to fix

                              File OTRRoom.ts has 390 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import type { IRoom, IMessage, IUser } from '@rocket.chat/core-typings';
                              import { UserStatus } from '@rocket.chat/core-typings';
                              import { Random } from '@rocket.chat/random';
                              import EJSON from 'ejson';
                              import { Meteor } from 'meteor/meteor';
                              Severity: Minor
                              Found in apps/meteor/app/otr/client/OTRRoom.ts - About 5 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language