Function matchesAgainstMessage
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
matchesAgainstMessage(message: DiscordJS.Message) {
// Check against user conditions first
if ('user' in this.data) {
if (!this.matchesAgainstUserConditions(message)) {
console.log('user does 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
File condition.js
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* @flow */
import DiscordJS from 'discord.js'
import Discord from './bot/discord'
import Config from './config'
Function matchesAgainstUserConditions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
matchesAgainstUserConditions(message: DiscordJS.Message) {
if (!('user' in this.data)) {
return true
}
- 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 matchesAgainstMessage
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
matchesAgainstMessage(message: DiscordJS.Message) {
// Check against user conditions first
if ('user' in this.data) {
if (!this.matchesAgainstUserConditions(message)) {
console.log('user does not match')
Function constructor
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(server: DiscordJS.Guild, values: ConditionValues) {
this.data = values
this.server = server
this.modifiers = values.modifiers || []
this.matchSuccess = true
Function constructor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
constructor(server: DiscordJS.Guild, values: ConditionValues) {
this.data = values
this.server = server
this.modifiers = values.modifiers || []
this.matchSuccess = true
- 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 matchesAgainstUserConditions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
matchesAgainstUserConditions(message: DiscordJS.Message) {
if (!('user' in this.data)) {
return true
}
Function isValid
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
isValid() {
try {
this.validateKeys()
// this.validateType(this.data, 'message', 'array') // could be string or array?
Function validateType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
validateType(obj: Object, key: string, expectedType: string) {
if (!(key in obj)) {
return
}
- 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 match === this.matchSuccess