Showing 31 of 70 total issues
Function triggerAction
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public async triggerAction(userId: string, msg: OnMessageState): Promise<void> {
for (const pair of this.commandRegistry.getRegistryMap().entries()) {
if (pair[1] instanceof TriggerableCommand) {
const command: TriggerableCommand = pair[1] as TriggerableCommand;
if (await command.tryTrigger(msg)) {
- 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 getImportPaths
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected getImportPaths(): string[] {
const filePaths: string[] = [];
for (const modulePath of this.MODULE_PATHS) {
let files: string[];
try {
- 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 setCustomAction
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState, args: string[]): Promise<boolean> => {
const user = state.getHandle().author;
try {
if (isNaN(args[0] as any)) {
Function setCustomAction
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState) => {
try {
const userModel = DBUserSchema.getModel();
const userId = state.getHandle().author.id;
Function attemptExecution
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private async attemptExecution(command: Command, args: string[], userId: string, msg: OnMessageState): Promise<void> {
if (!this.core.getDbCore().isReady()) {
this.logger.warn("Please wait until database connection has resolved.");
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
Function setCustomAction
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState): Promise<boolean> => {
const message = state.getHandle();
const author = message.author;
const core = state.getCore();
Function setCustomAction
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState, args: string[]): Promise<boolean> => {
const user = state.getHandle().author;
if (!args[0]) { // If the user doesn't specify an argument - shouldn't technically see this
Function setCustomAction
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState): Promise<boolean> => {
const user = state.getHandle().author;
try {
const doc = await DBUserSchema.getUserById(user.id);
Function LevenshteinDistance
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const LevenshteinDistance = (a: string, b: string): number => {
if (a.length === 0 || b.length === 0) {
return a.length === 0 ? b.length : a.length;
}
const matrix: number[][] = MathUtil.zeros(a.length + 1, b.length + 1);
- 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 awardUsers
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async awardUsers(state: OnMessageState, users: IdContributionPair[], DbBrad: DBBradPropertySchema): Promise<void> {
const channel = state.getHandle().channel;
const client = state.getCore().getClient();
const embed = new Discord.RichEmbed();
embed.setTitle("Brad is pleased.");
Function constructor
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public constructor(className: string) {
this.logger = winston.createLogger({
format: winston.format.combine(
winston.format.label({ label: className }),
),
Function attemptExecution
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async attemptExecution(command: Command, args: string[], userId: string, msg: OnMessageState): Promise<void> {
if (!this.core.getDbCore().isReady()) {
this.logger.warn("Please wait until database connection has resolved.");
return;
}
Function setCustomAction
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setCustomAction(): Action {
return new Action(async (state: OnMessageState, args: string[]): Promise<boolean> => {
try {
const guild = await DBGuildPropertySchema.getGuildById(state.getHandle().guild.id);
if (GuildConfig.BooleanConfig.keys.indexOf(args[Args.CONFIG_NAME]) !== -1) {
Function awardUsers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private async awardUsers(state: OnMessageState, users: IdContributionPair[], DbBrad: DBBradPropertySchema): Promise<void> {
const channel = state.getHandle().channel;
const client = state.getCore().getClient();
const embed = new Discord.RichEmbed();
embed.setTitle("Brad is pleased.");
- 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 createModels
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const createModels = async (ids: string[]): Promise<void> => {
let i = 0;
for (const userId of ids) {
const user = await DBUserSchema.getUserById(userId);
if (!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 getImportPaths
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected getImportPaths(): string[] {
const filePaths: string[] = [];
for (const modulePath of this.MODULE_PATHS) {
let files: string[];
try {
Function parseLine
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public parseLine(line: string, id: string, msg: OnMessageState): void {
for (const prefix of this.prefixManager.getPrefixes()) {
if (line.split(" ")[0] === prefix) {
const commandString = this.extractCommand(line);
if (!commandString) {
- 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 loadItems
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public async loadItems(): Promise<void> {
const importPaths: string[] = this.getImportPaths();
this.logger.info(`Detected ${importPaths.length}` +
` ${importPaths.length === 1 ? "item" : "items"} for import.`);
for (const path of importPaths) {
- 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 addCommand
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public addCommand(command: AbstractCommand): boolean {
const name: string = command.getCommandString();
if (command instanceof TriggerableCommand) {
if (this.registry.has(command.constructor.name)) {
this.logger.warn(`Duplicate command "${command.constructor.name}".`);
- 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 loadCommands
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public async loadCommands(): Promise<void> {
const importPaths: string[] = this.getImportPaths();
this.logger.info(`Detected ${importPaths.length}` +
` ${importPaths.length === 1 ? "command" : "commands"} for import.`);
for (const path of importPaths) {
- 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"