aXises/fortniteBot

View on GitHub

Showing 70 of 70 total issues

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

    public async loadCommands(): Promise<void> {
        const importPaths: string[] = this.getImportPaths();
        this.logger.info(`Detected ${importPaths.length}` +
                ` ${importPaths.length === 1 ? "command" : "commands"} for import.`);
        for (const path of importPaths) {
Severity: Major
Found in src/managers/CommandManager.ts and 1 other location - About 1 day to fix
src/managers/ObjectManager.ts on lines 14..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 316.

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 async loadItems(): Promise<void> {
        const importPaths: string[] = this.getImportPaths();
        this.logger.info(`Detected ${importPaths.length}` +
                ` ${importPaths.length === 1 ? "item" : "items"} for import.`);
        for (const path of importPaths) {
Severity: Major
Found in src/managers/ObjectManager.ts and 1 other location - About 1 day to fix
src/managers/CommandManager.ts on lines 28..44

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

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

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

    public setCustomAction(): Action {
        return new Action(async (state: OnMessageState): Promise<boolean> => {
            try {
                return await this.botService.sendMessage(state);
            } catch (err) {
Severity: Major
Found in src/command/modules/mrfortnite/AskResponse.ts and 1 other location - About 2 hrs to fix
src/command/modules/mrfortnite/RandomResponse.ts on lines 31..39

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

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

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

    public setCustomAction(): Action {
        return new Action(async (state: OnMessageState): Promise<boolean> => {
            try {
                return await this.botService.sendMessage(state);
            } catch (err) {
Severity: Major
Found in src/command/modules/mrfortnite/RandomResponse.ts and 1 other location - About 2 hrs to fix
src/command/modules/mrfortnite/AskResponse.ts on lines 26..34

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

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 triggerAction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public async triggerAction(userId: string, msg: OnMessageState): Promise<void> {
        for (const pair of this.commandRegistry.getRegistryMap().entries()) {
            if (pair[1] instanceof TriggerableCommand) {
                const command: TriggerableCommand = pair[1] as TriggerableCommand;
                if (await command.tryTrigger(msg)) {
Severity: Minor
Found in src/managers/CommandManager.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 getImportPaths has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected getImportPaths(): string[] {
        const filePaths: string[] = [];
        for (const modulePath of this.MODULE_PATHS) {
            let files: string[];
            try {
Severity: Minor
Found in src/managers/DynamicImportManager.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 setCustomAction has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public setCustomAction(): Action {
        return new Action(async (state: OnMessageState, args: string[]): Promise<boolean> => {
            const user = state.getHandle().author;
            try {
                if (isNaN(args[0] as any)) {
Severity: Minor
Found in src/command/modules/brad/FeedBrad.ts - About 1 hr to fix

    Function setCustomAction has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public setCustomAction(): Action {
            return new Action(async (state: OnMessageState) => {
                try {
                    const userModel = DBUserSchema.getModel();
                    const userId = state.getHandle().author.id;
    Severity: Minor
    Found in src/command/modules/interactions/Pickpocket.ts - About 1 hr to fix

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

          public disableCommand(name: string): boolean {
              if (!this.registry.has(name)) {
                  this.registry.get(name).setEnabled(false);
                  return true;
              }
      Severity: Major
      Found in src/registries/CommandRegistry.ts and 1 other location - About 1 hr to fix
      src/registries/CommandRegistry.ts on lines 71..77

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

      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 enableCommand(name: string): boolean {
              if (!this.registry.has(name)) {
                  this.registry.get(name).setEnabled(true);
                  return true;
              }
      Severity: Major
      Found in src/registries/CommandRegistry.ts and 1 other location - About 1 hr to fix
      src/registries/CommandRegistry.ts on lines 63..69

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

      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 attemptExecution has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private async attemptExecution(command: Command, args: string[], userId: string, msg: OnMessageState): Promise<void> {
              if (!this.core.getDbCore().isReady()) {
                  this.logger.warn("Please wait until database connection has resolved.");
                  return;
              }
      Severity: Minor
      Found in src/managers/CommandManager.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 setCustomAction has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public setCustomAction(): Action {
              return new Action(async (state: OnMessageState): Promise<boolean> => {
                  const message = state.getHandle();
                  const author = message.author;
                  const core = state.getCore();
      Severity: Minor
      Found in src/command/modules/util/Forward.ts - About 1 hr to fix

        Function setCustomAction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public setCustomAction(): Action {
                return new Action(async (state: OnMessageState, args: string[]): Promise<boolean> => {
                    const user = state.getHandle().author;
        
                    if (!args[0]) { // If the user doesn't specify an argument - shouldn't technically see this
        Severity: Minor
        Found in src/command/modules/user/GDPR.ts - About 1 hr to fix

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

                                  winston.format.printf((info) => {
                                      return `${moment().format()}:${info.label}:${info.level}:${info.message}`;
                                  }),
          Severity: Major
          Found in src/log/Logger.ts and 1 other location - About 1 hr to fix
          src/log/Logger.ts on lines 17..19

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

          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

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

                                  winston.format.printf((info) => {
                                      return `${moment().format()}:${info.label}:${info.level}:${info.message}`;
                                  }),
          Severity: Major
          Found in src/log/Logger.ts and 1 other location - About 1 hr to fix
          src/log/Logger.ts on lines 26..28

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

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

              public setCustomAction(): Action {
                  return new Action(async (state: OnMessageState): Promise<boolean> => {
                      const user = state.getHandle().author;
                      try {
                          const doc = await DBUserSchema.getUserById(user.id);
          Severity: Minor
          Found in src/command/modules/user/Profile.ts - About 1 hr to fix

            Function LevenshteinDistance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            export const LevenshteinDistance = (a: string, b: string): number => {
                if (a.length === 0 || b.length === 0) {
                    return a.length === 0 ? b.length : a.length;
                }
                const matrix: number[][] = MathUtil.zeros(a.length + 1, b.length + 1);
            Severity: Minor
            Found in src/math/LevenshteinDistance.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 awardUsers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private async awardUsers(state: OnMessageState, users: IdContributionPair[], DbBrad: DBBradPropertySchema): Promise<void> {
                    const channel = state.getHandle().channel;
                    const client = state.getCore().getClient();
                    const embed = new Discord.RichEmbed();
                    embed.setTitle("Brad is pleased.");
            Severity: Minor
            Found in src/command/modules/brad/FeedBrad.ts - About 1 hr to fix

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

                          } else {
                              // await dbUser.addCurrency(CoinType.DOTMA_COIN, 500);
                              embed.addField("Sixth to Tenth Place!",
                                  `Congrats to\n` +
                                  `${this.generateString(users.slice(6, 10), client)}\n` +
              Severity: Major
              Found in src/command/modules/brad/FeedBrad.ts and 1 other location - About 1 hr to fix
              src/command/modules/brad/FeedBrad.ts on lines 56..63

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

              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 (awardIndex < 5 && awardIndex > 0) {
                              // await dbUser.addCurrency(CoinType.DOTMA_COIN, 1000);
                              embed.addField("Second to Fifth Place!",
                                  `Congrats to\n` +
                                  `${this.generateString(users.slice(1, 5), client)}` +
              Severity: Major
              Found in src/command/modules/brad/FeedBrad.ts and 1 other location - About 1 hr to fix
              src/command/modules/brad/FeedBrad.ts on lines 63..70

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

              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