ronantakizawa/codereview-bench huggingface dataset:
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/ApplicationEmoji.js (JavaScript)

Code before:
    if (other instanceof ApplicationEmoji) {
      return (
        other.animated === this.animated &&
        other.id === this.id &&
        other.name === this.name &&
        other.managed === this.managed &&
        other.requiresColons === this.requiresColons &&
        other.available === this.available
      );
    }

    return other.id === this.id && other.name === this.name;
  }
}

/**
 * The emoji's name
 * @name name
 * @memberof ApplicationEmoji
 * @instance
 * @type {string}
 * @readonly
 */

/**
 * Whether or not the emoji is animated
 * @name animated
 * @memberof ApplicationEmoji
 * @instance
 * @type {boolean}
 * @readonly
 */

/**
 * Returns a URL for the emoji.
 * @method imageURL
 * @memberof ApplicationEmoji
 * @instance
 * @param {ImageURLOptions} [options] Options for the image URL
 * @returns {string}
 */

/**
 * Returns a URL for the emoji.
 * @name url
 * @memberof ApplicationEmoji
 * @instance
 * @type {string}
 * @readonly
 * @deprecated Use {@link ApplicationEmoji#imageURL} instead.
 */

Review comment (suggestion):
```suggestion
 * Whether the emoji is animated
```

Code after:
    if (other instanceof ApplicationEmoji) {
      return (
        other.animated === this.animated &&
        other.id === this.id &&
        other.name === this.name &&
        other.managed === this.managed &&
        other.requiresColons === this.requiresColons &&
        other.available === this.available
      );
    }

    return other.id === this.id && other.name === this.name;
  }
}

/**
 * The emoji's name
 * @name name
 * @memberof ApplicationEmoji
 * @instance
 * @type {string}
 * @readonly
 */

/**
 * Whether the emoji is animated
 * @name animated
 * @memberof ApplicationEmoji
 * @instance
 * @type {boolean}
 * @readonly
 */

/**
 * Returns a URL for the emoji.
 * @method imageURL
 * @memberof ApplicationEmoji
 * @instance
 * @param {EmojiURLOptions} [options] Options for the image URL
 * @returns {string}
 */

/**
 * The time the emoji was created at
 * @name createdAt
 * @memberof ApplicationEmoji
 * @instance
 * @type {Date}
 * @readonly
 */
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/User.js (JavaScript)

