RocketChat/Rocket.Chat

View on GitHub

Showing 3,299 of 8,337 total issues

Function sendReplyMessageFileToThread has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async sendReplyMessageFileToThread(
        externalRoomId: string,
        externalSenderId: string,
        content: Buffer,
        fileDetails: { filename: string; fileSize: number; mimeType: string; metadata?: { width?: number; height?: number; format?: string } },
Severity: Minor
Found in apps/meteor/server/services/federation/infrastructure/matrix/Bridge.ts - About 25 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

Function sendReplyMessageFileToRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async sendReplyMessageFileToRoom(
        externalRoomId: string,
        externaSenderId: string,
        content: Buffer,
        fileDetails: { filename: string; fileSize: number; mimeType: string; metadata?: { width?: number; height?: number; format?: string } },
Severity: Minor
Found in apps/meteor/server/services/federation/infrastructure/matrix/Bridge.ts - About 25 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

Function userDataDownloadHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const userDataDownloadHandler = async (req: IncomingMessage, res: ServerResponse, next: () => void) => {
    const downloadEnabled = settings.get<boolean>('UserData_EnableDownload');
    if (!downloadEnabled) {
        res.writeHead(403).end();
        return;
Severity: Minor
Found in apps/meteor/server/routes/userDataDownload.ts - About 25 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

Function toSendRoomFileMessageDto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static toSendRoomFileMessageDto(externalEvent: MatrixEventRoomMessageSent): FederationRoomReceiveExternalFileMessageDto {
        if (!externalEvent.content.url) {
            throw new Error('Missing url in the file message');
        }
        if (!externalEvent.content.info?.mimetype) {

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 onMessageReaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async onMessageReaction(messageReactionEventInput: FederationMessageReactionEventDto): Promise<void> {
        const {
            externalRoomId,
            emoji,
            externalSenderId,

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 onExternalFileMessageReceived has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async onExternalFileMessageReceived(roomReceiveExternalMessageInput: FederationRoomReceiveExternalFileMessageDto): Promise<void> {
        const { externalRoomId, externalSenderId, messageBody, externalEventId, replyToEventId } = roomReceiveExternalMessageInput;

        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
        if (!federatedRoom) {

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 handleDMRoomInviteWhenAllUsersWereBeingProvidedInTheCreationalEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private async handleDMRoomInviteWhenAllUsersWereBeingProvidedInTheCreationalEvent(
        allInviteesExternalIds: {
            externalInviteeId: string;
            normalizedInviteeId: string;
            inviteeUsernameOnly: string;

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 afterUserRealNameChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async afterUserRealNameChanged(internalUserId: string, name: string): Promise<void> {
        const federatedUser = await this.internalUserAdapter.getFederatedUserByInternalId(internalUserId);
        if (!federatedUser) {
            const internalUser = await this.internalUserAdapter.getInternalUserById(internalUserId);
            if (!internalUser) {

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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(options: GridFSStoreOptions) {
        // Default options
        options = Object.assign(
            {
                chunkSize: 1024 * 255,
Severity: Minor
Found in apps/meteor/server/ufs/ufs-gridfs.ts - About 25 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

Function recursiveRemoveAttachments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const recursiveRemoveAttachments = (attachments: MessageAttachment, deep = 1, quoteChainLimit: number): MessageAttachment => {
    if (attachments && isQuoteAttachment(attachments)) {
        if (deep < quoteChainLimit - 1) {
            attachments.attachments?.map((msg) => recursiveRemoveAttachments(msg, deep + 1, quoteChainLimit));
        } else {
Severity: Minor
Found in apps/meteor/server/services/messages/hooks/BeforeSaveJumpToMessage.ts - About 25 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

Function onExternalMessageReceived has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async onExternalMessageReceived(roomReceiveExternalMessageInput: FederationRoomReceiveExternalMessageDto): Promise<void> {
        const { externalRoomId, externalSenderId, rawMessage, externalFormattedText, externalEventId, replyToEventId } =
            roomReceiveExternalMessageInput;
        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByExternalId(externalRoomId);
        if (!federatedRoom) {

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 parseMarkdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async parseMarkdown({ message, config }: { message: IMessage; config: ParserConfig }): Promise<IMessage> {
        if (!this.enabled) {
            return message;
        }

Severity: Minor
Found in apps/meteor/server/services/messages/hooks/BeforeSaveMarkdownParser.ts - About 25 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

Function canAccessRoomLivechat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const canAccessRoomLivechat: RoomAccessValidator = async (room, user, extraData): Promise<boolean> => {
    // If we received a partial room and its type is not `l` or `v`, skip all checks.
    if (room && !['v', 'l'].includes(room.t)) {
        return false;
    }
Severity: Minor
Found in apps/meteor/server/services/authorization/canAccessRoomLivechat.ts - About 25 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

Function initConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async initConnection(commandType: CommandType): Promise<void> {
        // Initialize available connections
        const connection = new AMIConnection();

        const config = commandType === CommandType.AMI ? getManagementServerConfig() : undefined;

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 compareUserPassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function compareUserPassword(user: IUser, pass: IPassword): Promise<boolean> {
    if (!user?.services?.password?.bcrypt?.trim()) {
        return false;
    }

Severity: Minor
Found in apps/meteor/server/lib/compareUserPassword.ts - About 25 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

Function sendDirectMessageToUsers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function sendDirectMessageToUsers(
    fromId = 'rocket.cat',
    toIds: string[],
    messageFn: (user: IUser) => string,
): Promise<string[]> {
Severity: Minor
Found in apps/meteor/server/lib/sendDirectMessageToUsers.ts - About 25 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

Function getMessagesToSendToAdmins has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const getMessagesToSendToAdmins = async (
    alerts: {
        id: string;
        priority: number;
        title: string;
Severity: Minor
Found in apps/meteor/app/version-check/server/functions/checkVersionUpdate.ts - About 25 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

Function constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    constructor() {
        this.ldapjs = ldapjs;

        this.connected = false;
        this._receivedResponse = false;
Severity: Minor
Found in apps/meteor/server/lib/ldap/Connection.ts - About 25 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

Function getTypeForRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async getTypeForRoom(room: RoomRequiredFields, allowRinging: boolean): Promise<AtLeast<VideoConferenceCreateData, 'type'>> {
        for await (const { data, condition } of typeConditions) {
            if (await condition(room, allowRinging)) {
                if (typeof data === 'string') {
                    return {
Severity: Minor
Found in apps/meteor/server/lib/videoConfTypes.ts - About 25 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

Function reportMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const reportMessage = async (messageId: IMessage['_id'], description: string, uid: IUser['_id']) => {
    if (!uid) {
        throw new Error('error-invalid-user');
    }

Severity: Minor
Found in apps/meteor/server/lib/moderation/reportMessage.ts - About 25 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

Severity
Category
Status
Source
Language