Showing AI reviews for bet-service
Project AI Score ?
62%
Quality Avg ?
63%
Security Avg ?
59%
Reviews ?
92

Review Result ?

solutionbowl/bet-service · ce9bfd61
The commit introduces normalization of bet fancy types and uses these normalized types in market exposure logic, improving consistency and functionality around betting on fancy markets such as Jodi and Trio bets. The code refactor centralizes fancy type management and enhances the handling of selected runner IDs. The commit message is unclear and does not describe the changes adequately.
Quality ?
75%
Security ?
50%
Business Value ?
70%
Maintainability ?
73%
Issues & Suggested Fixes ?
1AI detects the issue
2Shows file, line, or evidence
3Suggests the fix to apply
Unclear And Uninformative
Where commit message
Issue / Evidence unclear and uninformative
Suggested Fix provide a clear, descriptive commit message summarizing the change purpose and impact
Magic Strings Used For Fancy Win Exposure...
Where src/controllers/bet.controller.js:13
Issue / Evidence magic strings used for fancy win exposure types
Suggested Fix consider moving these to a constants file or documenting them thoroughly
Normalization Function Has Ad Hoc Mappings...
Where src/controllers/bet.controller.js:21
Issue / Evidence normalization function has ad-hoc mappings for fancy types
Suggested Fix add unit tests for normalizeFancyType to catch edge cases and future regressions
Long Function
Where src/controllers/bet.controller.js:58
Issue / Evidence complex conditional logic on selected runner IDs and selection name
Suggested Fix add inline comments and/or refactor into smaller functions for clarity
Nested Ternary Operations To Determine Sel...
Where src/controllers/bet.controller.js:413
Issue / Evidence nested ternary operations to determine selectedRunnerIds
Suggested Fix refactor for readability and maintainability
Normalizefancytype Handles String Inputs
Where src/controllers/bet.controller.js:53
Issue / Evidence normalizeFancyType handles string inputs
Suggested Fix validate input types explicitly to avoid unexpected bugs
Usage Of Sets And Strings
Where src/controllers/bet.controller.js:85
Issue / Evidence usage of Sets and strings
Suggested Fix ensure consistent type usage across the codebase to avoid comparison issues
Missing Validation
Where src/controllers/bet.controller.js
Issue / Evidence consider adding error handling or validation when passed market objects lack expected properties, reducing bug risks
Suggested Fix Review and simplify this section.
Code Change Preview · src/controllers/bet.controller.js ?
Removed / Before Commit
- diff --git a/src/controllers/bet.controller.js b/src/controllers/bet.controller.js
- index ec5ce0a..59abf1e 100644
- const HorseRace = require("../models/HorseRace");
- const { getHierarchyIds } = require("../services/hierarchyService");
- 
- const isPhotoFancyMarket = (market = {}) =>
- String(market.marketType || "").toUpperCase() === "FANCY" &&
-   String(market.fancy_type || "").toUpperCase() === "PHOTO";
- 
- const getMarketRunnerId = (runner = {}) =>
- String(runner.runnerId || runner.runner?.runnerId || runner._id || "");
- debitAmount,
- odds_type,
- runnerId,
- fancyType,
- }) => {
-   if (!runnerId) {
- return;
Added / After Commit
+ diff --git a/src/controllers/bet.controller.js b/src/controllers/bet.controller.js
+ index ec5ce0a..59abf1e 100644
+ const HorseRace = require("../models/HorseRace");
+ const { getHierarchyIds } = require("../services/hierarchyService");
+ 
+ const FANCY_WIN_EXPOSURE_TYPES = new Set([
+   "PHOTO",
+   "JODI OF",
+   "TRIO OF",
+   "COMBO OF",
+   "SUPER COMBO OF",
+ ]);
+ 
+ const normalizeFancyType = (type) => {
+   const normalized = String(type || "").trim().toUpperCase();
+   if (normalized === "JODI") return "JODI OF";
+   if (normalized === "TRIO") return "TRIO OF";
+   if (normalized === "COMBO") return "COMBO OF";