RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

    private handleConnectionResponse(error: any, response?: any): void {
        if (!this._receivedResponse) {
            this._receivedResponse = true;
            this._connectionCallback(error, response);
            return;
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 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 saveRoomReadOnly has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function saveRoomReadOnly(
    rid: string,
    readOnly: boolean,
    user: Required<Pick<IUser, '_id' | 'username' | 'name'>>,
    sendMessage = true,
Severity: Minor
Found in apps/meteor/app/channel-settings/server/functions/saveRoomReadOnly.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 searchMembersOfGroupFilter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async searchMembersOfGroupFilter(): Promise<string[]> {
        if (!this.options.groupFilterEnabled) {
            return [];
        }

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

    private static getLdapUserUniqueID(ldapUser: ILDAPEntry): ILDAPUniqueIdentifierField | undefined {
        let uniqueIdentifierField: string | string[] | undefined = settings.get<string>('LDAP_Unique_Identifier_Field');

        if (uniqueIdentifierField) {
            uniqueIdentifierField = uniqueIdentifierField.replace(/\s/g, '').split(',');
Severity: Minor
Found in apps/meteor/server/lib/ldap/Manager.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

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

export async function getUsersInRolePaginated(
    roleId: IRole['_id'],
    scope: string | undefined,
    options?: any | undefined,
): Promise<FindPaginated<FindCursor<IUser>>> {
Severity: Minor
Found in apps/meteor/app/authorization/server/functions/getUsersInRole.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 findAuthenticatedUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static async findAuthenticatedUser(ldap: LDAPConnection, username: string): Promise<ILDAPEntry | undefined> {
        const escapedUsername = ldapEscape.filter`${username}`;

        try {
            const users = await ldap.searchByUsername(escapedUsername);
Severity: Minor
Found in apps/meteor/server/lib/ldap/Manager.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 hideUserName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const hideUserName = (
    username: string,
    userData: Pick<IUser, 'username'> | undefined,
    usersMap: { userNameTable: Record<string, string> },
) => {
Severity: Minor
Found in apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.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 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 processString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const processString = (string: string, date: Date): string => {
    try {
        const obj = EJSON.parse(string);
        if (!obj || typeof obj !== 'object') {
            throw new TypeError('Invalid JSON');
Severity: Minor
Found in apps/meteor/server/stream/stdout.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 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 sendNoWrap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const sendNoWrap = async ({
    to,
    from,
    replyTo,
    subject,
Severity: Minor
Found in apps/meteor/app/mailer/server/api.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