RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

        async post() {
            if (('roomId' in this.bodyParams && !this.bodyParams.roomId) || ('roomName' in this.bodyParams && !this.bodyParams.roomName)) {
                return API.v1.failure('The parameter "roomId" or "roomName" is required');
            }

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

    async 'livechat:getNextAgent'({ token, department }) {
        methodDeprecationLogger.method('livechat:getNextAgent', '7.0.0');
        check(token, String);

        const extraQuery = await callbacks.run('livechat.applyRoomRestrictions', {});
Severity: Minor
Found in apps/meteor/app/livechat/server/methods/getNextAgent.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 = 'roomId' in this.bodyParams ? this.bodyParams.roomId : '';
            const roomName = 'roomName' in this.bodyParams ? this.bodyParams.roomName : '';
            const idOrName = roomId || roomName;

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

const applyDepartmentRestrictions = async (
    userId: IUser['_id'],
    filterDepartment?: string,
): Promise<{ $in: string[] } | { $exists: false } | string> => {
    const allowedDepartments = await agentDepartments(userId);
Severity: Minor
Found in apps/meteor/app/livechat/server/api/lib/inquiries.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, {
                _id: Match.Maybe(String),
                active: Boolean,
                name: String,
Severity: Minor
Found in apps/meteor/app/api/server/v1/email-inbox.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 { deviceCode } = this.queryParams;
            check(this.queryParams, {
                deviceCode: String,
            });
Severity: Minor
Found in apps/meteor/app/api/server/v1/cloud.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 findDirectMessageRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const findDirectMessageRoom = async (
    keys: findDirectMessageRoomProps,
    uid: string,
): Promise<{ room: IRoom; subscription: ISubscription | null }> => {
    if (!('roomId' in keys) && !('username' in keys)) {
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

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

    async getSample(roomIds: string[], limit = 3): Promise<string[]> {
        if (limit === 0) {
            return [];
        }

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

    private _verifyCommand(command: ISlashCommand): void {
        if (typeof command !== 'object') {
            throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
        }

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

    protected async createDiscussion(
        room: IRoom,
        parentMessage: IMessage | undefined = undefined,
        reply: string | undefined = '',
        members: Array<string> = [],
Severity: Minor
Found in apps/meteor/app/apps/server/bridges/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 logFailedLoginAttempts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const logFailedLoginAttempts = (login: ILoginAttempt): void => {
    if (!settings.get('Login_Logs_Enabled')) {
        return;
    }

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

    update(sound: ICustomSound) {
        const audio = document.querySelector<HTMLAudioElement>(`#${getCustomSoundId(sound._id)}`);
        if (audio) {
            const list = this.list.get();
            if (!sound.src) {
Severity: Minor
Found in apps/meteor/app/custom-sounds/client/lib/CustomSounds.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

const get: FileUploadClass['get'] = async function (this: FileUploadClass, file, req, res) {
    const forcedDownload = forceDownload(req);

    const fileUrl = await this.store.getRedirectURL(file, forcedDownload);
    if (!fileUrl || !file.store) {
Severity: Minor
Found in apps/meteor/app/file-upload/server/config/GoogleStorage.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

const get: FileUploadClass['get'] = async function (this: FileUploadClass, file, req, res) {
    const forcedDownload = forceDownload(req);

    const fileUrl = await this.store.getRedirectURL(file, forcedDownload);
    if (!fileUrl || !file.store) {
Severity: Minor
Found in apps/meteor/app/file-upload/server/config/AmazonS3.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 validateSignatureChildren has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private validateSignatureChildren(xml: string, cert: string, parent: XmlParent): boolean {
        const xpathSigQuery = ".//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']";
        const signatures = xmlCrypto.xpath(parent, xpathSigQuery) as Array<Element>;
        let signature = null;

Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/parsers/Response.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