RocketChat/Rocket.Chat

View on GitHub

Showing 8,229 of 8,229 total issues

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

export const validateMessage = async (message: any, room: any, user: any) => {
    check(
        message,
        objectMaybeIncluding({
            _id: String,
Severity: Minor
Found in apps/meteor/app/lib/server/functions/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 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 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 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: FC = ({ children }) => {
    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 useComposerBoxPopupQueries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const useComposerBoxPopupQueries = <T extends { _id: string; sort?: number }>(filter: unknown, popup?: ComposerPopupOption<T>) => {
    const [counter, setCounter] = useState(0);

    useEffect(() => {
        setCounter(0);

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

const AppsProvider: FC = ({ children }) => {
    const isAdminUser = usePermission('manage-apps');

    const queryClient = useQueryClient();

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

export const useImagesList = (
    options: ChannelsImagesProps,
): {
    filesList: ImagesList;
    initialItemCount: number;
Severity: Minor
Found in apps/meteor/client/views/room/ImageGallery/hooks/useImagesList.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 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 PlanCardTrial has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const PlanCardTrial = ({ licenseInformation }: PlanCardProps): ReactElement => {
    const { t } = useTranslation();

    const planName = useLicenseName();
    const isSalesAssisted = licenseInformation.grantedBy?.method !== 'self-service' || true;

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

export const useMessageComposerMergedRefs = <T>(...refs: Ref<T>[]): RefCallback<T> => {
    return useCallback((refValue: T) => {
        refs.filter(Boolean).forEach((ref) => {
            if (isRefCallback<T>(ref)) {
                ref(refValue);

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

export const useArchiveRoom = (room: Pick<IRoom, RoomAdminFieldsType>) => {
    const t = useTranslation();
    const dispatchToastMessage = useToastMessageDispatch();
    const archiveAction = useEndpoint('POST', '/v1/rooms.changeArchivationState');

Severity: Minor
Found in apps/meteor/client/views/hooks/roomActions/useArchiveRoom.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

Severity
Category
Status
Source
Language