Showing 67 of 92 total issues
Function sortTriggerSet
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
const sortTriggerSet = function sortTriggerSet(gambits) {
let gambit;
let cnt;
let inherits;
- 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 importData
has 149 lines of code (exceeds 25 allowed). Consider refactoring. Open
const importData = function importData(chatSystem, data, callback) {
if (!data.version || data.version < MIN_SUPPORTED_SCRIPT_VERSION) {
return callback(`Error: Your script has version ${data.version} but the minimum supported version is ${MIN_SUPPORTED_SCRIPT_VERSION}.\nPlease either re-parse your file with a supported parser version, or update SuperScript.`);
}
Function createUserModel
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createUserModel = function createUserModel(db, factSystem, logger) {
const userSchema = mongoose.Schema({
id: String,
currentTopic: { type: String, default: 'random' },
pendingTopic: String,
File processTags.js
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Open
// TODO: Fix this documentation, options is incorrect
/**
* Parse the reply for additional tags, this is called once we have a reply candidate filtered out.
*
* @param {Object} replyObj - The Reply Object
Function letterLookup
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
const letterLookup = function letterLookup(cb) {
let reply = '';
const lastWord = this.message.lemWords.slice(-1)[0];
debug('--LastWord', lastWord);
- 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 sortTriggerSet
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
const sortTriggerSet = function sortTriggerSet(gambits) {
let gambit;
let cnt;
let inherits;
Function createTopicModel
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createTopicModel = function createTopicModel(db) {
const topicSchema = new mongoose.Schema({
name: { type: String, index: true, unique: true },
system: { type: Boolean, default: false },
Function afterHandle
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const afterHandle = function afterHandle(matches) {
debug.verbose(`Set of matches: ${matches}`);
const debugAll = [];
let props = {};
Function createGambitModel
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createGambitModel = function createGambitModel(db, factSystem) {
const gambitSchema = new mongoose.Schema({
id: { type: String, index: true, default: Utils.genId() },
// This is the input string that generates a rule,
Function topicItorHandle
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const topicItorHandle = async function topicItorHandle(topicData, messageObject, options) {
const system = options.system;
if (topicData.type === 'TOPIC') {
const topic = await system.chatSystem.Topic.findById(topicData.id, '_id name filter gambits')
- 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 _reply
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
_reply(messageString, options, callback) {
const system = {
// Pass in the topic if it has been set
topicName: options.topicName || null,
plugins: this.plugins,
Function matchItorHandle
has 50 lines of code (exceeds 25 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);
Function processTag
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
const processTag = async function processTag(tag, replyObj, options) {
if (typeof tag === 'string') {
return tag;
}
Function findPendingTopicsForUser
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const findPendingTopicsForUser = async function findPendingTopicsForUser(user, message, chatSystem, conversationTimeout) {
const allTopics = await chatSystem.Topic.find({}).lean().exec();
const tfidf = new TfIdf();
Function findMatches
has a Cognitive Complexity of 15 (exceeds 5 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;
- 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 findPendingTopicsForUser
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const findPendingTopicsForUser = async function findPendingTopicsForUser(user, message, chatSystem, conversationTimeout) {
const allTopics = await chatSystem.Topic.find({}).lean().exec();
const tfidf = new TfIdf();
- 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 updateHistory
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
userSchema.methods.updateHistory = function (message, reply, cb) {
if (!_.isNull(message)) {
this.lastMessageSentAt = Date.now();
}
Function topicItorHandle
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const topicItorHandle = async function topicItorHandle(topicData, messageObject, options) {
const system = options.system;
if (topicData.type === 'TOPIC') {
const topic = await system.chatSystem.Topic.findById(topicData.id, '_id name filter gambits')
Function receiveData
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const receiveData = function receiveData(slack, bot, data) {
// Fetch the user who sent the message;
const user = data._client.users[data.user];
let channel;
const messageData = data.toJSON();
Function customFunction
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const customFunction = async function customFunction(functionName, functionArgs, replyObj, options) {
const plugins = options.system.plugins;
// Important to create a new scope object otherwise we could leak data
const scope = _.merge({}, options.system.scope);
scope.extraScope = options.system.extraScope;