feat: rerolling rivens #806
@ -41,7 +41,7 @@ export const rerollRandomModController: RequestHandler = async (req, res) => {
|
|||||||
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
|
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
|
||||||
if (request.CommitReroll) {
|
if (request.CommitReroll && upgrade.PendingRerollFingerprint) {
|
||||||
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Similar to the previous case, the code uses the null assertion operator Apply this diff to add null checks:
📝 Committable suggestion
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Similar to the previous case, the code uses the null assertion operator `!` without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
if (!upgrade) {
return res.status(404).json({ error: "Upgrade not found in inventory." });
}
if (request.CommitReroll) {
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting curses. Similarly, if none of the Apply this diff to check for curseable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting curses.**
Similarly, if none of the `meta.upgradeEntries` have `canBeCurse` set to `true`, the `while` loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.
Apply this diff to check for curseable entries:
```diff
+ const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
+ if (curseableEntries.length === 0) {
+ // It's acceptable for an upgrade to have no curses
+ break;
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(curseableEntries);
- while (!entry.canBeCurse) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
if (curseableEntries.length === 0) {
// It's acceptable for an upgrade to have no curses
break;
}
let entry = getRandomElement(curseableEntries);
fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting buffs. If none of the Apply this diff to check for buffable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting buffs.**
If none of the `meta.upgradeEntries` have `canBeBuff` set to `true`, the `while` loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.
Apply this diff to check for buffable entries:
```diff
+ const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
+ if (buffableEntries.length === 0) {
+ throw new Error("No available buffs for this upgrade type.");
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(buffableEntries);
- while (!entry.canBeBuff) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
if (buffableEntries.length === 0) {
throw new Error("No available buffs for this upgrade type.");
}
let entry = getRandomElement(buffableEntries);
fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
}
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Currently, the code uses the null assertion operator Apply this diff to add null checks:
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Currently, the code uses the null assertion operator `!` when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0])!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0]);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Similar to the previous case, the code uses the null assertion operator Apply this diff to add null checks:
📝 Committable suggestion
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Similar to the previous case, the code uses the null assertion operator `!` without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
if (!upgrade) {
return res.status(404).json({ error: "Upgrade not found in inventory." });
}
if (request.CommitReroll) {
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting curses. Similarly, if none of the Apply this diff to check for curseable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting curses.**
Similarly, if none of the `meta.upgradeEntries` have `canBeCurse` set to `true`, the `while` loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.
Apply this diff to check for curseable entries:
```diff
+ const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
+ if (curseableEntries.length === 0) {
+ // It's acceptable for an upgrade to have no curses
+ break;
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(curseableEntries);
- while (!entry.canBeCurse) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
if (curseableEntries.length === 0) {
// It's acceptable for an upgrade to have no curses
break;
}
let entry = getRandomElement(curseableEntries);
fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting buffs. If none of the Apply this diff to check for buffable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting buffs.**
If none of the `meta.upgradeEntries` have `canBeBuff` set to `true`, the `while` loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.
Apply this diff to check for buffable entries:
```diff
+ const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
+ if (buffableEntries.length === 0) {
+ throw new Error("No available buffs for this upgrade type.");
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(buffableEntries);
- while (!entry.canBeBuff) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
if (buffableEntries.length === 0) {
throw new Error("No available buffs for this upgrade type.");
}
let entry = getRandomElement(buffableEntries);
fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
}
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Currently, the code uses the null assertion operator Apply this diff to add null checks:
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Currently, the code uses the null assertion operator `!` when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0])!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0]);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
|
|||||||
upgrade.UpgradeFingerprint = upgrade.PendingRerollFingerprint;
|
upgrade.UpgradeFingerprint = upgrade.PendingRerollFingerprint;
|
||||||
}
|
}
|
||||||
upgrade.PendingRerollFingerprint = undefined;
|
upgrade.PendingRerollFingerprint = undefined;
|
||||||
|
|||||||
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Similar to the previous case, the code uses the null assertion operator Apply this diff to add null checks:
📝 Committable suggestion
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Similar to the previous case, the code uses the null assertion operator `!` without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
if (!upgrade) {
return res.status(404).json({ error: "Upgrade not found in inventory." });
}
if (request.CommitReroll) {
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting curses. Similarly, if none of the Apply this diff to check for curseable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting curses.**
Similarly, if none of the `meta.upgradeEntries` have `canBeCurse` set to `true`, the `while` loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.
Apply this diff to check for curseable entries:
```diff
+ const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
+ if (curseableEntries.length === 0) {
+ // It's acceptable for an upgrade to have no curses
+ break;
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(curseableEntries);
- while (!entry.canBeCurse) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
if (curseableEntries.length === 0) {
// It's acceptable for an upgrade to have no curses
break;
}
let entry = getRandomElement(curseableEntries);
fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting buffs. If none of the Apply this diff to check for buffable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting buffs.**
If none of the `meta.upgradeEntries` have `canBeBuff` set to `true`, the `while` loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.
Apply this diff to check for buffable entries:
```diff
+ const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
+ if (buffableEntries.length === 0) {
+ throw new Error("No available buffs for this upgrade type.");
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(buffableEntries);
- while (!entry.canBeBuff) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
if (buffableEntries.length === 0) {
throw new Error("No available buffs for this upgrade type.");
}
let entry = getRandomElement(buffableEntries);
fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
}
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Currently, the code uses the null assertion operator Apply this diff to add null checks:
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Currently, the code uses the null assertion operator `!` when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0])!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0]);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Similar to the previous case, the code uses the null assertion operator Apply this diff to add null checks:
📝 Committable suggestion
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Similar to the previous case, the code uses the null assertion operator `!` without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId)!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemId);
if (!upgrade) {
return res.status(404).json({ error: "Upgrade not found in inventory." });
}
if (request.CommitReroll) {
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting curses. Similarly, if none of the Apply this diff to check for curseable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting curses.**
Similarly, if none of the `meta.upgradeEntries` have `canBeCurse` set to `true`, the `while` loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.
Apply this diff to check for curseable entries:
```diff
+ const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
+ if (curseableEntries.length === 0) {
+ // It's acceptable for an upgrade to have no curses
+ break;
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(curseableEntries);
- while (!entry.canBeCurse) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const curseableEntries = meta.upgradeEntries!.filter(entry => entry.canBeCurse);
if (curseableEntries.length === 0) {
// It's acceptable for an upgrade to have no curses
break;
}
let entry = getRandomElement(curseableEntries);
fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Prevent potential infinite loops when selecting buffs. If none of the Apply this diff to check for buffable entries:
📝 Committable suggestion
_:warning: Potential issue_
**Prevent potential infinite loops when selecting buffs.**
If none of the `meta.upgradeEntries` have `canBeBuff` set to `true`, the `while` loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.
Apply this diff to check for buffable entries:
```diff
+ const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
+ if (buffableEntries.length === 0) {
+ throw new Error("No available buffs for this upgrade type.");
+ }
- let entry = getRandomElement(meta.upgradeEntries!);
+ let entry = getRandomElement(buffableEntries);
- while (!entry.canBeBuff) {
- entry = getRandomElement(meta.upgradeEntries!);
- }
```
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
`````suggestion
const buffableEntries = meta.upgradeEntries!.filter(entry => entry.canBeBuff);
if (buffableEntries.length === 0) {
throw new Error("No available buffs for this upgrade type.");
}
let entry = getRandomElement(buffableEntries);
fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
}
`````
</details>
<!-- suggestion_end -->
<!-- This is an auto-generated comment by CodeRabbit -->
![]() ⚠️ Potential issue Handle potential null references when accessing inventory upgrades. Currently, the code uses the null assertion operator Apply this diff to add null checks:
_:warning: Potential issue_
**Handle potential null references when accessing inventory upgrades.**
Currently, the code uses the null assertion operator `!` when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.
Apply this diff to add null checks:
```diff
- const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0])!;
+ const upgrade = inventory.Upgrades.find(x => x._id?.toString() == request.ItemIds[0]);
+ if (!upgrade) {
+ return res.status(404).json({ error: "Upgrade not found in inventory." });
+ }
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
|
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Similar to the previous case, the code uses the null assertion operator
!
without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.Apply this diff to add null checks:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting curses.
Similarly, if none of the
meta.upgradeEntries
havecanBeCurse
set totrue
, thewhile
loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.Apply this diff to check for curseable entries:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting buffs.
If none of the
meta.upgradeEntries
havecanBeBuff
set totrue
, thewhile
loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.Apply this diff to check for buffable entries:
📝 Committable suggestion
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Currently, the code uses the null assertion operator
!
when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.Apply this diff to add null checks:
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Similar to the previous case, the code uses the null assertion operator
!
without checking if the upgrade exists. This may lead to runtime errors if the upgrade is not found.Apply this diff to add null checks:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting curses.
Similarly, if none of the
meta.upgradeEntries
havecanBeCurse
set totrue
, thewhile
loop will result in an infinite loop. Ensure that there is at least one entry that can be a curse before entering the loop.Apply this diff to check for curseable entries:
📝 Committable suggestion
⚠️ Potential issue
Prevent potential infinite loops when selecting buffs.
If none of the
meta.upgradeEntries
havecanBeBuff
set totrue
, thewhile
loop will result in an infinite loop. To prevent this, ensure that there is at least one entry that can be a buff before entering the loop.Apply this diff to check for buffable entries:
📝 Committable suggestion
⚠️ Potential issue
Handle potential null references when accessing inventory upgrades.
Currently, the code uses the null assertion operator
!
when accessing the upgrade in the inventory without checking if it exists. If the upgrade is not found, this will cause a runtime error. It's important to add a null check to handle cases where the upgrade may not exist.Apply this diff to add null checks: