File request.js
has 450 lines of code (exceeds 250 allowed). Consider refactoring. Open
//
// Copyright 2014 Ilkka Oksanen <iao@iki.fi>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Function process
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. 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;
- 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 handleUpdate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
async function handleUpdate({ user, command, window, session }) {
const accepted = ['row', 'column', 'minimizedNamesList', 'desktop'];
const acceptedAlerts = ['email', 'notification', 'sound', 'title'];
if (!window) {
- 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
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 process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. 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 handleSet
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async function handleSet({ user, command }) {
const properties = command.settings || {};
const keys = Object.keys(properties);
if (keys.length === 0) {
- 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 handleJoin
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async function handleJoin({ user, command, backend, network }) {
if (!command.name || !command.network) {
return { status: 'PARAMETER_MISSING', errorMsg: 'Name or network missing.' };
}
- 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
Avoid too many return
statements within this function. Open
return courier.call(backend, 'textCommand', {
userId: user.id,
conversationId: conversation.id,
command: name,
commandParams: params
Avoid too many return
statements within this function. Open
return { status: 'OK' };
Avoid too many return
statements within this function. Open
return start1on1(user, targetUserGId, targetUserGId.isMASUser ? 'mas' : network);
Avoid too many return
statements within this function. Open
return { status: 'OK' };
Avoid too many return
statements within this function. Open
return { status: 'ERROR', errorMsg: 'Nick missing, use e.g. /ircquery john' };
Function start1on1
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function start1on1(user, targetUserGId, network) {
let selectedNetwork = network;
if (!targetUserGId || !targetUserGId.valid) {
return { status: 'ERROR', errorMsg: 'Malformed request.' };
- 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"