While packet creating Threshold values and score values are giving same, continue button is not enable in biometric page#628
Conversation
…t button should not enabled Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com> # Conflicts: # lib/ui/settings/widgets/global_config_settings_tab.dart
…me, continue button is not enable in biometric page Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
WalkthroughTwo files modified: biometric validation logic in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Rakshithasai123 <rakshithasai2002@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/ui/process_ui/generic_process.dart(2 hunks)lib/ui/settings/widgets/global_config_settings_tab.dart(2 hunks)
🔇 Additional comments (1)
lib/ui/settings/widgets/global_config_settings_tab.dart (1)
31-31: Formatting changes only—no functional impact.These whitespace additions don't affect behavior or maintainability.
Also applies to: 177-177, 180-180
| List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? []; | ||
| if (list.isNotEmpty) { | ||
| BiometricAttributeData lastCapture = list.last; | ||
| if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) { | ||
| isValid = false; | ||
| break; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Add error handling for threshold parsing.
int.parse() will throw a FormatException if thresholdPercentage is not a valid integer string or if it's null. This can crash the validation flow.
🔎 Apply this diff to add safe parsing with error handling:
if (globalProvider.isValidBiometricCapture) {
List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? [];
if (list.isNotEmpty) {
BiometricAttributeData lastCapture = list.last;
- if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) {
+ int? threshold = int.tryParse(lastCapture.thresholdPercentage);
+ if (threshold != null && lastCapture.qualityPercentage < threshold) {
isValid = false;
break;
}
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? []; | |
| if (list.isNotEmpty) { | |
| BiometricAttributeData lastCapture = list.last; | |
| if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) { | |
| isValid = false; | |
| break; | |
| } | |
| } | |
| } | |
| List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? []; | |
| if (list.isNotEmpty) { | |
| BiometricAttributeData lastCapture = list.last; | |
| int? threshold = int.tryParse(lastCapture.thresholdPercentage); | |
| if (threshold != null && lastCapture.qualityPercentage < threshold) { | |
| isValid = false; | |
| break; | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In lib/ui/process_ui/generic_process.dart around lines 526 to 534, the code uses
int.parse(lastCapture.thresholdPercentage) which can throw FormatException or
NPE if thresholdPercentage is null; change this to use safe parsing (int? parsed
= int.tryParse(lastCapture.thresholdPercentage ?? '');) and handle the
null/failed-parse case by treating the capture as invalid (set isValid = false;
break) and optionally log or record the malformed threshold for diagnostics;
ensure no exceptions propagate from parsing so the validation flow continues
safely.
| List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? []; | ||
| if (list.isNotEmpty) { | ||
| BiometricAttributeData lastCapture = list.last; | ||
| if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) { | ||
| isValid = false; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
Extract duplicated validation logic into a helper method.
This quality validation block is identical to the one at lines 526-534. Duplicate logic increases maintenance burden and bug risk.
🔎 View suggested refactor to eliminate duplication:
Add this helper method to the class:
bool _isLastCaptureQualityValid(String fieldId) {
List<BiometricAttributeData> list = globalProvider.fieldInputValue[fieldId] ?? [];
if (list.isEmpty) return true;
BiometricAttributeData lastCapture = list.last;
int? threshold = int.tryParse(lastCapture.thresholdPercentage);
if (threshold == null) return true; // or false, depending on policy
return lastCapture.qualityPercentage >= threshold;
}Then replace both occurrences with:
if (globalProvider.isValidBiometricCapture) {
- List<BiometricAttributeData> list = globalProvider.fieldInputValue[field.id!] ?? [];
- if (list.isNotEmpty) {
- BiometricAttributeData lastCapture = list.last;
- if (lastCapture.qualityPercentage < int.parse(lastCapture.thresholdPercentage)) {
- isValid = false;
- break;
- }
- }
+ if (!_isLastCaptureQualityValid(field.id!)) {
+ isValid = false;
+ break;
+ }
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In lib/ui/process_ui/generic_process.dart around lines 526-534 and 575-584 there
is duplicated last-capture quality validation; extract that logic into a private
helper on the class (e.g. _isLastCaptureQualityValid) that takes the fieldId,
fetches the list from globalProvider.fieldInputValue[fieldId] using a default
empty list, returns true if empty, safely parses threshold with int.tryParse and
returns true on parse failure (or adjust to project policy), and compares
lastCapture.qualityPercentage >= threshold; then replace both duplicated blocks
with a single call to this helper.
RCF-1268
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.