RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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 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

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

    async sendMessage(message, previewUrls) {
        check(message, Object);

        const uid = Meteor.userId();
        if (!uid) {
Severity: Minor
Found in apps/meteor/app/lib/server/methods/sendMessage.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 updateGlobalSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static updateGlobalSettings(samlConfigs: Record<string, any>): void {
        debug = Boolean(samlConfigs.debug);

        globalSettings.generateUsername = Boolean(samlConfigs.generateUsername);
        globalSettings.nameOverwrite = Boolean(samlConfigs.nameOverwrite);
Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.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 useInviteToken has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const useInviteToken = async (userId: string, token: string) => {
    if (!userId) {
        throw new Meteor.Error('error-invalid-user', 'The user is invalid', {
            method: 'useInviteToken',
            field: 'userId',
Severity: Minor
Found in apps/meteor/app/invites/server/functions/useInviteToken.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 fillTemplateData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static fillTemplateData(template: string, data: Record<string, string>): string {
        let newTemplate = template;

        for (const variable in data) {
            if (variable in data) {
Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.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 unblockUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async unblockUser({ rid, blocked }) {
        check(rid, String);
        check(blocked, String);
        const userId = Meteor.userId();

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

        async (
            params: {
                _id: ISetting['_id'];
                value: ISetting['value'];
            }[] = [],
Severity: Minor
Found in apps/meteor/app/lib/server/methods/saveSettings.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 archiveRoom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async archiveRoom(rid) {
        check(rid, String);

        const userId = Meteor.userId();
        if (!userId) {
Severity: Minor
Found in apps/meteor/app/lib/server/methods/archiveRoom.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 validateStatus has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static validateStatus(doc: Document): {
        success: boolean;
        message: string;
        statusCode: string;
    } {
Severity: Minor
Found in apps/meteor/app/meteor-accounts-saml/server/lib/Utils.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 loadMessageHistory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function loadMessageHistory({
    userId,
    rid,
    end,
    limit = 20,
Severity: Minor
Found in apps/meteor/app/lib/server/functions/loadMessageHistory.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/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 useUserCustomFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const useUserCustomFields = (customFields: CustomField): CustomFieldDisplay[] | undefined => {
    const customFieldsToShowSetting = useSetting('Accounts_CustomFieldsToShowInUserInfo');

    let customFieldsToShowObj: CustomField[] | undefined;
    try {
Severity: Minor
Found in apps/meteor/client/hooks/useUserCustomFields.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/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 parseMessageTextPerUser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export async function parseMessageTextPerUser(
    messageText: string,
    message: Pick<IMessage, 'u' | 'msg' | 't' | 'attachments'>,
    receiver: Pick<IUser, 'language'>,
): Promise<string> {
Severity: Minor
Found in apps/meteor/app/lib/server/functions/notifications/index.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 TooltipProvider has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const TooltipProvider = ({ children }: TooltipProviderProps) => {
    const lastAnchor = useRef<HTMLElement>();
    const hasHover = !useMediaQuery('(hover: none)');

    const [tooltip, setTooltip] = useDebouncedState<ReactNode>(null, 300);
Severity: Minor
Found in apps/meteor/client/providers/TooltipProvider.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 EditStatusModal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const EditStatusModal = ({ onClose, userStatus, userStatusText }: EditStatusModalProps): ReactElement => {
    const allowUserStatusMessageChange = useSetting('Accounts_AllowUserStatusMessageChange');
    const dispatchToastMessage = useToastMessageDispatch();
    const [customStatus, setCustomStatus] = useLocalStorage<string | undefined>('Local_Custom_Status', '');
    const initialStatusText = customStatus || userStatusText;

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

export const useOmnichannelCloseRoute = () => {
    const hideConversationAfterClosing = useUserPreference<boolean>('omnichannelHideConversationAfterClosing') ?? true;
    const router = useRouter();

    const navigateHome = useCallback(() => {
Severity: Minor
Found in apps/meteor/client/hooks/omnichannel/useOmnichannelCloseRoute.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 shouldBypass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const shouldBypass = ({ msg, method, params }: Meteor.IDDPMessage): boolean => {
    if (msg !== 'method') {
        return true;
    }

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

export const useFileUploadDropTarget = (): readonly [
    fileUploadTriggerProps: {
        onDragEnter: (event: React.DragEvent<Element>) => void;
    },
    fileUploadOverlayProps: {
Severity: Minor
Found in apps/meteor/client/views/room/body/hooks/useFileUploadDropTarget.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