RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

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

export const templateVarHandler = function (variable: string, object: Record<string, any>): string | undefined {
    const templateRegex = /#{([\w\-]+)}/gi;
    let match = templateRegex.exec(variable);
    let tmpVariable = variable;

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

export const deleteIncomingIntegration = async (integrationId: string, userId: string): Promise<void> => {
    let integration;

    if (userId && (await hasPermissionAsync(userId, 'manage-incoming-integrations'))) {
        integration = Integrations.findOneById(integrationId);

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

export async function startRegisterWorkspace(resend = false) {
    const { workspaceRegistered } = await retrieveRegistrationStatus();
    if (workspaceRegistered || process.env.TEST_MODE) {
        await syncWorkspace();

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

    updateOne(query: any, update: any, options?: any): void {
        const existent = this.findOne(query);

        const data = { ...existent, ...query, ...update, ...update.$set };

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

export async function getWorkspaceAccessToken(forceNew = false, scope = '', save = true, throwOnError = false): Promise<string> {
    const { workspaceRegistered } = await retrieveRegistrationStatus();

    if (!workspaceRegistered) {
        return '';
Severity: Minor
Found in apps/meteor/app/cloud/server/functions/getWorkspaceAccessToken.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 addOutgoingIntegration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const addOutgoingIntegration = async (userId: string, integration: INewOutgoingIntegration): Promise<IOutgoingIntegration> => {
    check(
        integration,
        Match.ObjectIncluding({
            type: 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 createChannelValidator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function createChannelValidator(params: {
    user: { value: string };
    name?: { key: string; value?: string };
    members?: { key: string; value?: string[] };
    customFields?: { key: string; value?: string };
Severity: Minor
Found in apps/meteor/app/api/server/v1/channels.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async post() {
            check(
                this.bodyParams,
                Match.ObjectIncluding({
                    msgId: String,
Severity: Minor
Found in apps/meteor/app/api/server/v1/chat.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            check(
                this.queryParams,
                Match.ObjectIncluding({
                    websocketUrl: Match.Maybe(String),
Severity: Minor
Found in apps/meteor/app/api/server/v1/voip/server-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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            const { rid } = this.queryParams;
            const { query, fields, sort } = await this.parseJsonQuery();
            const { updatedSince } = this.queryParams;
            let updatedSinceDate;
Severity: Minor
Found in apps/meteor/app/api/server/v1/chat.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async post() {
            const { roomId, title, allowRinging: requestRinging } = this.bodyParams;
            const { userId } = this;
            if (!userId || !(await canAccessRoomIdAsync(roomId, userId))) {
                return API.v1.failure('invalid-params');
Severity: Minor
Found in apps/meteor/app/api/server/v1/videoConference.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            const { query } = await this.parseJsonQuery();
            if (!query || Object.keys(query).length === 0) {
                return API.v1.failure('Invalid query');
            }
Severity: Minor
Found in apps/meteor/app/api/server/v1/channels.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            const query = this.queryParams;
            const user = await getLoggedInUser(this.request);

            if (typeof query.command !== 'string') {
Severity: Minor
Found in apps/meteor/app/api/server/v1/commands.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 findUsers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function findUsers({
    role,
    text,
    onlyAvailable = false,
    excludeId,
Severity: Minor
Found in apps/meteor/app/livechat/server/api/lib/users.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 livechat:returnAsInquiry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async 'livechat:returnAsInquiry'(rid, departmentId) {
        const uid = Meteor.userId();
        if (!uid || !(await hasPermissionAsync(uid, 'view-l-room'))) {
            throw new Meteor.Error('error-not-allowed', 'Not allowed', {
                method: 'livechat:returnAsInquiry',
Severity: Minor
Found in apps/meteor/app/livechat/server/methods/returnAsInquiry.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            const { offset } = await getPaginationItems(this.queryParams);
            const { token } = this.queryParams;
            const { rid } = this.urlParams;

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

        async get() {
            const room = await findRoomByIdOrName({ params: this.queryParams });
            const { fields } = await this.parseJsonQuery();

            if (!room || !(await canAccessRoomAsync(room, { _id: this.userId }))) {
Severity: Minor
Found in apps/meteor/app/api/server/v1/rooms.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            if (settings.get('API_Enable_Direct_Message_History_EndPoint') !== true) {
                throw new Meteor.Error('error-endpoint-disabled', 'This endpoint is disabled', {
                    route: '/api/v1/im.messages.others',
                });
Severity: Minor
Found in apps/meteor/app/api/server/v1/im.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