RocketChat/Rocket.Chat

View on GitHub

Showing 3,299 of 8,337 total issues

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

export const reducePlainTexts = (
  values: Paragraph['value']
): Paragraph['value'] =>
  values
    .flatMap((item) => item)
Severity: Minor
Found in packages/message-parser/src/utils.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 runFederation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function runFederation(): Promise<void> {
    // Get the settings
    const siteUrl = settings.get('Site_Url') as string;
    const { protocol } = new URL(siteUrl);
    const rocketChatProtocol = protocol.slice(0, -1);
Severity: Minor
Found in apps/meteor/server/cron/federation.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 findAllNumberOfAbandonedRooms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async findAllNumberOfAbandonedRooms({
        start,
        end,
        departmentId,
        onlyCount = false,
Severity: Minor
Found in apps/meteor/server/models/raw/LivechatRooms.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 findAllServiceTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    findAllServiceTime({
        start,
        end,
        departmentId,
        onlyCount = false,
Severity: Minor
Found in apps/meteor/server/models/raw/LivechatRooms.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 saveAnalyticsDataByRoomId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    saveAnalyticsDataByRoomId(room: IOmnichannelRoom, message: IMessage, analyticsData: Record<string, string | number | Date>) {
        const update: DeepWritable<UpdateFilter<IOmnichannelRoom>> = {
            $set: {
                ...(analyticsData && {
                    'metrics.response.avg': analyticsData.avgResponseTime,
Severity: Minor
Found in apps/meteor/server/models/raw/LivechatRooms.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 utf8Encode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function utf8Encode(input: string) {
    // METEOR change:
    // The webtoolkit.info version of this code added this
    // Utf8Encode function (which does seem necessary for dealing
    // with arbitrary Unicode), but the following line seems
Severity: Minor
Found in packages/sha256/src/utf8Encode.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 MessageSeparator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const MessageSeparator = ({ date, unread, use: Element = 'div', className, style = {}, t }: MessageSeparatorProps) => (
    <Element
        className={createClassName(
            styles,
            'separator',
Severity: Minor
Found in packages/livechat/src/components/Messages/MessageSeparator/index.tsx - 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 updateEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async updateEvent(
        eventId: ICalendarEvent['_id'],
        { subject, description, startTime, meetingUrl, reminderMinutesBeforeStart, reminderTime }: Partial<ICalendarEvent>,
    ): Promise<UpdateResult> {
        return this.updateOne(
Severity: Minor
Found in apps/meteor/server/models/raw/CalendarEvent.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 loadSurroundingMessages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async loadSurroundingMessages(message, limit = 50) {
        check(message, Object);
        check(limit, Number);

        if (!Meteor.userId()) {
Severity: Minor
Found in apps/meteor/server/methods/loadSurroundingMessages.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 deleteUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async deleteUser(userId, confirmRelinquish = false) {
        check(userId, String);
        const uid = Meteor.userId();
        if (!uid || (await hasPermissionAsync(uid, 'delete-user')) !== true) {
            throw new Meteor.Error('error-not-allowed', 'Not allowed', {
Severity: Minor
Found in apps/meteor/server/methods/deleteUser.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 sendForgotPasswordEmail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async sendForgotPasswordEmail(to) {
        check(to, String);

        const email = to.trim().toLowerCase();

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

    async loadNextMessages(rid, end, limit = 20) {
        check(rid, String);
        check(limit, Number);

        if (!Meteor.userId()) {
Severity: Minor
Found in apps/meteor/server/methods/loadNextMessages.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 onRoomOwnerRemoved has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async onRoomOwnerRemoved(internalUserId: string, internalTargetUserId: string, internalRoomId: string): Promise<void> {
        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByInternalId(internalRoomId);
        if (!federatedRoom) {
            return;
        }

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

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

    public async onRoomModeratorRemoved(internalUserId: string, internalTargetUserId: string, internalRoomId: string): Promise<void> {
        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByInternalId(internalRoomId);
        if (!federatedRoom) {
            return;
        }

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

export async function configureEmailInboxes(): Promise<void> {
    const emailInboxesCursor = EmailInbox.find({
        active: true,
    });

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

    public async onRoomModeratorAdded(internalUserId: string, internalTargetUserId: string, internalRoomId: string): Promise<void> {
        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByInternalId(internalRoomId);
        if (!federatedRoom) {
            return;
        }

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

async function uploadAttachment(attachmentParam: Attachment, rid: string, visitorToken: string): Promise<Partial<FileAttachment>> {
    const details = {
        name: attachmentParam.filename,
        size: attachmentParam.size,
        type: attachmentParam.contentType,
Severity: Minor
Found in apps/meteor/server/features/EmailInbox/EmailInbox_Incoming.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 afterRoomTopicChanged has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async afterRoomTopicChanged(internalRoomId: string, internalRoomTopic: string): Promise<void> {
        const federatedRoom = await this.internalRoomAdapter.getFederatedRoomByInternalId(internalRoomId);
        if (!federatedRoom) {
            return;
        }

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

    public async sendMessageFileToThread(
        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

Severity
Category
Status
Source
Language