Code before:
      this.avatarDecorationData = {
        asset: data.avatar_decoration_data.asset,
        skuId: data.avatar_decoration_data.sku_id,
      };
    } else {
      this.avatarDecorationData = null;
    }

    /**
     * @typedef {Object} NameplateData
     * @property {Snowflake} skuId The id of the nameplate's SKU
     * @property {string} asset The nameplate's asset path
     * @property {string} label The nameplate's label
     * @property {NameplatePalette} palette Background color of the nameplate
     */

    /**
     * @typedef {Object} Collectibles
     * @property {NameplateData} nameplate The user's nameplate data
     */

    if (data.collectibles) {
      /**
       * The user's collectibles
       *
       * @type {Collectibles}
       */
      this.collectibles = _transformCollectibles(data.collectibles);
    } else {
      this.collectibles = null;
    }
  }

  /**
   * Whether this User is a partial
   *
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**
   * The timestamp the user was created at
   *
   * @type {number}
   * @readonly
   */
  get createdTimestamp() {
    return DiscordSnowflake.timestampFrom(this.id);

Review comment (suggestion):
```suggestion
       * @type {?Collectibles}
```

Code after:
      this.avatarDecorationData = {
        asset: data.avatar_decoration_data.asset,
        skuId: data.avatar_decoration_data.sku_id,
      };
    } else {
      this.avatarDecorationData = null;
    }

    /**
     * @typedef {Object} NameplateData
     * @property {Snowflake} skuId The id of the nameplate's SKU
     * @property {string} asset The nameplate's asset path
     * @property {string} label The nameplate's label
     * @property {NameplatePalette} palette Background color of the nameplate
     */

    /**
     * @typedef {Object} Collectibles
     * @property {?NameplateData} nameplate The user's nameplate data
     */

    if (data.collectibles) {
      /**
       * The user's collectibles
       *
       * @type {?Collectibles}
       */
      this.collectibles = _transformCollectibles(data.collectibles);
    } else {
      this.collectibles = null;
    }
  }

  /**
   * Whether this User is a partial
   *
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**
   * The timestamp the user was created at
   *
   * @type {number}
   * @readonly
   */
  get createdTimestamp() {
    return DiscordSnowflake.timestampFrom(this.id);
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/User.js (JavaScript)

Code before:

    if (data.avatar_decoration_data) {
      /**
       * The user avatar decoration's data
       *
       * @type {?AvatarDecorationData}
       */
      this.avatarDecorationData = {
        asset: data.avatar_decoration_data.asset,
        skuId: data.avatar_decoration_data.sku_id,
      };
    } else {
      this.avatarDecorationData = null;
    }

    /**
     * @typedef {Object} NameplateData
     * @property {Snowflake} skuId The id of the nameplate's SKU
     * @property {string} asset The nameplate's asset path
     * @property {string} label The nameplate's label
     * @property {NameplatePalette} palette Background color of the nameplate
     */

    /**
     * @typedef {Object} Collectibles
     * @property {NameplateData} nameplate The user's nameplate data
     */

    if (data.collectibles) {
      /**
       * The user's collectibles
       *
       * @type {Collectibles}
       */
      this.collectibles = _transformCollectibles(data.collectibles);
    } else {
      this.collectibles = null;
    }
  }

  /**
   * Whether this User is a partial
   *
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**

Review comment (suggestion):
```suggestion
     * @property {?NameplateData} nameplate The user's nameplate data
```

Code after:

    if (data.avatar_decoration_data) {
      /**
       * The user avatar decoration's data
       *
       * @type {?AvatarDecorationData}
       */
      this.avatarDecorationData = {
        asset: data.avatar_decoration_data.asset,
        skuId: data.avatar_decoration_data.sku_id,
      };
    } else {
      this.avatarDecorationData = null;
    }

    /**
     * @typedef {Object} NameplateData
     * @property {Snowflake} skuId The id of the nameplate's SKU
     * @property {string} asset The nameplate's asset path
     * @property {string} label The nameplate's label
     * @property {NameplatePalette} palette Background color of the nameplate
     */

    /**
     * @typedef {Object} Collectibles
     * @property {?NameplateData} nameplate The user's nameplate data
     */

    if (data.collectibles) {
      /**
       * The user's collectibles
       *
       * @type {?Collectibles}
       */
      this.collectibles = _transformCollectibles(data.collectibles);
    } else {
      this.collectibles = null;
    }
  }

  /**
   * Whether this User is a partial
   *
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**
Repository: discordjs/discord.js
File: packages/discord.js/typings/index.d.ts (TypeScript)

Code before:
  SoundboardSound,
}

export interface PartialUser extends Partialize<User, 'discriminator' | 'tag' | 'username'> {}

export type PresenceStatusData = ClientPresenceStatus | 'invisible';

export type PresenceStatus = PresenceStatusData | 'offline';

export interface ReactionCollectorOptions extends CollectorOptions<[MessageReaction, User]> {
  max?: number;
  maxEmojis?: number;
  maxUsers?: number;
}

export interface MessageReplyOptions extends BaseMessageCreateOptions {
  failIfNotExists?: boolean;
}

export interface ResolvedOverwriteOptions {
  allow: PermissionsBitField;
  deny: PermissionsBitField;
}

export interface RoleData {
  colors?: RoleColors;
  hoist?: boolean;
  icon?: Base64Resolvable | BufferResolvable | EmojiResolvable | null;
  mentionable?: boolean;
  name?: string;
  permissions?: PermissionResolvable;
  position?: number;
  unicodeEmoji?: string | null;
}

export type RoleMention = '@everyone' | `<@&${Snowflake}>`;

export interface RolePosition {
  position: number;
  role: RoleResolvable;
}

export type RoleResolvable = Role | Snowflake;

export interface RoleSubscriptionData {
  isRenewal: boolean;
  roleSubscriptionListingId: Snowflake;
  tierName: string;
  totalMonthsSubscribed: number;
}


Review comment (suggestion):
```suggestion
  colors?: RoleColorsResolvable;
```

Code after:
export interface PartialMessage
  extends Partialize<Message, 'pinned' | 'system' | 'tts' | 'type', 'author' | 'cleanContent' | 'content'> {}

export interface PartialMessageReaction extends Partialize<MessageReaction, 'count'> {}

export interface PartialPoll
  extends Partialize<
    Poll,
    'allowMultiselect' | 'expiresTimestamp' | 'layoutType',
    null,
    'answers' | 'message' | 'question'
  > {
  // eslint-disable-next-line no-restricted-syntax
  answers: Collection<number, PartialPollAnswer>;
  message: PartialMessage;
  question: { text: null };
}

export interface PartialPollAnswer extends Partialize<PollAnswer, 'emoji' | 'text', null, 'poll'> {
  readonly poll: PartialPoll;
}

export interface PartialGuildScheduledEvent
  extends Partialize<GuildScheduledEvent, 'userCount', 'entityType' | 'name' | 'privacyLevel' | 'status'> {}

export interface PartialThreadMember extends Partialize<ThreadMember, 'flags' | 'joinedAt' | 'joinedTimestamp'> {}

export interface PartialSoundboardSound extends Partialize<SoundboardSound, 'available' | 'name' | 'volume'> {}

export interface PartialOverwriteData {
  allow?: PermissionResolvable;
  deny?: PermissionResolvable;
  id: Snowflake | number;
  type?: OverwriteType;
}

export interface PartialRoleData extends RoleData {
  id?: Snowflake | number;
}

export enum Partials {
  User,
  Channel,
  GuildMember,
  Message,
  Reaction,
  GuildScheduledEvent,
  ThreadMember,
  Poll,
  PollAnswer,
  SoundboardSound,
Repository: discordjs/discord.js
File: packages/discord.js/src/structures/User.js (JavaScript)

Code before:
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**
   * The timestamp the user was created at
   *
   * @type {number}
   * @readonly
   */
  get createdTimestamp() {
    return DiscordSnowflake.timestampFrom(this.id);
  }

  /**
   * The time the user was created at
   *
   * @type {Date}
   * @readonly
   */
  get createdAt() {
    return new Date(this.createdTimestamp);
  }

  /**
   * A link to the user's avatar.
   *
   * @param {ImageURLOptions} [options={}] Options for the image URL
   * @returns {?string}
   */
  avatarURL(options = {}) {
    return this.avatar && this.client.rest.cdn.avatar(this.id, this.avatar, options);
  }

  /**
   * A link to the user's avatar decoration.
   *
   * @returns {?string}
   */
  avatarDecorationURL() {
    return this.avatarDecorationData ? this.client.rest.cdn.avatarDecoration(this.avatarDecorationData.asset) : null;
  }

  /**
   * A link to the user's default avatar
   *
   * @type {string}
   * @readonly

Review comment (suggestion):
 if a patch call doesn't include primary_guild this will unset it although it should remain unchanged. Same applies to avatar_decoration_data though, no idea if that was discussed for that before. Imho it should get the same treatment as banner or accent_color did, unless we got something that guarantees this behaves differently.

Code after:

    /**
     * @typedef {Object} UserPrimaryGuild
     * @property {?Snowflake} identityGuildId The id of the user's primary guild
     * @property {?boolean} identityEnabled Whether the user is displaying the primary guild's tag
     * @property {?string} tag The user's guild tag. Limited to 4 characters
     * @property {?string} badge The guild tag badge hash
     */

    if ('primary_guild' in data) {
      if (data.primary_guild) {
        /**
         * The primary guild of the user
         *
         * @type {?UserPrimaryGuild}
         */
        this.primaryGuild = {
          identityGuildId: data.primary_guild.identity_guild_id,
          identityEnabled: data.primary_guild.identity_enabled,
          tag: data.primary_guild.tag,
          badge: data.primary_guild.badge,
        };
      } else {
        this.primaryGuild = null;
      }
    } else {
      this.primaryGuild ??= null;
    }
  }

  /**
   * Whether this User is a partial
   *
   * @type {boolean}
   * @readonly
   */
  get partial() {
    return typeof this.username !== 'string';
  }

  /**
   * The timestamp the user was created at
   *
   * @type {number}
   * @readonly
   */
  get createdTimestamp() {
    return DiscordSnowflake.timestampFrom(this.id);
  }

  /**
Repository: discordjs/discord.js
File: packages/discord.js/src/client/websocket/WebSocketManager.js (JavaScript)

Code before:
    if (this.status === Status.Ready) return;
    if (this.shards.size !== this.totalShards || this.shards.some(shard => shard.status !== Status.Ready)) {
      return;
    }

    this.triggerClientReady();
  }

  /**
   * Causes the client to be marked as ready and emits the ready event.
   * @private
   */
  triggerClientReady() {
    this.status = Status.Ready;

    this.client.readyTimestamp = Date.now();

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#ready
     * @deprecated Use {@link Client#event:clientReady} instead.
     * @param {Client} client The client
     */
    if (this.client.emit('ready', this.client) && !deprecationEmitted) {
      deprecationEmitted = true;
      process.emitWarning('The ready event is deprecated. Use clientReady instead.', 'DeprecationWarning');
    }

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#clientReady
     * @param {Client} client The client
     */
    this.client.emit(Events.ClientReady, this.client);

    this.handlePacket();
  }
}

