RocketChat/Rocket.Chat

View on GitHub

Showing 3,291 of 8,320 total issues

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 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 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() {
            // eslint-disable-next-line @typescript-eslint/naming-convention
            const { prid, pmid, reply, t_name, users, encrypted, topic } = this.bodyParams;
            if (!prid) {
                return API.v1.failure('Body parameter "prid" is required.');
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 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 takeInquiry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async takeInquiry(inquiry, agent, options = { clientAction: false }) {
        check(
            agent,
            Match.ObjectIncluding({
                agentId: String,
Severity: Minor
Found in apps/meteor/app/livechat/server/lib/RoutingManager.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 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() {
            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

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

    async 'e2e.updateGroupKey'(rid, uid, key) {
        const userId = Meteor.userId();
        if (!userId) {
            throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'e2e.acceptSuggestedGroupKey' });
        }
Severity: Minor
Found in apps/meteor/app/e2e/server/methods/updateGroupKey.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 { query } = URL.parse(req.url || '', true);
    const forceDownload = typeof query.download !== 'undefined';

    const fileUrl = await this.store.getRedirectURL(file, forceDownload);
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 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 { query } = URL.parse(req.url || '', true);
    const forceDownload = typeof query.download !== 'undefined';

    const fileUrl = await this.store.getRedirectURL(file, forceDownload);
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 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

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

    async avatarsOnValidate(this: Store, file: IUpload) {
        if (settings.get('Accounts_AvatarResize') !== true) {
            return;
        }

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

    public async validate(xmlString: string, callback: ILogoutRequestValidateCallback): Promise<void> {
        SAMLUtils.log(`LogoutRequest: ${xmlString}`);

        const doc = new xmldom.DOMParser().parseFromString(xmlString, 'text/xml');
        if (!doc) {
Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/parsers/LogoutRequest.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        async get() {
            check(this.urlParams, {
                type: String,
            });
            const { offset, count } = await getPaginationItems(this.queryParams);
Severity: Minor
Found in apps/meteor/app/livechat/imports/server/rest/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