aXises/fortniteBot

View on GitHub

Showing 31 of 70 total issues

Function triggerAction has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public async triggerAction(userId: string, msg: OnMessageState): Promise<void> {
        for (const pair of this.commandRegistry.getRegistryMap().entries()) {
            if (pair[1] instanceof TriggerableCommand) {
                const command: TriggerableCommand = pair[1] as TriggerableCommand;
                if (await command.tryTrigger(msg)) {
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

      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

          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

              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

                    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

                    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

                      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

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

                          public async loadItems(): Promise<void> {
                              const importPaths: string[] = this.getImportPaths();
                              this.logger.info(`Detected ${importPaths.length}` +
                                      ` ${importPaths.length === 1 ? "item" : "items"} for import.`);
                              for (const path of importPaths) {
                      Severity: Minor
                      Found in src/managers/ObjectManager.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

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

                          public addCommand(command: AbstractCommand): boolean {
                              const name: string = command.getCommandString();
                              if (command instanceof TriggerableCommand) {
                                  if (this.registry.has(command.constructor.name)) {
                                      this.logger.warn(`Duplicate command "${command.constructor.name}".`);
                      Severity: Minor
                      Found in src/registries/CommandRegistry.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

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

                          public async loadCommands(): Promise<void> {
                              const importPaths: string[] = this.getImportPaths();
                              this.logger.info(`Detected ${importPaths.length}` +
                                      ` ${importPaths.length === 1 ? "command" : "commands"} for import.`);
                              for (const path of importPaths) {
                      Severity: Minor
                      Found in src/managers/CommandManager.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

                      Severity
                      Category
                      Status
                      Source
                      Language