RocketChat/Rocket.Chat

View on GitHub

Showing 3,291 of 8,320 total issues

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

function notifyNewMessageAudio(rid?: string): void {
    // This logic is duplicated in /client/startup/unread.coffee.
    const hasFocus = document.hasFocus();
    const messageIsInOpenedRoom = RoomManager.opened === rid;
    const muteFocusedConversations = getUserPreference(Meteor.userId(), 'muteFocusedConversations');
Severity: Minor
Found in apps/meteor/client/startup/notifications/konchatNotifications.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 play has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    play(autoPlay = true, muteAudio = false): void {
        if (this.renderingMediaElement && this.mediaStream) {
            this.renderingMediaElement.autoplay = autoPlay;
            this.renderingMediaElement.srcObject = this.mediaStream;
            if (autoPlay) {
Severity: Minor
Found in apps/meteor/client/lib/voip/RemoteStream.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 SystemMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const SystemMessage = ({ message, showUserAvatar, ...props }: SystemMessageProps): ReactElement => {
    const t = useTranslation();
    const formatTime = useFormatTime();
    const formatDateAndTime = useFormatDateAndTime();
    const { triggerProps, openUserCard } = useUserCard();
Severity: Minor
Found in apps/meteor/client/components/message/variants/SystemMessage.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 MessageToolbar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const MessageToolbar = ({
    message,
    messageContext,
    room,
    subscription,
Severity: Minor
Found in apps/meteor/client/components/message/toolbar/MessageToolbar.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 AttachmentImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const AttachmentImage: FC<AttachmentImageProps> = ({ id, previewUrl, dataSrc, loadImage = true, setLoadImage, src, ...size }) => {
    const limits = useAttachmentDimensions();

    const [error, setError] = useState(false);

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

    private onDirectCallAccepted(params: DirectCallParams, skipConfirmation = false): void {
        if (!params.callId || params.callId !== this.currentCallData?.callId) {
            debug && console.log(`[VideoConf] User ${params.uid} has accepted a call ${params.callId} from us, but we're not calling.`);
            return;
        }
Severity: Minor
Found in apps/meteor/client/lib/VideoConfManager.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 useOutsideClick has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const useOutsideClick = (
    ref: RefObject<HTMLElement>,
    onDismiss: (() => void) | undefined,
): {
    onMouseDown: (e: MouseEvent) => void;
Severity: Minor
Found in apps/meteor/client/components/ModalBackdrop.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 onDirectCallEnded has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private onDirectCallEnded(params: DirectCallParams): void {
        if (!params.callId) {
            debug && console.log(`[VideoConf] Invalid 'video-conference.end' event received: ${params.callId}, ${params.uid}.`);
            return;
        }
Severity: Minor
Found in apps/meteor/client/lib/VideoConfManager.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 StatusIndicators has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const StatusIndicators = ({ message }: StatusIndicatorsProps): ReactElement => {
    const t = useTranslation();
    const translated = useShowTranslated(message);
    const starred = useShowStarred({ message });
    const following = useShowFollowing({ message });
Severity: Minor
Found in apps/meteor/client/components/message/StatusIndicators.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 parseMessageTextToAstMarkdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const parseMessageTextToAstMarkdown = <
    TMessage extends IMessage & Partial<ITranslatedMessage> = IMessage & Partial<ITranslatedMessage>,
>(
    message: TMessage,
    parseOptions: Options,
Severity: Minor
Found in apps/meteor/client/lib/parseMessageTextToAstMarkdown.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 joinCall has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public async joinCall(callId: string): Promise<void> {
        debug && console.log(`[VideoConf] Joining call ${callId}.`);

        if (this.incomingDirectCalls.has(callId)) {
            const data = this.incomingDirectCalls.get(callId);
Severity: Minor
Found in apps/meteor/client/lib/VideoConfManager.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 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;
Severity: Minor
Found in apps/meteor/client/sidebar/header/EditStatusModal.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 checkPlaceholdersFormat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const checkPlaceholdersFormat = async ({ json, path, fix = false }: { json: Record<string, string>; path: PathLike; fix?: boolean }) => {
    const outdatedKeys = Object.entries(json)
        .map(([key, value]) => ({
            key,
            value,
Severity: Minor
Found in apps/meteor/.scripts/translation-check.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 delegate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const delegate = ({
    parent = document,
    eventName,
    elementSelector,
    listener,
Severity: Minor
Found in apps/meteor/client/lib/utils/domEvents.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 validateRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private validateRoute<TRouteName extends RouteName>(route: IRoomTypeRouteConfig<TRouteName>): void {
        const { name, path, link } = route;

        if (typeof name !== 'string' || name.length === 0) {
            throw new Error('The route name must be a string.');
Severity: Minor
Found in apps/meteor/client/lib/rooms/roomCoordinator.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 appEnableCheck has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const appEnableCheck = async ({
    baseUrl,
    headers,
    appId,
    version,
Severity: Minor
Found in apps/meteor/ee/server/apps/marketplace/appEnableCheck.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 updateSubscription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public updateSubscription(subscription?: ISubscription) {
        if (!subscription) {
            return;
        }

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

const checkExceedingKeys = async ({
    json,
    path,
    lng,
    sourceJson,
Severity: Minor
Found in apps/meteor/.scripts/translation-check.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 extractSingularKeys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const extractSingularKeys = (json: Record<string, string>, lng: string) => {
    if (!i18next.isInitialized) {
        i18next.init({ initImmediate: false });
    }

Severity: Minor
Found in apps/meteor/.scripts/translation-check.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 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

Severity
Category
Status
Source
Language