module.exports = WebSocketManager;


Review comment (suggestion):
```suggestion
      process.emitWarning('The ready event has been renamed to clientReady. Please use that instead', 'DeprecationWarning');
```

Code after:
    if (this.status === Status.Ready) return;
    if (this.shards.size !== this.totalShards || this.shards.some(shard => shard.status !== Status.Ready)) {
      return;
    }

    this.triggerClientReady();
  }

  /**
   * Causes the client to be marked as ready and emits the ready event.
   * @private
   */
  triggerClientReady() {
    this.status = Status.Ready;

    this.client.readyTimestamp = Date.now();

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#ready
     * @deprecated Use {@link Client#event:clientReady} instead.
     * @param {Client} client The client
     */
    if (this.client.emit('ready', this.client) && !deprecationEmitted) {
      deprecationEmitted = true;

      process.emitWarning(
        // eslint-disable-next-line max-len
        'The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.',
        'DeprecationWarning',
      );
    }

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#clientReady
     * @param {Client} client The client
     */
    this.client.emit(Events.ClientReady, this.client);

    this.handlePacket();
  }
}

module.exports = WebSocketManager;
Repository: discordjs/discord.js
File: packages/discord.js/src/client/websocket/WebSocketManager.js (JavaScript)

Code before:
      return;
    }

    this.triggerClientReady();
  }

  /**
   * Causes the client to be marked as ready and emits the ready event.
   * @private
   */
  triggerClientReady() {
    this.status = Status.Ready;

    this.client.readyTimestamp = Date.now();

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#ready
     * @deprecated Use {@link Client#event:clientReady} instead.
     * @param {Client} client The client
     */
    if (this.client.emit('ready', this.client) && !deprecationEmitted) {
      deprecationEmitted = true;

      process.emitWarning(
        'The ready event has been renamed to clientReady. Please use that instead',
        'DeprecationWarning',
      );
    }

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#clientReady
     * @param {Client} client The client
     */
    this.client.emit(Events.ClientReady, this.client);

    this.handlePacket();
  }
}

