RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

export const getAvatarURL = ({ username, roomId, cache }: { username?: string; roomId?: string; cache?: string }): string | undefined => {
    if (username) {
        return getURL(`/avatar/${encodeURIComponent(username)}${cache ? `?etag=${cache}` : ''}`);
    }
    if (roomId) {
Severity: Minor
Found in apps/meteor/app/utils/client/getAvatarURL.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 getDefaultSubscriptionPref has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getDefaultSubscriptionPref = (userPref: AtLeast<IUser, 'settings'>) => {
    const subscription: Partial<ISubscription> = {};

    const { desktopNotifications, pushNotifications, emailNotificationMode, highlights } = userPref.settings?.preferences || {};

Severity: Minor
Found in apps/meteor/app/utils/lib/getDefaultSubscriptionPref.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 parseMentions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    parseMentions(newMessage: IImportMessage): void {
        const mentionsParser = new MentionsParser({
            pattern: () => '[0-9a-zA-Z]+',
            useRealName: () => settings.get<boolean>('UI_Use_Real_Name'),
            me: () => 'me',
Severity: Minor
Found in apps/meteor/app/importer-slack/server/SlackImporter.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 recursiveRemove has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const recursiveRemove = (msg: MessageAttachment, deep = 1) => {
    if (!msg || !isQuoteAttachment(msg)) {
        return;
    }

Severity: Minor
Found in apps/meteor/app/message-pin/server/pinMessage.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 getAvatarURL has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getAvatarURL = ({ username, roomId, cache }: { username?: string; roomId?: string; cache?: string }): string | undefined => {
    if (username) {
        return getURL(`/avatar/${encodeURIComponent(username)}${cache ? `?etag=${cache}` : ''}`);
    }
    if (roomId) {
Severity: Minor
Found in apps/meteor/app/utils/server/getAvatarURL.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 processThreads has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function processThreads(message: IMessage, room: IRoom) {
    if (!message.tmid) {
        return message;
    }

Severity: Minor
Found in apps/meteor/app/threads/server/hooks/aftersavemessage.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 unfollowMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async unfollowMessage({ mid }) {
        check(mid, String);

        const uid = Meteor.userId();
        if (!uid) {
Severity: Minor
Found in apps/meteor/app/threads/server/methods/unfollowMessage.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 toNextMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        toNextMessage: async () => {
            if (!this.composer || !this.currentEditing) {
                return;
            }

Severity: Minor
Found in apps/meteor/app/ui/client/lib/ChatMessages.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 getMoreNext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async getMoreNext(rid: IRoom['_id'], atBottomRef: MutableRefObject<boolean>) {
        const room = this.getRoom(rid);
        if (Tracker.nonreactive(() => room.hasMoreNext.get()) !== true) {
            return;
        }
Severity: Minor
Found in apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.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 getVirtualRecordById has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private getVirtualRecordById(id: string): IImportRecord | undefined {
        for (const store of [this._userRecords, this._channelRecords, this._messageRecords]) {
            for (const record of store) {
                if (record._id === id) {
                    return record;
Severity: Minor
Found in apps/meteor/app/importer/server/classes/VirtualDataConverter.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 followMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async followMessage({ mid }) {
        check(mid, String);

        const uid = Meteor.userId();
        if (!uid) {
Severity: Minor
Found in apps/meteor/app/threads/server/methods/followMessage.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 convertUnicode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    (entire, _m1, m2, m3) => {
        const mappedUnicode = emojione.mapUnicodeToShort();

        if (typeof m3 === 'undefined' || m3 === '' || !(emojione.unescapeHTML(m3) in emojione.asciiList)) {
            // if the ascii doesnt exist just return the entire match
Severity: Minor
Found in apps/meteor/app/emoji-emojione/lib/getEmojiConfig.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 findImportedRoomName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async findImportedRoomName(importId: string): Promise<string | undefined> {
        if (this._roomNameCache.has(importId)) {
            return this._roomNameCache.get(importId) as string;
        }

Severity: Minor
Found in apps/meteor/app/importer/server/classes/ImportDataConverter.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 getNotificationConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private getNotificationConfig({
        rid,
        uid: userId,
        mid: messageId,
        roomName,
Severity: Minor
Found in apps/meteor/app/push-notifications/server/lib/PushNotification.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 sendNotificationGateway has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private async sendNotificationGateway(
        app: IAppsTokens,
        notification: PendingPushNotification,
        countApn: string[],
        countGcm: string[],
Severity: Minor
Found in apps/meteor/app/push/server/push.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 replace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    replace: (
        str: string,
        data: { name?: string; email?: string; password?: string; reason?: string; user?: string; room?: string; unsubscribe?: string },
    ) => {
        if (!str) {
Severity: Minor
Found in apps/meteor/app/utils/server/placeholders.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 job has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function job(): Promise<void> {
    const now = new Date();
    const filesOnly = settings.get<boolean>('RetentionPolicy_FilesOnly');
    const excludePinned = settings.get<boolean>('RetentionPolicy_DoNotPrunePinned');
    const ignoreDiscussion = settings.get<boolean>('RetentionPolicy_DoNotPruneDiscussion');
Severity: Minor
Found in apps/meteor/app/retention-policy/server/cronPruneMessages.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 getSettingDefaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getSettingDefaults = (
    setting: Partial<ISetting> & Pick<ISetting, '_id' | 'value' | 'type'>,
    blockedSettings: Set<string> = new Set(),
    hiddenSettings: Set<string> = new Set(),
    wizardRequiredSettings: Set<string> = new Set(),
Severity: Minor
Found in apps/meteor/app/settings/server/functions/getSettingDefaults.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 saveRegistrationDataBase has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function saveRegistrationDataBase({
    workspaceId,
    client_name,
    client_id,
    client_secret,
Severity: Minor
Found in apps/meteor/app/cloud/server/functions/saveRegistrationData.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 getLanguage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    getLanguage(rid: IRoom['_id']): string {
        let subscription: ISubscription | undefined;
        if (rid) {
            subscription = this.findSubscriptionByRid(rid);
        }
Severity: Minor
Found in apps/meteor/app/autotranslate/client/lib/autotranslate.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