Showing 92 of 92 total issues
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,
Similar blocks of code found in 2 locations. Consider refactoring. Open
const redirectMessage = await new Promise((resolve, reject) => {
Message.createMessage(topicTrigger, messageOptions, (err, redirectMessage) => {
err ? reject(err) : resolve(redirectMessage);
});
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 57.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
const redirectMessage = await new Promise((resolve, reject) => {
Message.createMessage(triggerTarget, messageOptions, (err, redirectMessage) => {
err ? reject(err) : resolve(redirectMessage);
});
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 57.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"
Further reading
Identical blocks of code found in 2 locations. Consider refactoring. Open
const redirectReply = await new Promise((resolve, reject) => {
getReply(redirectMessage, options, (err, redirectReply) => {
err ? reject(err) : resolve(redirectReply);
});
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 53.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
const redirectReply = await new Promise((resolve, reject) => {
getReply(redirectMessage, options, (err, redirectReply) => {
err ? reject(err) : resolve(redirectReply);
});
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 53.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76