feat: trade fish for standing #681

Merged
Sainan merged 2 commits from fish-standing into main 2025-01-02 15:10:18 -08:00
Showing only changes of commit 99f01958db - Show all commits

View File

@ -18,14 +18,14 @@ export const fishmongerController: RequestHandler = async (req, res) => {
for (const part of fishData.dissectionParts!) {
const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
if (partItem) {
partItem.ItemCount += part.ItemCount;
partItem.ItemCount += part.ItemCount * fish.ItemCount;
} else {
miscItemChanges.push(part);
miscItemChanges.push({ ItemType: part.ItemType, ItemCount: part.ItemCount * fish.ItemCount });
}
}
coderabbitai[bot] commented 2025-01-01 21:54:43 -08:00 (Migrated from github.com)
Review

💡 Codebase verification

Based on the code analysis, I can now provide a final response:

Validation needed for fishData access

The code immediately uses fishData.dissectionParts without checking if fishData exists, which could cause runtime errors. The validation is particularly important because:

  1. ExportResources is accessed with a dynamic key fish.ItemType
  2. The value is immediately used to access dissectionParts property
  3. Other services like purchaseService and inventoryService implement existence checks with in operator before accessing ExportResources
  • src/controllers/api/fishmongerController.ts:16: Add null check before accessing fishData
🔗 Analysis chain

Verify existence of fishData
Accessing ExportResources[fish.ItemType] without any check can cause errors if fish.ItemType is missing from the export or is undefined. Consider adding a validation step or fallback logic.

+ if (!fishData) {
+   throw new Error(\`Missing fish data for type: \${fish.ItemType}\`);
+ }

Let me gather information about the ExportResources and its usage to verify this concern.


Let me analyze the usage of ExportResources to understand if we need validation. I'll search for its usage patterns and error handling.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Find the definition and structure of ExportResources
ast-grep --pattern 'const ExportResources = $_'

# Also search for any type definitions or interfaces related to it
rg "ExportResources" -A 5 -B 5

# Look for ItemType usage in the codebase
rg "ItemType" -A 2 -B 2

Length of output: 87233


Script:

#!/bin/bash
# Look for ExportResources usage patterns and error handling
ast-grep --pattern 'ExportResources[$_]'

# Look for any error handling around ExportResources
rg "ExportResources.*\{" -A 3 -B 3

# Look for the specific fishmonger controller implementation
rg -A 10 -B 10 "fishmongerController"

Length of output: 11028

_:bulb: Codebase verification_ Based on the code analysis, I can now provide a final response: **Validation needed for `fishData` access** The code immediately uses `fishData.dissectionParts` without checking if `fishData` exists, which could cause runtime errors. The validation is particularly important because: 1. `ExportResources` is accessed with a dynamic key `fish.ItemType` 2. The value is immediately used to access `dissectionParts` property 3. Other services like `purchaseService` and `inventoryService` implement existence checks with `in` operator before accessing `ExportResources` - `src/controllers/api/fishmongerController.ts:16`: Add null check before accessing `fishData` <details> <summary>🔗 Analysis chain</summary> **Verify existence of `fishData`** Accessing `ExportResources[fish.ItemType]` without any check can cause errors if `fish.ItemType` is missing from the export or is undefined. Consider adding a validation step or fallback logic. ```diff + if (!fishData) { + throw new Error(\`Missing fish data for type: \${fish.ItemType}\`); + } ``` --- Let me gather information about the `ExportResources` and its usage to verify this concern. --- Let me analyze the usage of `ExportResources` to understand if we need validation. I'll search for its usage patterns and error handling. </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Error: No shell scripts found --- Script: ```shell #!/bin/bash # Find the definition and structure of ExportResources ast-grep --pattern 'const ExportResources = $_' # Also search for any type definitions or interfaces related to it rg "ExportResources" -A 5 -B 5 # Look for ItemType usage in the codebase rg "ItemType" -A 2 -B 2 ``` Length of output: 87233 --- Script: ```shell #!/bin/bash # Look for ExportResources usage patterns and error handling ast-grep --pattern 'ExportResources[$_]' # Look for any error handling around ExportResources rg "ExportResources.*\{" -A 3 -B 3 # Look for the specific fishmonger controller implementation rg -A 10 -B 10 "fishmongerController" ``` Length of output: 11028 </details> <!-- This is an auto-generated comment by CodeRabbit -->
} else {
syndicateTag = fishData.syndicateTag!;
standingChange += fishData.standingBonus!;
standingChange += fishData.standingBonus! * fish.ItemCount;
}
miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
}