RocketChat/Rocket.Chat

View on GitHub

Showing 3,291 of 8,320 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 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

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

        async post() {
            // New change made by pull request #5152
            if (typeof this.bodyParams.joinDefaultChannels === 'undefined') {
                this.bodyParams.joinDefaultChannels = true;
            }
Severity: Minor
Found in apps/meteor/app/api/server/v1/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 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 { 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 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 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 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            const { token } = this.urlParams;
            const room = await findOpenRoom(token);
            if (room) {
                return API.v1.success();
Severity: Minor
Found in apps/meteor/app/livechat/server/api/v1/agent.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 getAgentFromExternalQueue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private async getAgentFromExternalQueue(department?: string, ignoreAgentId?: string): Promise<SelectedAgent | null | undefined> {
        try {
            const request = await fetch(`${settings.get('Livechat_External_Queue_URL')}`, {
                headers: {
                    'User-Agent': 'RocketChat Server',
Severity: Minor
Found in apps/meteor/app/livechat/server/lib/routing/External.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 oAuthServicesEnabled = await LoginServiceConfigurationModel.find({}, { projection: { secret: 0 } }).toArray();

            return API.v1.success({
                services: oAuthServicesEnabled.map((service) => {
Severity: Minor
Found in apps/meteor/app/api/server/v1/settings.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/groups.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, {
                email: Match.Maybe(String),
                phone: Match.Maybe(String),
                custom: Match.Maybe(String),
Severity: Minor
Found in apps/meteor/app/livechat/server/api/v1/contact.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

Severity
Category
Status
Source
Language