Showing 3,268 of 8,229 total issues
File Helper.ts
has 638 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { LivechatTransferEventType } from '@rocket.chat/apps-engine/definition/livechat';
import { api, Message, Omnichannel } from '@rocket.chat/core-services';
import type {
ILivechatVisitor,
IOmnichannelRoom,
Function AccountProfileForm
has 280 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactElement => {
const t = useTranslation();
const user = useUser();
const dispatchToastMessage = useToastMessageDispatch();
File FileUpload.ts
has 629 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Buffer } from 'buffer';
import type { WriteStream } from 'fs';
import fs from 'fs';
import { unlink, rename, writeFile } from 'fs/promises';
import type * as http from 'http';
Function createComposerAPI
has 275 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const createComposerAPI = (input: HTMLTextAreaElement, storageID: string): ComposerAPI => {
const triggerEvent = (input: HTMLTextAreaElement, evt: string): void => {
const event = new Event(evt, { bubbles: true });
// TODO: Remove this hack for react to trigger onChange
const tracker = (input as any)._valueTracker;
Function prepareUsingLocalFile
has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring. Open
async prepareUsingLocalFile(fullFilePath: string): Promise<ImporterProgress> {
this.logger.debug('start preparing import operation');
await this.converter.clearImportData();
const zip = new this.AdmZip(fullFilePath);
- Read upRead up
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
File SlackImporter.ts
has 614 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { IImportUser, IImportMessage, IImportPendingFile } from '@rocket.chat/core-typings';
import { Messages, Settings, ImportData } from '@rocket.chat/models';
import type { IZipEntry } from 'adm-zip';
import { Importer, ProgressStep, ImporterWebsocket } from '../../importer/server';
Function prepareMessageObject
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
async prepareMessageObject(message: SlackMessage, missedTypes: Record<string, SlackMessage>, slackChannelId: string): Promise<void> {
const id = this.makeSlackMessageId(slackChannelId, message.ts);
const newMessage: IImportMessage = {
_id: id,
rid: slackChannelId,
- Read upRead up
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 addOAuthService
has 256 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function addOAuthService(name: string, values: { [k: string]: string | boolean | undefined } = {}): Promise<void> {
name = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
name = capitalize(name);
await settingsRegistry.add(`Accounts_OAuth_Custom-${name}`, values.enabled || false, {
type: 'boolean',
Function NewImportPage
has 256 lines of code (exceeds 25 allowed). Consider refactoring. Open
function NewImportPage() {
const t = useTranslation();
const dispatchToastMessage = useToastMessageDispatch();
const handleError = useErrorHandler();
File VideoConfManager.ts
has 583 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { Emitter } from '@rocket.chat/emitter';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
File EmailInboxForm.tsx
has 581 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { IEmailInboxPayload } from '@rocket.chat/core-typings';
import {
Accordion,
Button,
ButtonGroup,
File triggerHandler.js
has 580 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Integrations, Users, Rooms, Messages } from '@rocket.chat/models';
import { serverFetch as fetch } from '@rocket.chat/server-fetch';
import { wrapExceptions } from '@rocket.chat/tools';
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
File widget.ts
has 576 lines of code (exceeds 250 allowed). Consider refactoring. Open
import type { UserStatus } from '@rocket.chat/core-typings';
import type { LivechatRoomEvents } from '@rocket.chat/ddp-client/dist/livechat/types/LivechatSDK';
import mitt from 'mitt';
import { isDefined } from './helpers/isDefined';
Function createDataAPI
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
export const createDataAPI = ({ rid, tmid }: { rid: IRoom['_id']; tmid: IMessage['_id'] | undefined }): DataAPI => {
const composeMessage = async (
text: string,
{ sendToChannel, quotedMessages, originalMessage }: { sendToChannel?: boolean; quotedMessages: IMessage[]; originalMessage?: IMessage },
): Promise<IMessage> => {
- Read upRead up
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 addUser
has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring. Open
async addUser(slackUserID) {
rocketLogger.debug('Adding Rocket.Chat user from Slack', slackUserID);
let addedUser;
for await (const slack of this.slackAdapters) {
if (addedUser) {
- Read upRead up
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
File teams.ts
has 565 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Team } from '@rocket.chat/core-services';
import type { ITeam, UserStatus } from '@rocket.chat/core-typings';
import { TEAM_TYPE } from '@rocket.chat/core-typings';
import { Users, Rooms } from '@rocket.chat/models';
import {
File index.js
has 553 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*
Node.js POP3 client library
Copyright (C) 2011-2013 by Ditesh Shashikant Gathani <ditesh@gathani.org>
Function executeTriggerUrl
has 229 lines of code (exceeds 25 allowed). Consider refactoring. Open
async executeTriggerUrl(url, trigger, { event, message, room, owner, user }, theHistoryId, tries = 0) {
if (!this.isTriggerEnabled(trigger)) {
outgoingLogger.warn(`The trigger "${trigger.name}" is no longer enabled, stopping execution of it at try: ${tries}`);
return;
}
Function reducer
has 229 lines of code (exceeds 25 allowed). Consider refactoring. Open
const reducer = (state: initialStateType, action: IAction) => {
const { activeProject, activeScreen } = state;
switch (action.type) {
case ActionTypes.IsMobile:
return { ...state, isMobile: action.payload };
Function RoomBody
has 229 lines of code (exceeds 25 allowed). Consider refactoring. Open
const RoomBody = (): ReactElement => {
const chat = useChat();
if (!chat) {
throw new Error('No ChatContext provided');
}