feat: dojo research #689
@ -3,9 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||
import { Guild } from "@/src/models/guildModel";
|
||||
import { ICreateGuildRequest } from "@/src/types/guildTypes";
|
||||
|
||||
const createGuildController: RequestHandler = async (req, res) => {
|
||||
export const createGuildController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const payload = getJSONfromString(String(req.body)) as ICreateGuildRequest;
|
||||
|
||||
@ -34,4 +33,6 @@ const createGuildController: RequestHandler = async (req, res) => {
|
||||
res.json(guild);
|
||||
};
|
||||
|
||||
export { createGuildController };
|
||||
interface ICreateGuildRequest {
|
||||
guildName: string;
|
||||
}
|
||||
|
@ -1,5 +1,100 @@
|
||||
|
||||
import { RequestHandler } from "express";
|
||||
import { getGuildForRequestEx } from "@/src/services/guildService";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
export const guildTechController: RequestHandler = (_req, res) => {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
res.status(500).end(); // This is what I got for a fresh clan.
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
export const guildTechController: RequestHandler = async (req, res) => {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const inventory = await getInventory(accountId);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const guild = await getGuildForRequestEx(req, inventory);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const data = JSON.parse(String(req.body)) as TGuildTechRequest;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (data.Action == "Sync") {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
res.json({
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
TechProjects: guild.toJSON().TechProjects
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
});
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
} else if (data.Action == "Start") {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const recipe = ExportDojoRecipes.research[data.RecipeType!];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
guild.TechProjects ??= [];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (!guild.TechProjects.find(x => x.ItemType == data.RecipeType)) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
guild.TechProjects.push({
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ItemType: data.RecipeType!,
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ReqCredits: scaleRequiredCount(recipe.price),
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ReqItems: recipe.ingredients.map(x => ({
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ItemType: x.ItemType,
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ItemCount: scaleRequiredCount(x.ItemCount)
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
})),
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
State: 0
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
});
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
await guild.save();
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
res.end();
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
} else if (data.Action == "Contribute") {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const contributions = data as IGuildTechContributeFields;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const techProject = guild.TechProjects!.find(x => x.ItemType == contributions.RecipeType)!;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (contributions.RegularCredits > techProject.ReqCredits) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
contributions.RegularCredits = techProject.ReqCredits;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
techProject.ReqCredits -= contributions.RegularCredits;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const miscItemChanges = [];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
for (const miscItem of contributions.MiscItems) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const reqItem = techProject.ReqItems.find(x => x.ItemType == miscItem.ItemType);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (reqItem) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (miscItem.ItemCount > reqItem.ItemCount) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
miscItem.ItemCount = reqItem.ItemCount;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
reqItem.ItemCount -= miscItem.ItemCount;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
miscItemChanges.push({
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ItemType: miscItem.ItemType,
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ItemCount: miscItem.ItemCount * -1
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
});
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const inventoryChanges: IInventoryChanges = {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
...updateCurrency(inventory, contributions.RegularCredits, false),
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
MiscItems: miscItemChanges
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
};
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
if (techProject.ReqCredits == 0 && !techProject.ReqItems.find(x => x.ItemCount > 0)) {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
// This research is now fully funded.
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
techProject.State = 1;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const recipe = ExportDojoRecipes.research[data.RecipeType!];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
techProject.CompletionDate = new Date(new Date().getTime() + recipe.time * 1000);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
await guild.save();
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
await inventory.save();
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
res.json({
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
InventoryChanges: inventoryChanges
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
});
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
} else {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
throw new Error(`unknown guildTech action: ${data.Action}`);
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
};
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
type TGuildTechRequest = {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
Action: string;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
} & Partial<IGuildTechStartFields> &
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
Partial<IGuildTechContributeFields>;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
interface IGuildTechStartFields {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
Mode: "Guild";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
RecipeType: string;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
interface IGuildTechContributeFields {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
ResearchId: "";
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
RecipeType: string;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
RegularCredits: number;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
MiscItems: IMiscItem[];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
VaultCredits: number;
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
VaultMiscItems: IMiscItem[];
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
}
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
const scaleRequiredCount = (count: number): number => {
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
// The recipes in the export are for Moon clans. For now we'll just assume we only have Ghost clans.
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
return Math.max(1, Math.trunc(count / 100));
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
};
|
||||
|
||||
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 🛠️ Refactor suggestion ⚠️ Potential issue "Contribute" action needs item and credit boundary checks.
_:hammer_and_wrench: Refactor suggestion_
_:warning: Potential issue_
**"Contribute" action needs item and credit boundary checks.**
The code deducts the indicated contribution from `techProject.ReqCredits` and `reqItem.ItemCount` without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clamp `ReqCredits` or `ItemCount` to a minimum of zero.
```diff
- techProject.ReqCredits -= contributions.RegularCredits;
+ techProject.ReqCredits = Math.max(
+ 0,
+ techProject.ReqCredits - contributions.RegularCredits
+ );
for (const miscItem of contributions.MiscItems) {
...
reqItem.ItemCount = Math.max(
0,
reqItem.ItemCount - miscItem.ItemCount
);
...
}
```
> Committable suggestion skipped: line range outside the PR's diff.
<!-- This is an auto-generated comment by CodeRabbit -->
![]() 💡 Codebase verification 🛠️ Refactor suggestion Recipe validation and duplicate project checks are missing Based on the code analysis, the review comment is correct. The current implementation:
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chainCheck for duplicate or invalid project requests in "Start" action.
Let me verify the concerns by checking the codebase. Let me check the ExportDojoRecipes structure and any existing validation. Let me try a different approach to check the validation and recipe structure. Let me check one more thing to verify the duplicate project handling. 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script:
Length of output: 4617 Script:
Length of output: 93 Script:
Length of output: 1234 Script:
Length of output: 390 _:bulb: Codebase verification_
_:hammer_and_wrench: Refactor suggestion_
**Recipe validation and duplicate project checks are missing**
Based on the code analysis, the review comment is correct. The current implementation:
1. Directly accesses `ExportDojoRecipes.research[data.RecipeType!]` without validating if the recipe exists
2. Has no checks to prevent duplicate projects with the same `RecipeType`
3. Uses the recipe object without null checks, which could cause runtime errors
The suggested fix in the review comment is appropriate as it addresses both issues:
- Validates recipe existence
- Prevents duplicate projects
<details>
<summary>🔗 Analysis chain</summary>
**Check for duplicate or invalid project requests in "Start" action.**
Currently, there is no validation to ensure a project of the same `RecipeType` isn't already present or that the `RecipeType` actually exists in `ExportDojoRecipes.research`. You might want to:
1. Verify the recipe is valid.
2. Ensure duplicates are either prevented or handled.
```diff
if (!recipe) {
return res.status(400).json({ error: "Unknown recipe type" });
}
+if (guild.TechProjects?.some(p => p.ItemType === data.RecipeType)) {
+ return res.status(400).json({ error: "This project already exists" });
+}
```
---
Let me verify the concerns by checking the codebase.
---
Let me check the ExportDojoRecipes structure and any existing validation.
---
Let me try a different approach to check the validation and recipe structure.
---
Let me check one more thing to verify the duplicate project handling.
</details>
<details>
<summary>🏁 Scripts executed</summary>
The following scripts were executed for the analysis:
Error: No shell scripts found
---
Script:
```shell
#!/bin/bash
# Search for recipe validation and duplicate checks in guildTechController
ast-grep --pattern 'if (data.Action == "Start") {
$$$
}'
# Also check the ExportDojoRecipes structure
rg -l "ExportDojoRecipes"
```
Length of output: 4617
---
Script:
```shell
#!/bin/bash
# Check ExportDojoRecipes structure and validation
ast-grep --pattern 'const ExportDojoRecipes = {
$$$
}'
# Check if there's any validation for RecipeType
rg "RecipeType.*validation" -A 2
```
Length of output: 93
---
Script:
```shell
#!/bin/bash
# Look for the ExportDojoRecipes definition with a more flexible pattern
rg "ExportDojoRecipes.*=" -A 5
# Check how RecipeType is used in the controller
ast-grep --pattern 'const recipe = ExportDojoRecipes.research[$_];
$$$'
```
Length of output: 1234
---
Script:
```shell
#!/bin/bash
# Check if there's any existing duplicate check for TechProjects
rg "TechProjects.*some" -A 2
# Look for any other validation related to TechProjects
rg "TechProjects.*find" -A 2
```
Length of output: 390
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
|
@ -1,5 +1,12 @@
|
||||
import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes";
|
||||
import {
|
||||
IGuildDatabase,
|
||||
IDojoComponentDatabase,
|
||||
ITechProjectDatabase,
|
||||
ITechProjectClient
|
||||
} from "@/src/types/guildTypes";
|
||||
import { model, Schema } from "mongoose";
|
||||
import { typeCountSchema } from "./inventoryModels/inventoryModel";
|
||||
import { toMongoDate } from "../helpers/inventoryHelpers";
|
||||
|
||||
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||
pf: { type: String, required: true },
|
||||
@ -10,12 +17,35 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||
CompletionTime: Date
|
||||
});
|
||||
|
||||
const techProjectSchema = new Schema<ITechProjectDatabase>(
|
||||
{
|
||||
ItemType: String,
|
||||
ReqCredits: Number,
|
||||
ReqItems: [typeCountSchema],
|
||||
State: Number,
|
||||
CompletionDate: Date
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
techProjectSchema.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_doc, obj) {
|
||||
const db = obj as ITechProjectDatabase;
|
||||
const client = obj as ITechProjectClient;
|
||||
if (db.CompletionDate) {
|
||||
client.CompletionDate = toMongoDate(db.CompletionDate);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const guildSchema = new Schema<IGuildDatabase>(
|
||||
{
|
||||
Name: { type: String, required: true },
|
||||
DojoComponents: [dojoComponentSchema],
|
||||
DojoCapacity: { type: Number, default: 100 },
|
||||
DojoEnergy: { type: Number, default: 5 }
|
||||
DojoEnergy: { type: Number, default: 5 },
|
||||
TechProjects: { type: [techProjectSchema], default: undefined }
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
|
@ -61,7 +61,7 @@ import {
|
||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
||||
import { EquipmentSelectionSchema } from "./loadoutModel";
|
||||
|
||||
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
||||
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
||||
|
||||
const focusXPSchema = new Schema<IFocusXP>(
|
||||
{
|
||||
|
@ -2,17 +2,22 @@ import { Request } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { Guild } from "@/src/models/guildModel";
|
||||
import { IInventoryDatabaseDocument } from "../types/inventoryTypes/inventoryTypes";
|
||||
|
||||
export const getGuildForRequest = async (req: Request) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
return await getGuildForRequestEx(req, inventory);
|
||||
};
|
||||
|
||||
export const getGuildForRequestEx = async (req: Request, inventory: IInventoryDatabaseDocument) => {
|
||||
const guildId = req.query.guildId as string;
|
||||
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
|
||||
throw new Error("Account is not in the guild that it has sent a request for");
|
||||
}
|
||||
const guild = await Guild.findOne({ _id: guildId });
|
||||
if (!guild) {
|
||||
throw new Error("Account thinks it is a in guild that doesn't exist");
|
||||
throw new Error("Account thinks it is in a guild that doesn't exist");
|
||||
}
|
||||
return guild;
|
||||
};
|
||||
|
@ -11,10 +11,7 @@ export interface IGuildDatabase extends IGuild {
|
||||
DojoComponents?: IDojoComponentDatabase[];
|
||||
DojoCapacity: number;
|
||||
DojoEnergy: number;
|
||||
}
|
||||
|
||||
export interface ICreateGuildRequest {
|
||||
guildName: string;
|
||||
TechProjects?: ITechProjectDatabase[];
|
||||
}
|
||||
|
||||
export interface IDojoClient {
|
||||
@ -49,3 +46,15 @@ export interface IDojoComponentDatabase
|
||||
pi?: Types.ObjectId;
|
||||
CompletionTime?: Date;
|
||||
}
|
||||
|
||||
export interface ITechProjectClient {
|
||||
ItemType: string;
|
||||
ReqCredits: number;
|
||||
ReqItems: IMiscItem[];
|
||||
State: number; // 0 = pending, 1 = complete
|
||||
CompletionDate?: IMongoDate;
|
||||
}
|
||||
|
||||
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
||||
CompletionDate?: Date;
|
||||
}
|
||||
|
@ -460,10 +460,7 @@ export interface IFlavourItem {
|
||||
ItemType: string;
|
||||
}
|
||||
|
||||
export interface IMiscItem {
|
||||
ItemCount: number;
|
||||
ItemType: string;
|
||||
}
|
||||
export type IMiscItem = ITypeCount;
|
||||
|
||||
export interface ICrewShipWeapon {
|
||||
PILOT: ICrewShipPilotWeapon;
|
||||
|
🛠️ Refactor suggestion
⚠️ Potential issue
"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from
techProject.ReqCredits
andreqItem.ItemCount
without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clampReqCredits
orItemCount
to a minimum of zero.💡 Codebase verification
🛠️ Refactor suggestion
Recipe validation and duplicate project checks are missing
Based on the code analysis, the review comment is correct. The current implementation:
ExportDojoRecipes.research[data.RecipeType!]
without validating if the recipe existsRecipeType
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chain
Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same
RecipeType
isn't already present or that theRecipeType
actually exists inExportDojoRecipes.research
. You might want to:Let me verify the concerns by checking the codebase.
Let me check the ExportDojoRecipes structure and any existing validation.
Let me try a different approach to check the validation and recipe structure.
Let me check one more thing to verify the duplicate project handling.
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 4617
Script:
Length of output: 93
Script:
Length of output: 1234
Script:
Length of output: 390
🛠️ Refactor suggestion
⚠️ Potential issue
"Contribute" action needs item and credit boundary checks.
The code deducts the indicated contribution from
techProject.ReqCredits
andreqItem.ItemCount
without validating whether the user truly has enough resources. Consider adding inventory checks to ensure negative resource values are not introduced. Additionally, watch out for potential overshoot: the code does not clampReqCredits
orItemCount
to a minimum of zero.💡 Codebase verification
🛠️ Refactor suggestion
Recipe validation and duplicate project checks are missing
Based on the code analysis, the review comment is correct. The current implementation:
ExportDojoRecipes.research[data.RecipeType!]
without validating if the recipe existsRecipeType
The suggested fix in the review comment is appropriate as it addresses both issues:
🔗 Analysis chain
Check for duplicate or invalid project requests in "Start" action.
Currently, there is no validation to ensure a project of the same
RecipeType
isn't already present or that theRecipeType
actually exists inExportDojoRecipes.research
. You might want to:Let me verify the concerns by checking the codebase.
Let me check the ExportDojoRecipes structure and any existing validation.
Let me try a different approach to check the validation and recipe structure.
Let me check one more thing to verify the duplicate project handling.
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 4617
Script:
Length of output: 93
Script:
Length of output: 1234
Script:
Length of output: 390