module.exports = WebSocketManager;


Review comment (suggestion):
```suggestion
        'The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.',
```
mostly to reduce the outrage this might cause in a minor (not really a patch is it?) release 

Code after:
      return;
    }

    this.triggerClientReady();
  }

  /**
   * Causes the client to be marked as ready and emits the ready event.
   * @private
   */
  triggerClientReady() {
    this.status = Status.Ready;

    this.client.readyTimestamp = Date.now();

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#ready
     * @deprecated Use {@link Client#event:clientReady} instead.
     * @param {Client} client The client
     */
    if (this.client.emit('ready', this.client) && !deprecationEmitted) {
      deprecationEmitted = true;

      process.emitWarning(
        // eslint-disable-next-line max-len
        'The ready event has been renamed to clientReady to distinguish it from the gateway READY event and will only emit under that name in v15. Please use clientReady instead.',
        'DeprecationWarning',
      );
    }

    /**
     * Emitted when the client becomes ready to start working.
     * @event Client#clientReady
     * @param {Client} client The client
     */
    this.client.emit(Events.ClientReady, this.client);

    this.handlePacket();
  }
}

module.exports = WebSocketManager;
Repository: discordjs/discord.js
File: packages/discord.js/typings/index.d.ts (TypeScript)

Code before:
  message: MessageResolvable;
}

export interface FetchMessagesOptions {
  after?: Snowflake;
  around?: Snowflake;
  before?: Snowflake;
  cache?: boolean;
  limit?: number;
}

export interface FetchPinnedMessagesOptions {
  before?: DateResolvable;
  limit?: number;
}

export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
  hasMore: boolean;
  items: readonly MessagePin<InGuild>[];
}

export interface MessagePin<InGuild extends boolean = boolean> {
  message: Message<InGuild>;
  pinnedAt: Date;
  pinnedTimestamp: number;
}

export interface FetchReactionUsersOptions {
  after?: Snowflake;
  limit?: number;
  type?: ReactionType;
}

export interface FetchThreadMemberOptions extends BaseFetchOptions {
  member: ThreadMemberResolvable;
  withMember?: boolean;
}

export interface FetchThreadOwnerOptions extends BaseFetchOptions {
  withMember?: boolean;
}

export interface FetchThreadMembersWithGuildMemberDataOptions {
  after?: Snowflake;
  cache?: boolean;
  limit?: number;
  withMember: true;
}

