Showing 67 of 92 total issues
Function botHandle
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
const botHandle = function botHandle(err, bot) {
const receiveData = function receiveData(socket, bot, data) {
// Handle incoming messages.
let message = `${data}`;
Function letterLookup
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
const letterLookup = function letterLookup(cb) {
let reply = '';
const lastWord = this.message.lemWords.slice(-1)[0];
debug('--LastWord', lastWord);
Function eachGambitHandle
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
const eachGambitHandle = async function eachGambitHandle(gambit, message, options) {
const plugins = options.system.plugins;
const scope = options.system.scope;
const topic = options.topic || 'reply';
const chatSystem = options.system.chatSystem;
Function inlineRedirect
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
const inlineRedirect = async function inlineRedirect(triggerTarget, options) {
debug.verbose(`Inline redirection to: '${triggerTarget}'`);
// if we have a special topic, reset it to the previous one
// in order to preserve the context for inline redirection
- 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 postParse
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const postParse = function postParse(regexp, message, user) {
if (_.isNull(regexp)) {
return null;
}
Function findConversationTopics
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const findConversationTopics = async function findConversationTopics(pendingTopics, user, chatSystem, conversationTimeout) {
if (user.history.length === 0) {
return pendingTopics;
}
Function processReplyTags
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const processReplyTags = async function processReplyTags(replyObj, options) {
debug.verbose('Depth: ', options.depth);
let replyString = replyObj.reply.reply;
debug.info(`Reply before processing reply tags: "${replyString}"`);
Function processStars
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const processStars = function processStars(match, gambit, topic) {
debug.verbose(`Match found: ${gambit.input} in topic: ${topic}`);
const stars = [];
if (match.length > 1) {
for (let j = 1; j < match.length; j++) {
- 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 findMatches
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const findMatches = async function findMatches(pendingTopics, messageObject, options) {
debug.verbose(`Found pending topics/conversations: ${JSON.stringify(pendingTopics)}`);
const replies = [];
let stopSearching = false;
Function inlineRedirect
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const inlineRedirect = async function inlineRedirect(triggerTarget, options) {
debug.verbose(`Inline redirection to: '${triggerTarget}'`);
// if we have a special topic, reset it to the previous one
// in order to preserve the context for inline redirection
Function eachTopicItor
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const eachTopicItor = function eachTopicItor(topicName, nextTopic) {
const topic = data.topics[topicName];
debug.verbose(`Find or create topic with name '${topicName}'`);
const topicProperties = {
name: topic.name,
Function findConversationTopics
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const findConversationTopics = async function findConversationTopics(pendingTopics, user, chatSystem, conversationTimeout) {
if (user.history.length === 0) {
return pendingTopics;
}
- 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 matchItorHandle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const matchItorHandle = async function matchItorHandle(match, message, options) {
const system = options.system;
options.message = message;
debug.verbose('Match itor: ', match.gambit);
- 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 doesMatch
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const doesMatch = async function doesMatch(gambit, message, options) {
if (gambit.conditions && gambit.conditions.length > 0) {
const conditionsMatch = processConditions(gambit.conditions, options);
if (!conditionsMatch) {
debug.verbose('Conditions did not match');
- 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 processCustomFunction
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const processCustomFunction = async function processCustomFunction(tag, replyObj, options) {
if (tag.functionArgs === null) {
debug.verbose(`Processing custom function: ^${tag.functionName}()`);
return customFunction(tag.functionName, [], replyObj, options);
}
Function createReplyModel
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createReplyModel = function createReplyModel(db) {
const replySchema = new mongoose.Schema({
id: { type: String, index: true, default: Utils.genId() },
reply: { type: String, required: '{reply} is required.' },
keep: { type: Boolean, default: false },
Function doesMatch
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const doesMatch = async function doesMatch(gambit, message, options) {
if (gambit.conditions && gambit.conditions.length > 0) {
const conditionsMatch = processConditions(gambit.conditions, options);
if (!conditionsMatch) {
debug.verbose('Conditions did not match');
Function filterRepliesByFunction
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const filterRepliesByFunction = async function filterRepliesByFunction(potentialReplies, options) {
const bits = await Promise.all(potentialReplies.map(async (potentialReply) => {
const system = options.system;
// We support a single filter function in the reply
- 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 eachGambitHandle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const eachGambitHandle = async function eachGambitHandle(gambit, message, options) {
const plugins = options.system.plugins;
const scope = options.system.scope;
const topic = options.topic || 'reply';
const chatSystem = options.system.chatSystem;
- 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 wordLength
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
const wordLength = function wordLength(cap, cb) {
if (typeof cap === 'string') {
const parts = cap.split(' ');
if (parts.length === 1) {
cb(null, cap.length);
- 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"