RocketChat/Rocket.Chat

View on GitHub

Showing 8,229 of 8,229 total issues

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

    async 'livechat:resumeOnHold'(roomId, options = { clientAction: false }) {
        methodDeprecationLogger.warn(
            'Method "livechat:resumeOnHold" is deprecated and will be removed in next major version. Please use "livechat/room.resumeOnHold" API instead.',
        );

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

export async function setSLAToInquiry({ userId, roomId, sla }: { userId: string; roomId: string; sla?: string }): Promise<void> {
    const inquiry = await LivechatInquiry.findOneByRoomId(roomId, { projection: { status: 1 } });
    if (!inquiry || inquiry.status !== 'queued') {
        throw new Error('error-invalid-inquiry');
    }
Severity: Minor
Found in apps/meteor/ee/app/livechat-enterprise/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 auditGetMessages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async auditGetMessages({ rid, startDate, endDate, users: usernames, msg, type, visitor, agent }) {
        check(startDate, Date);
        check(endDate, Date);

        const user = await Meteor.userAsync();
Severity: Minor
Found in apps/meteor/ee/server/lib/audit/methods.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 syncUserTeams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static async syncUserTeams(ldap: LDAPConnection, user: IUser, dn: string, isNewRecord: boolean): Promise<void> {
        if (!user.username) {
            return;
        }

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

const handleAfterTakeInquiryCallback = async (inquiry: any = {}): Promise<any> => {
    const { rid } = inquiry;
    if (!rid?.trim()) {
        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 getLdapTeamsByUsername has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static async getLdapTeamsByUsername(ldap: LDAPConnection, username: string, dn: string): Promise<Array<string>> {
        const baseDN = (settings.get<string>('LDAP_Teams_BaseDN') ?? '').trim() || ldap.options.baseDN;
        const query = settings.get<string>('LDAP_Query_To_Get_User_Teams');
        if (!query) {
            return [];
Severity: Minor
Found in apps/meteor/ee/server/lib/ldap/Manager.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 handleAfterSaveMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const handleAfterSaveMessage = async (message: IMessage, room: IRoom | undefined): Promise<IMessage> => {
    if (!room || !isOmnichannelRoom(room)) {
        return message;
    }

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

    private async removeBHFromPreviouslyConnectedDepartmentAgentsIfRequired(departmentIds: string[]): Promise<void> {
        // we need to do 2 things here.
        // 1st is to check if any of the departments are associated with any BH. If they are, then we need to remove
        // that BH from all agents of that department.
        // 2nd is to check if any of the departments are not associated with BH, meaning default BH
Severity: Minor
Found in apps/meteor/ee/app/livechat-enterprise/server/business-hour/Custom.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 changeSettingValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function changeSettingValue(record: ISetting): SettingValue {
    if (!record.enterprise) {
        return record.value;
    }

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

export function useLongPress(
    onLongPress: () => void,
    options?: Partial<UseLongPressResult> & {
        threshold?: number;
    },
Severity: Minor
Found in apps/meteor/ee/client/voip/modal/DialPad/hooks/useLongPress.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 mapRolesFromSSO has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    static async mapRolesFromSSO(identity: Record<string, any>, roleClaimName: string): Promise<string[]> {
        if (!identity || !roleClaimName || !identity[roleClaimName] || !Array.isArray(identity[roleClaimName])) {
            return [];
        }

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

export async function updatePriority(
    _id: string,
    data: Pick<ILivechatPriority, 'name'> & { reset?: boolean },
): Promise<ILivechatPriority | null> {
    if (data.name) {
Severity: Minor
Found in apps/meteor/ee/app/livechat-enterprise/server/api/lib/priorities.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 getLivechatQueueInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getLivechatQueueInfo = async (room?: IOmnichannelRoom) => {
    if (!room) {
        return null;
    }

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

export const useDialPad = ({ initialValue, initialErrorMessage }: DialPadProps): DialPadStateHandlers => {
    const t = useTranslation();
    const outboundClient = useOutboundDialer();
    const { closeDialModal } = useDialModal();

Severity: Minor
Found in apps/meteor/ee/client/voip/modal/DialPad/hooks/useDialPad.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 CreateCannedResponseModal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CreateCannedResponseModal = ({
    cannedResponseData,
    onClose,
    reloadCannedList,
}: {

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

    subscribe(name: string, ...params: any[]) {
        const id = this.ddp.subscribe(name, params);

        // eslint-disable-next-line @typescript-eslint/no-this-alias
        const self = this;
Severity: Minor
Found in ee/packages/ddp-client/src/ClientStream.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async call(client: Client, packet: IPacket): Promise<void> {
        // if client is not connected we don't need to do anything
        if (client.ws.readyState !== WebSocket.OPEN) {
            return;
        }
Severity: Minor
Found in ee/apps/ddp-streamer/src/Server.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 MessagesPerChannelSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const MessagesPerChannelSection = (): ReactElement => {
    const [period, periodSelectorProps] = usePeriodSelectorState('last 7 days', 'last 30 days', 'last 90 days');

    const t = useTranslation();

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

export const PrioritiesSelect = ({ value = '', label, options, onChange }: PrioritiesSelectProps) => {
    const t = useTranslation();
    const hasLicense = useHasLicenseModule('livechat-enterprise');
    const [sorting] = useState<Record<string, LivechatPriorityWeight>>({});

Severity: Minor
Found in apps/meteor/ee/client/omnichannel/additionalForms/PrioritiesSelect.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 replaceModules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function replaceModules(this: LicenseManager, newModules: LicenseModule[]): boolean {
    let anyChange = false;
    for (const moduleName of newModules) {
        if (this.modules.has(moduleName)) {
            continue;
Severity: Minor
Found in ee/packages/license/src/modules.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