export interface FetchThreadMembersWithoutGuildMemberDataOptions {
  cache?: boolean;

Review comment (performance):
```suggestion
  before?: DateResolvable;
  cache?: boolean;
```

Code after:
  user: UserResolvable;
}

export interface FetchMembersOptions {
  limit?: number;
  nonce?: string;
  query?: string;
  time?: number;
  user?: UserResolvable | readonly UserResolvable[];
  withPresences?: boolean;
}

export interface FetchMessageOptions extends BaseFetchOptions {
  message: MessageResolvable;
}

export interface FetchMessagesOptions {
  after?: Snowflake;
  around?: Snowflake;
  before?: Snowflake;
  cache?: boolean;
  limit?: number;
}

export interface FetchPinnedMessagesOptions {
  before?: DateResolvable;
  cache?: boolean;
  limit?: number;
}

export interface FetchPinnedMessagesResponse<InGuild extends boolean = boolean> {
  hasMore: boolean;
  items: readonly MessagePin<InGuild>[];
}

export interface MessagePin<InGuild extends boolean = boolean> {
  message: Message<InGuild>;
  get pinnedAt(): Date;
  pinnedTimestamp: number;
}

export interface FetchReactionUsersOptions {
  after?: Snowflake;
  limit?: number;
  type?: ReactionType;
}

export interface FetchThreadMemberOptions extends BaseFetchOptions {
  member: ThreadMemberResolvable;
  withMember?: boolean;
}
Repository: discordjs/discord.js
File: packages/brokers/src/brokers/redis/BaseRedis.ts (TypeScript)

Code before:
	blockTimeout?: number;

	/**
	 * Consumer group name to use for this broker
	 *
	 * @see {@link https://redis.io/commands/xreadgroup/}
	 */
	group: string;

	/**
	 * Max number of messages to poll at once
	 */
	maxChunk?: number;

	/**
	 * Unique consumer name.
	 *
	 * @see {@link https://redis.io/commands/xreadgroup/}
	 */
	name?: string;
}

/**
 * Default broker options for redis
 */
export const DefaultRedisBrokerOptions = {
	...DefaultBrokerOptions,
	name: randomBytes(20).toString('hex'),
	maxChunk: 10,
	blockTimeout: 5_000,
} as const satisfies Required<Omit<RedisBrokerOptions, 'group'>>;

/**
 * Helper class with shared Redis logic
 */
export abstract class BaseRedisBroker<
		TEvents extends Record<string, any[]>,
		TResponses extends Record<keyof TEvents, any> | undefined = undefined,
	>
	extends AsyncEventEmitter<ToEventMap<TEvents, TResponses>>
	implements IBaseBroker<TEvents>
{
	/**
	 * Used for Redis queues, see the 3rd argument taken by {@link https://redis.io/commands/xadd | xadd}
	 */
	public static readonly STREAM_DATA_KEY = 'data' as const;

	/**
	 * Options this broker is using
	 */
	protected readonly options: Required<RedisBrokerOptions>;

Review comment (suggestion):
From a docs perspective it would be better to have name and group be in their own interface and have the options interfaces extend both interfaces and have another interface only extending the one contained in these defaults. Omit is always bad for docs. Apart from that this LGTM

Code after:
	/**
	 * Consumer group name to use for this broker
	 *
	 * @see {@link https://redis.io/commands/xreadgroup/}
	 */
	group: string;
	/**
	 * Max number of messages to poll at once
	 */
	maxChunk?: number;
	/**
	 * Unique consumer name.
	 *
	 * @see {@link https://redis.io/commands/xreadgroup/}
	 */
	name: string;
}

/**
 * Default broker options for redis
 */
export const DefaultRedisBrokerOptions = {
	...DefaultBrokerOptions,
	maxChunk: 10,
	blockTimeout: 5_000,
} as const satisfies Required<Omit<RedisBrokerOptions, 'group' | 'name'>>;

/**
 * Helper class with shared Redis logic
 */
export abstract class BaseRedisBroker<
		TEvents extends Record<string, any[]>,
		TResponses extends Record<keyof TEvents, any> | undefined = undefined,
	>
	extends AsyncEventEmitter<ToEventMap<TEvents, TResponses>>
	implements IBaseBroker<TEvents>
{
	/**
	 * Used for Redis queues, see the 3rd argument taken by {@link https://redis.io/commands/xadd | xadd}
	 */
	public static readonly STREAM_DATA_KEY = 'data' as const;

	/**
	 * Options this broker is using
	 */
	protected readonly options: Required<RedisBrokerOptions>;

	/**
	 * Events this broker has subscribed to
	 */
	protected readonly subscribedEvents = new Set<string>();