ClarityMoe/hibiki

View on GitHub
src/ext/CommandHandler.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function checkArguments has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
Open

    public checkArguments (msg: Eris.Message, given: string[], args: ICommandArg[]): Promise<{ [key: string]: any }> {
        const newArgs: { [key: string]: any } = {};

        for (const arg of args) {
            const i: number = args.indexOf(arg);
Severity: Minor
Found in src/ext/CommandHandler.ts - About 2 days to fix

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 checkArguments has 177 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public checkArguments (msg: Eris.Message, given: string[], args: ICommandArg[]): Promise<{ [key: string]: any }> {
        const newArgs: { [key: string]: any } = {};

        for (const arg of args) {
            const i: number = args.indexOf(arg);
Severity: Major
Found in src/ext/CommandHandler.ts - About 7 hrs to fix

File CommandHandler.ts has 360 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// CommandHandler.ts - Command handler (noud02)

import * as Eris from "eris";
import * as minimist from "minimist";
import * as pg from "pg";
Severity: Minor
Found in src/ext/CommandHandler.ts - About 4 hrs to fix

Function executeCommand has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public async executeCommand (msg: Eris.Message, command: string, args: minimist.ParsedArgs, prefix: string): Promise<any> {
        let subcommand: string | undefined = undefined; // tslint:disable-line:no-unnecessary-initializer

        if (command.indexOf(".") > -1) {
            subcommand = command.split(".")[1];
Severity: Minor
Found in src/ext/CommandHandler.ts - About 4 hrs to fix

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 executeCommand has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public async executeCommand (msg: Eris.Message, command: string, args: minimist.ParsedArgs, prefix: string): Promise<any> {
        let subcommand: string | undefined = undefined; // tslint:disable-line:no-unnecessary-initializer

        if (command.indexOf(".") > -1) {
            subcommand = command.split(".")[1];
Severity: Major
Found in src/ext/CommandHandler.ts - About 3 hrs to fix

Function checkMessage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public async checkMessage (msg: Eris.Message): Promise<void> {
        let guildPrefixes: string[] = [];
        let usedPrefix: string = "";
        let command: string = "";
        let args: minimist.ParsedArgs;
Severity: Minor
Found in src/ext/CommandHandler.ts - About 2 hrs to fix

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 checkMessage has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public async checkMessage (msg: Eris.Message): Promise<void> {
        let guildPrefixes: string[] = [];
        let usedPrefix: string = "";
        let command: string = "";
        let args: minimist.ParsedArgs;
Severity: Minor
Found in src/ext/CommandHandler.ts - About 1 hr to fix

Avoid deeply nested control flow statements.
Open

                        if (!(msg.channel instanceof Eris.GuildChannel)) {
                            return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    } else if (id.test(given[i])) {
                        const user: Eris.User | undefined = this.shard.users.get(given[i]);

                        if (!user) {
                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!user) {
                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                            if (user) {
                                newArgs[arg.name] = user;
                            }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!guild) {
                            return Promise.reject(this.shard.lm.t("search.guild_not_found", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    } else if (name.test(given[i])) {
                        const channel: Eris.GuildChannel = msg.channel.guild.channels.filter((c: Eris.GuildChannel) => c.type === 0 && c.name.indexOf(given[i]) > -1)[0];

                        if (!channel) {
                            return Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!role) {
                            return Promise.reject(this.shard.lm.t("search.role_not_found", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (!channel) {
                            return Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts - About 45 mins to fix

Function checkPermissions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public checkPermissions (msg: Eris.Message, perms: ICommandPermission[]): Promise<{ [key: string]: boolean }> {
        const newPerms: { [key: string]: boolean } = {};

        if (!(msg.channel instanceof Eris.GuildChannel)) {
            for (const perm of perms) {
Severity: Minor
Found in src/ext/CommandHandler.ts - About 35 mins to fix

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 Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return Promise.resolve(newArgs);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return msg.channel.createMessage(e);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return Promise.resolve();
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.guild_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return Promise.reject(this.shard.lm.t("commands.invalid_argument_type", {
                            argument: arg.name,
                            type: arg.type,
                            username: msg.author.username,
                        }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return Promise.reject(this.shard.lm.t("commands.invalid_argument_type", {
                            argument: arg.name,
                            type: arg.type,
                            username: msg.author.username,
                        }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return Promise.reject(this.shard.lm.t("commands.invalid_argument_type", {
                            argument: arg.name,
                            type: arg.type,
                            username: msg.author.username,
                        }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.role_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return Promise.resolve(newArgs);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.guild_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.channel_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return cmd.run(ctx);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return msg.channel.createMessage(e);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return msg.channel.createMessage(e);
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.role_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

                            return Promise.reject(this.shard.lm.t("search.role_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts - About 30 mins to fix

Function checkBotPermissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public checkBotPermissions (msg: Eris.Message, perms: ICommandPermission[]): Promise<{ [key: string]: boolean }> {
        const newPerms: { [key: string]: boolean } = {};

        if (!(msg.channel instanceof Eris.GuildChannel)) {
            for (const perm of perms) {
Severity: Minor
Found in src/ext/CommandHandler.ts - About 25 mins to fix

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    if (!mention.test(given[i]) && !name.test(given[i]) && !id.test(given[i])) {
                        return Promise.reject(this.shard.lm.t("commands.invalid_argument_type", {
                            argument: arg.name,
                            type: arg.type,
                            username: msg.author.username,
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 4 hrs to fix
src/ext/CommandHandler.ts on lines 381..387

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 117.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    if (!mention.test(given[i]) && !name.test(given[i]) && !id.test(given[i])) {
                        return Promise.reject(this.shard.lm.t("commands.invalid_argument_type", {
                            argument: arg.name,
                            type: arg.type,
                            username: msg.author.username,
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 4 hrs to fix
src/ext/CommandHandler.ts on lines 435..441

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 117.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    } else if (id.test(given[i])) {
                        const user: Eris.User | undefined = this.shard.users.get(given[i]);

                        if (!user) {
                            return Promise.reject(this.shard.lm.t("search.user_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 3 hrs to fix
src/ext/CommandHandler.ts on lines 482..498

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 110.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    if (id.test(given[i])) {
                        const guild: Eris.Guild | undefined = this.shard.guilds.get(given[i]);

                        if (!guild) {
                            return Promise.reject(this.shard.lm.t("search.guild_not_found", { username: msg.author.username }));
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 3 hrs to fix
src/ext/CommandHandler.ts on lines 347..367

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 110.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if (!perm.optional && !msg.channel.permissionsOf(msg.author.id).has(perm.name)) {
                return Promise.reject(this.shard.lm.t("permissions.user_lack_perms", {
                    permission: this.shard.lm.localizedPerm(perm.name),
                    username: msg.author.username,
                }));
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 262..267

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 71.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            if (!perm.optional && !msg.channel.permissionsOf(this.shard.user.id).has(perm.name)) {
                return Promise.reject(this.shard.lm.t("permissions.bot_lack_perms", {
                    permission: this.shard.lm.localizedPerm(perm.name),
                    username: msg.author.username,
                }));
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 230..235

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 71.

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

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

                    if (!(msg.channel instanceof Eris.GuildChannel)) {
                        return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
                    }
Severity: Major
Found in src/ext/CommandHandler.ts and 3 other locations - About 1 hr to fix
src/ext/CommandHandler.ts on lines 336..338
src/ext/CommandHandler.ts on lines 356..358
src/ext/CommandHandler.ts on lines 377..379

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 63.

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

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

                        if (!(msg.channel instanceof Eris.GuildChannel)) {
                            return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts and 3 other locations - About 1 hr to fix
src/ext/CommandHandler.ts on lines 356..358
src/ext/CommandHandler.ts on lines 377..379
src/ext/CommandHandler.ts on lines 431..433

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 63.

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

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

                        if (!(msg.channel instanceof Eris.GuildChannel)) {
                            return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
                        }
Severity: Major
Found in src/ext/CommandHandler.ts and 3 other locations - About 1 hr to fix
src/ext/CommandHandler.ts on lines 336..338
src/ext/CommandHandler.ts on lines 377..379
src/ext/CommandHandler.ts on lines 431..433

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 63.

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

Further Reading

Similar blocks of code found in 4 locations. Consider refactoring.
Open

                    if (!(msg.channel instanceof Eris.GuildChannel)) {
                        return Promise.reject(this.shard.lm.t("commands.guild_only", { username: msg.author.username }));
                    }
Severity: Major
Found in src/ext/CommandHandler.ts and 3 other locations - About 1 hr to fix
src/ext/CommandHandler.ts on lines 336..338
src/ext/CommandHandler.ts on lines 356..358
src/ext/CommandHandler.ts on lines 431..433

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 63.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (!(msg.channel instanceof Eris.GuildChannel)) {
            for (const perm of perms) {
                newPerms[perm.name] = true;
            }

Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 221..227

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 60.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (!(msg.channel instanceof Eris.GuildChannel)) {
            for (const perm of perms) {
                newPerms[perm.name] = true;
            }

Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 253..259

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 60.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        try {
            newPerms = await this.checkPermissions(msg, cmd.perms || []);
        } catch (e) {
            return msg.channel.createMessage(e);
        }
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 194..198

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 55.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        try {
            newBotPerms = await this.checkBotPermissions(msg, cmd.botPerms || []);
        } catch (e) {
            return msg.channel.createMessage(e);
        }
Severity: Major
Found in src/ext/CommandHandler.ts and 1 other location - About 1 hr to fix
src/ext/CommandHandler.ts on lines 188..192

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 55.

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

Further Reading

There are no issues that match your filters.

Category
Status