aXises/fortniteBot

View on GitHub

Showing 70 of 70 total issues

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 }),
            ),
Severity: Minor
Found in src/log/Logger.ts - About 1 hr to fix

    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;
            }
    Severity: Minor
    Found in src/managers/CommandManager.ts - About 1 hr to fix

      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) {
      Severity: Minor
      Found in src/command/modules/config/SetConfig.ts - About 1 hr to fix

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

                        if (dbBrad.contributors.length !== 0) {
                            embed.addField(`Top Contributors (Current Run)`,
                            `${this.getUserString(state, dbBrad.contributors)}`);
                        }
        Severity: Major
        Found in src/command/modules/brad/BradStats.ts and 1 other location - About 1 hr to fix
        src/command/modules/brad/BradStats.ts on lines 49..52

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

        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 (dbBrad.contributorsAllTime.length !== 0) {
                            embed.addField(`Top Contributors (All time)`,
                            `${this.getUserString(state, dbBrad.contributorsAllTime)}`);
                        }
        Severity: Major
        Found in src/command/modules/brad/BradStats.ts and 1 other location - About 1 hr to fix
        src/command/modules/brad/BradStats.ts on lines 45..48

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

        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 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.");
        Severity: Minor
        Found in src/command/modules/brad/FeedBrad.ts - About 1 hr 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 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) {
        Severity: Minor
        Found in src/database/migration/UserMigration.ts - About 1 hr 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 (indexAll === -1) {
                        this.contributorsAllTime.push(new IdContributionPair(id, amount));
                    } else {
                        this.contributorsAllTime[indexAll].contribution += amount;
                    }
        Severity: Major
        Found in src/database/schemas/DBBradPropertySchema.ts and 1 other location - About 1 hr to fix
        src/database/schemas/DBBradPropertySchema.ts on lines 33..37

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

        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 {
                    await this.markModified("daily");
                    return await this.save();
                } catch (err) {
                    DBUserSchema.logger.error("Failed to save user daily.");
        Severity: Major
        Found in src/database/schemas/DBUserSchema.ts and 1 other location - About 1 hr to fix
        src/database/schemas/DBUserSchema.ts on lines 106..112

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

        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 {
                    await this.markModified("wallet");
                    return await this.save();
                } catch (err) {
                    DBUserSchema.logger.error("Failed to save user currency.");
        Severity: Major
        Found in src/database/schemas/DBUserSchema.ts and 1 other location - About 1 hr to fix
        src/database/schemas/DBUserSchema.ts on lines 59..65

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

        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 (index === -1) {
                        this.contributors.push(new IdContributionPair(id, amount));
                    } else {
                        this.contributors[index].contribution += amount;
                    }
        Severity: Major
        Found in src/database/schemas/DBBradPropertySchema.ts and 1 other location - About 1 hr to fix
        src/database/schemas/DBBradPropertySchema.ts on lines 39..43

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

        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 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 {
        Severity: Minor
        Found in src/managers/DynamicImportManager.ts - About 1 hr to fix

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

                  export const DEBUG_CHANNELS: string[] = process.env.DEBUG_CHANNELS ?
                      process.env.DEBUG_CHANNELS.replace(/\s/g, "").split(",") : undefined;
          Severity: Major
          Found in src/config/Config.ts and 1 other location - About 1 hr to fix
          src/config/Config.ts on lines 50..51

          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

                  export const IDS: string[] = process.env.DEV_IDS ?
                      process.env.DEV_IDS.replace(/\s/g, "").split(",") : undefined;
          Severity: Major
          Found in src/config/Config.ts and 1 other location - About 1 hr to fix
          src/config/Config.ts on lines 10..11

          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

          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) {
          Severity: Minor
          Found in src/managers/CommandManager.ts - About 55 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

                      for (const key of GuildConfig.BooleanConfig.keys) {
                          if (!(await model.booleanConfigExists(key))) {
                              await model.addBooleanConfig(key);
                          }
                      }
          Severity: Minor
          Found in src/database/schemas/DBGuildPropertySchema.ts and 1 other location - About 55 mins to fix
          src/database/migration/GuildPropertyMigration.ts on lines 26..30

          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

          Further Reading

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

                      for (const key of GuildConfig.BooleanConfig.keys) {
                          if (!(await guild.booleanConfigExists(key))) {
                              await guild.addBooleanConfig(key);
                          }
                      }
          Severity: Minor
          Found in src/database/migration/GuildPropertyMigration.ts and 1 other location - About 55 mins to fix
          src/database/schemas/DBGuildPropertySchema.ts on lines 126..130

          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

          Further Reading

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

              public static getModel(): Mongoose.Model<InstanceType<DBGuildPropertySchema>> & DBGuildPropertySchema & typeof DBGuildPropertySchema {
                  return new DBGuildPropertySchema().getModelForClass(DBGuildPropertySchema);
              }
          Severity: Major
          Found in src/database/schemas/DBGuildPropertySchema.ts and 3 other locations - About 50 mins to fix
          src/database/schemas/DBBradPropertySchema.ts on lines 79..81
          src/database/schemas/DBGlobalPropertySchema.ts on lines 12..15
          src/database/schemas/DBUserSchema.ts on lines 159..161

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

          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

              public static getModel():
                      Mongoose.Model<InstanceType<DBGlobalPropertySchema>> & DBGlobalPropertySchema & typeof DBGlobalPropertySchema {
                  return new DBGlobalPropertySchema().getModelForClass(DBGlobalPropertySchema);
              }
          Severity: Major
          Found in src/database/schemas/DBGlobalPropertySchema.ts and 3 other locations - About 50 mins to fix
          src/database/schemas/DBBradPropertySchema.ts on lines 79..81
          src/database/schemas/DBGuildPropertySchema.ts on lines 145..147
          src/database/schemas/DBUserSchema.ts on lines 159..161

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

          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

              public static getModel(): Mongoose.Model<InstanceType<DBUserSchema>> & DBUserSchema & typeof DBUserSchema {
                  return new DBUserSchema().getModelForClass(DBUserSchema);
              }
          Severity: Major
          Found in src/database/schemas/DBUserSchema.ts and 3 other locations - About 50 mins to fix
          src/database/schemas/DBBradPropertySchema.ts on lines 79..81
          src/database/schemas/DBGlobalPropertySchema.ts on lines 12..15
          src/database/schemas/DBGuildPropertySchema.ts on lines 145..147

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

          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