ClarityMoe/hibiki

View on GitHub

Showing 155 of 155 total issues

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

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

                    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

Function eval has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public async eval (code: string, customProps: { [key: string]: any }): Promise<any> {
        const builtins: string[] = require("repl")._builtinLibs;
        const context: IEvalContext = vm.createContext();

        for (const builtin of builtins) {
Severity: Major
Found in src/ext/Context.ts - About 3 hrs to fix

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

                    } 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

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

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

    public disconnect (): Promise<void> {
        return new Promise((resolve, reject) => {
            this.client.end((err: Error) => {
                if (err) {
                    return reject(err);
Severity: Major
Found in src/db/PostgreSQL.ts and 1 other location - About 2 hrs to fix
src/db/PostgreSQL.ts on lines 37..47

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

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

    public connect (): Promise<void> {
        return new Promise((resolve, reject) => {
            this.client.connect((err: Error) => {
                if (err) {
                    return reject(err);
Severity: Major
Found in src/db/PostgreSQL.ts and 1 other location - About 2 hrs to fix
src/db/PostgreSQL.ts on lines 54..64

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

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

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

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

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

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

Severity
Category
Status
Source
Language