Showing 165 of 254 total issues
Consider simplifying this complex logical expression. Open
Open
if (
(y === 0 && cursor === 'top') ||
(y === rows - 1 && cursor === 'bottom') ||
(x === 0 && cursor === 'left') ||
(x === columns - 1 && cursor === 'right')
Function findOrCreate1on1
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.findOrCreate1on1 = async function findOrCreate1on1(user, peerUserGId, network) {
assert(user && peerUserGId && network);
let conversation = null;
const userMembers = await ConversationMember.find({ userGId: user.gIdString });
Function createFrontendApp
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createFrontendApp() {
const app = new Koa();
app.on('error', err => {
if (err.status !== 404 && !error.errno === 'EPIPE') {
Function main
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function main() {
const { mode, fileName: mainEntryFileName } = getMainEntryFileNameAndMode();
const googleAuthEnabled = process.env['GOOGLE_AUTH'] === 'true';
const serverPort = process.env['WEB_SERVER_PORT'] || 3100;
Function handleIdentConnection
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function handleIdentConnection(socket) {
const timer = setTimeout(() => {
if (socket) {
socket.destroy();
}
Function createReset
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.createReset = async function createReset(ctx) {
const form = await decodeForm(ctx.req, registrationFormReset);
const userId = await redis.get(`frontend:password_reset_token:${form.data.token}`);
async function renderForm() {
Function create
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static async create(props, { skipSetters = false } = {}) {
trimWhiteSpace(props);
if (!skipSetters) {
const passwordValidation = validatePassword(props.password);
Function createNodeSpec
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec {
return {
selectable: true,
draggable: false,
...override,
Function handleUpdateWindowServer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
handleUpdateWindowServer({
windowId = mandatory(),
userId,
network,
windowType,
- 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 handleCommand
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
async function handleCommand({ command, conversation, user, backend }) {
const { command: name, params } = command;
if (!conversation) {
return { status: 'ERROR', errorMsg: 'Invalid windowId.' };
- 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 handleProcessLine
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
handleProcessLine({ window = mandatory(), body = mandatory() }) {
let command = false;
let commandParams;
if (body.charAt(0) === '/') {
Function sendText
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async sendText(window: WindowModel, text: string, doc?: RemirrorJSON): Promise<void> {
let sent = false;
setTimeout(() => {
if (!sent) {
Function getMessageRange
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getMessageRange(conversationId, start, end, amount) {
if (!elasticSearchAvailable()) {
return [];
}
Function dispatch
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function dispatch(type, data = {}, acceptCb = noopCb, rejectCb = noopCb) {
let consumed = false;
const name = type
.split('_')
.map(part => part.toLowerCase().capitalize())
Function _whichSection
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_whichSection(windowDim, x, y) {
// -----------------
// |\ t /|
// | \ / |
// | ----------- |
Function process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.process = async function process(session, command) {
const { windowId } = command;
const network = typeof command.network === 'string' ? command.network.toLowerCase() : null;
const user = session.user;
Function useMessageRemirror
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function useMessageRemirror(): MessageRemirror {
const extensions = useMemo(
() => () =>
[
new BoldExtension(),
Function deleteConversationMember
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function deleteConversationMember(conversation, member, options) {
log.info(`User: ${member.get('userGId')} removed from conversation: ${conversation.id}`);
if (!options.silent && conversation.get('type') === 'group') {
await broadcastAddMessage(conversation, {
Function updateMembers
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateMembers(id: number, members: Array<{ userId: string; role: Role }>, reset: boolean): void {
const window = this.windows.get(id);
if (!window) {
return;
Function _calculateCursorPosition
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_calculateCursorPosition(event) {
const outOfBoundsCursor = { x: null, y: null, section: null };
const x = event.clientX;
const y = event.clientY;