RocketChat/Rocket.Chat

View on GitHub

Showing 9,144 of 9,144 total issues

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

const useDropdownPosition = (reference: RefObject<HTMLElement>, target: RefObject<HTMLElement>) => {
    const innerContainer = getDropdownContainer(reference.current);
    const viewHeight = document.body.getBoundingClientRect().height;
    const refTop = reference.current?.getBoundingClientRect().top ?? 0;
    const targetHeight = target.current?.getBoundingClientRect().height || 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 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 Room has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const Room = (): ReactElement => {
    const t = useTranslation();
    const room = useRoom();
    const toolbox = useRoomToolbox();
    const contextualBarView = useAppsContextualBar();
Severity: Minor
Found in apps/meteor/client/views/room/Room.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 DeviceManagementAdminTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const DeviceManagementAdminTable = ({ reloadRef }: { reloadRef: MutableRefObject<() => void> }): ReactElement => {
    const t = useTranslation();
    const [text, setText] = useState('');
    const { current, itemsPerPage, setCurrent, setItemsPerPage, ...paginationProps } = usePagination();
    const { sortBy, sortDirection, setSort } = useSort<'client' | 'os' | 'username' | 'loginAt'>('username');

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

const getDropdownContainer = (descendant: HTMLElement | null) => {
    for (let element = descendant ?? document.body; element !== document.body; element = element.parentElement ?? document.body) {
        if (
            getComputedStyle(element).transform !== 'none' ||
            getComputedStyle(element).position === 'fixed' ||

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

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

    const utc = timezone === 'utc';

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

const CustomSoundsTable = ({ reload, onClick }: CustomSoundsTableProps) => {
    const t = useTranslation();
    const { sortBy, sortDirection, setSort } = useSort<'name'>('name');
    const { current, itemsPerPage, setItemsPerPage: onSetItemsPerPage, setCurrent: onSetCurrent, ...paginationProps } = usePagination();

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

const AppSetting = ({ id, type, i18nLabel, i18nDescription, values, value, packageValue, ...props }: ISetting): ReactElement => {
    const appId = useRouteParameter('id');
    const tApp = useAppTranslation(appId || '');

    const label = (i18nLabel && tApp(i18nLabel)) || id || tApp(id);

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

const AppDetailsPageHeader = ({ app }: { app: App }): ReactElement => {
    const t = useTranslation();
    const {
        iconFileData,
        name,

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

const AgentField = ({ agent, isSmall = false }: AgentFieldProps) => {
    const t = useTranslation();
    const { username = '' } = agent ?? {};
    const getUserInfo = useEndpoint('GET', '/v1/users.info');
    const { data, isLoading } = useQuery(['/v1/users.info', username], () => getUserInfo({ username }));
Severity: Minor
Found in apps/meteor/client/views/omnichannel/directory/components/AgentField.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 BusinessHoursRouter has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const BusinessHoursRouter = () => {
    const router = useRouter();
    const context = useRouteParameter('context');
    const id = useRouteParameter('id');
    const type = useRouteParameter('type') as LivechatBusinessHourTypes;

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

const AppRow = ({ className, ...props }: App & { className?: string }): ReactElement => {
    const { name, id, shortDescription, iconFileData, marketplaceVersion, iconFileContent, installed, bundledIn, version } = props;

    const router = useRouter();
    const context = useRouteParameter('context');
Severity: Minor
Found in apps/meteor/client/views/marketplace/AppsList/AppRow.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 useRemoveRoomFromTeam has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const useRemoveRoomFromTeam = (room: IRoom, { reload }: { reload?: () => void }) => {
    const t = useTranslation();
    const setModal = useSetModal();
    const dispatchToastMessage = useToastMessageDispatch();
    const canRemoveTeamChannel = usePermission('remove-team-channel', room._id);

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

function AddAgent({ agentList, onAdd }: { agentList: IDepartmentAgent[]; onAdd: (agent: IDepartmentAgent) => void }) {
    const t = useTranslation();

    const [userId, setUserId] = useState('');

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

const LegacyBanner = ({ config }: LegacyBannerProps) => {
    const { closable = true, title, text, html, icon, modifiers } = config;

    const inline = !modifiers?.includes('large');
    const variant = modifiers?.includes('danger') ? 'danger' : 'info';
Severity: Minor
Found in apps/meteor/client/views/banners/LegacyBanner.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 TeamsInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const TeamsInfo = ({
    room,
    onClickHide,
    onClickClose,
    onClickLeave,
Severity: Minor
Found in apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.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 TeamsChannels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const TeamsChannels = ({
    loading,
    channels = [],
    mainRoom,
    text,
Severity: Minor
Found in apps/meteor/client/views/teams/contextualBar/channels/TeamsChannels.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 WebhooksPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const WebhooksPage = ({ settings }: WebhooksPageProps) => {
    const t = useTranslation();
    const dispatchToastMessage = useToastMessageDispatch();
    const defaultValues = getInitialValues(settings);
    const {
Severity: Minor
Found in apps/meteor/client/views/omnichannel/webhooks/WebhooksPage.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 ContactTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function ContactTable(): ReactElement {
    const { current, itemsPerPage, setItemsPerPage, setCurrent, ...paginationProps } = usePagination();
    const { sortBy, sortDirection, setSort } = useSort<'username' | 'phone' | 'name' | 'visitorEmails.address' | 'lastChat.ts'>('username');
    const isCallReady = useIsCallReady();

Severity: Minor
Found in apps/meteor/client/views/omnichannel/directory/contacts/ContactTable.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 CurrentUserDisplay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CurrentUserDisplay = ({ user }: CurrentUserDisplayProps) => {
    const showRealNames = useSetting<boolean>('UI_Use_Real_Name');
    const getRoles = useRolesDescription();

    const { t } = useTranslation();
Severity: Minor
Found in apps/meteor/client/views/oauth/components/CurrentUserDisplay.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