RocketChat/Rocket.Chat

View on GitHub

Showing 3,291 of 8,320 total issues

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

    async 'authorization:addPermissionToRole'(permissionId, role) {
        if (AuthorizationUtils.isPermissionRestrictedForRole(permissionId, role)) {
            throw new Meteor.Error('error-action-not-allowed', 'Permission is restricted', {
                method: 'authorization:addPermissionToRole',
                action: 'Adding_permission',
Severity: Minor
Found in apps/meteor/app/authorization/server/methods/addPermissionToRole.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 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 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 mergeWithRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private mergeWithRoom(subscription: ISubscription): SubscriptionWithRoom {
        const options = {
            fields: {
                lm: 1,
                lastMessage: 1,
Severity: Minor
Found in apps/meteor/app/models/client/models/CachedChatSubscription.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 Open has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    callback: async function Open({ params }: SlashCommandCallbackParams<'open'>): Promise<void> {
        const dict: Record<string, RoomType[]> = {
            '#': ['c', 'p'],
            '@': ['d'],
        };
Severity: Minor
Found in apps/meteor/app/slashcommands-open/client/client.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 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 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 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 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 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 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 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 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 reloadPolicy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async function reloadPolicy() {
        types = [];

        if (!settings.get('RetentionPolicy_Enabled')) {
            return cronJobs.remove(pruneCronName);
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 verify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async verify({
        secret,
        token,
        backupTokens,
        userId,
Severity: Minor
Found in apps/meteor/app/2fa/server/lib/totp.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