checks: Guard float/int conversions #158
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This guards all string to float/int conversions in the analyzer inside try-except clauses, to ensure that it fails gracefully if the string fed to it is not a valid float/int.
Motivation and Context
Due to the ever-changing nature of obs logging, especially with localisation and third-party plugins, it cannot be guaranteed and future-proofed that a given search or regexp will always fetch the bit of the log that it is supposed to.
If, as a result of this, the analyzer calls
int()
orfloat()
on a string that is not a valid number, it will cause an exception and abort the whole analysis.For example, as a result of the french localisation adding an unexpected set of parentheses in the name of the replay buffer, this log fails the whole analysis when trying to fetch the amount of lagged frames.
This solves those instances by catching such exceptions, and allowing the rest of the analysis to proceed.
The
checkStreamSettings
functions haven't been modified, as they are currently not working, and #157 is already set to either modify them with an already guarded alternative, or remove them entirely.How Has This Been Tested?
Manually fed the log above to the analyzer, checked that it worked well.
Types of changes
Checklist: