RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

Router.prototype.path = function (pathDef, fields, queryParams) {
    if (this._routesMap[pathDef]) {
        pathDef = this._routesMap[pathDef].path;
    }

Severity: Minor
Found in apps/meteor/packages/flow-router/server/router.js - 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 storeReadReceipts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async storeReadReceipts(messages, roomId, userId, extraData = {}) {
        if (settings.get('Message_Read_Receipt_Store_Users')) {
            const ts = new Date();
            const receipts = messages.map((message) => ({
                _id: Random.id(),
Severity: Minor
Found in apps/meteor/ee/server/lib/message-read-receipt/ReadReceipt.js - 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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(config: AgendaConfig = {}) {
        super();

        this._name = config.name;
        this._processEvery = humanInterval(config.processEvery) || defaultInterval;
Severity: Minor
Found in packages/agenda/src/Agenda.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 loadPostcssConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const loadPostcssConfig = async () => {
    if (loaded) {
        return;
    }

Severity: Minor
Found in apps/meteor/packages/rocketchat-postcss/build.js - 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 MockedServerContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const MockedServerContext = ({
    handleRequest,
    handleMethod,
    children,

Severity: Minor
Found in packages/mock-providers/src/MockedServerContext.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 withPermission has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    withPermission(permission: string): this {
        const innerFn = this.authorization.queryPermission;

        const outerFn = (
            innerPermission: string | ObjectId,
Severity: Minor
Found in packages/mock-providers/src/MockedAppRootBuilder.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 _lockOnTheFly has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private async _lockOnTheFly(): Promise<void> {
        // Already running this? Return
        if (this._isLockingOnTheFly) {
            debug('lockOnTheFly() already running, returning');
            return;
Severity: Minor
Found in packages/agenda/src/Agenda.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 PlainSpan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const PlainSpan = ({ text }: PlainSpanProps): ReactElement => {
    const t = useTranslation();
    const { highlightRegex, markRegex } = useContext(MarkupInteractionContext);

    const content = useMemo(() => {
Severity: Minor
Found in packages/gazzodown/src/elements/PlainSpan.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 CodeBlock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CodeBlock = ({ lines = [], language }: CodeBlockProps): ReactElement => {
    const ref = useRef<HTMLElement>(null);

    const { highlightRegex } = useContext(MarkupInteractionContext);

Severity: Minor
Found in packages/gazzodown/src/code/CodeBlock.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 LinkSpan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const LinkSpan = ({ href, label }: LinkSpanProps): ReactElement => {
    const t = useTranslation();
    const children = useMemo(() => {
        const labelArray = Array.isArray(label) ? label : [label];

Severity: Minor
Found in packages/gazzodown/src/elements/LinkSpan.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 getBadgeText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const getBadgeText = (badge: NonNullable<Badge>) => {
    if (typeof badge === 'number') {
        badge = Math.abs(badge | 0);

        if (badge > 999) {
Severity: Minor
Found in packages/favicon/src/badge.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 timeAgo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function timeAgo(dateParam: number, locale: string): string {
    const int = new Intl.RelativeTimeFormat(locale, { style: 'long' });

    const date = new Date(dateParam).getTime();
    const today = new Date().getTime();
Severity: Minor
Found in packages/gazzodown/src/elements/Timestamp/timeago.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 makeFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const makeFunction = <T extends BaseFunction>(fn: T): PatchedFunction<T> => {
    const patches = new Set<PatchData<T>>();

    patches.add({
        patchFunction: (_next, ...args) => fn(...args),
Severity: Minor
Found in packages/patch-injection/src/makeFunction.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 Button has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const Button = ({
    submit,
    form,
    disabled,
    outline,
Severity: Minor
Found in packages/livechat/src/components/Button/index.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 promptTranscript has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const promptTranscript = async () => {
    const {
        config: {
            messages: { transcriptMessage },
        },
Severity: Minor
Found in packages/livechat/src/lib/transcript.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 findPercentageOfAbandonedRooms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async findPercentageOfAbandonedRooms({
        start,
        end,
        departmentId,
        onlyCount = false,
Severity: Minor
Found in apps/meteor/server/models/raw/LivechatRooms.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 findAllAverageOfChatDurationTime has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    findAllAverageOfChatDurationTime({
        start,
        end,
        departmentId,
        onlyCount = false,
Severity: Minor
Found in apps/meteor/server/models/raw/LivechatRooms.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

export function validate(options: CasOptions, ticket: string, callback: CasCallback, renew = false): void {
    if (!options.base_url) {
        throw new Error('Required CAS option `base_url` missing.');
    }

Severity: Minor
Found in packages/cas-validate/src/validate.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 MessageSeparator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const MessageSeparator = ({ date, unread, use: Element = 'div', className, style = {}, t }: MessageSeparatorProps) => (
    <Element
        className={createClassName(
            styles,
            'separator',
Severity: Minor
Found in packages/livechat/src/components/Messages/MessageSeparator/index.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 shouldComponentUpdate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    shouldComponentUpdate(nextProps: RenderableProps<P>) {
        const { props } = this;

        for (const key in props) {
            if (props[key] !== nextProps[key]) {
Severity: Minor
Found in packages/livechat/src/helpers/MemoizedComponent.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