feat: dojo research #689
@ -34,11 +34,17 @@ export const guildTechController: RequestHandler = async (req, res) => {
|
|||||||
|
|||||||
} else if (data.Action == "Contribute") {
|
} else if (data.Action == "Contribute") {
|
||||||
const contributions = data as IGuildTechContributeFields;
|
const contributions = data as IGuildTechContributeFields;
|
||||||
const techProject = guild.TechProjects!.find(x => x.ItemType == contributions.RecipeType)!;
|
const techProject = guild.TechProjects!.find(x => x.ItemType == contributions.RecipeType)!;
|
||||||
|
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;
|
techProject.ReqCredits -= contributions.RegularCredits;
|
||||||
const miscItemChanges = [];
|
const miscItemChanges = [];
|
||||||
for (const miscItem of contributions.MiscItems) {
|
for (const miscItem of contributions.MiscItems) {
|
||||||
const reqItem = techProject.ReqItems.find(x => x.ItemType == miscItem.ItemType);
|
const reqItem = techProject.ReqItems.find(x => x.ItemType == miscItem.ItemType);
|
||||||
if (reqItem) {
|
if (reqItem) {
|
||||||
|
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;
|
reqItem.ItemCount -= miscItem.ItemCount;
|
||||||
miscItemChanges.push({
|
miscItemChanges.push({
|
||||||
ItemType: miscItem.ItemType,
|
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 -->
![]() 🛠️ 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.
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