Closed Vladiwostok closed 7 months ago
I have a hard time understanding the logic here. Could you maybe explain a bit how you implemented this given that dmd does not store whether braces have been used or not?
Please, when you do PR try to explain a bit what the check does and how you implemented it. This makes it easier for me to review it and merge it.
mind the conflicts
This check ensures some statements (if, for, foreach, while, do, try-catch) are always written with braces. My solution is to visit Compound statements and mark their parent as having braces, since compound statements in DMD are statements having more than 1 child statement (forcing a brace block). AST node changes include:
For visiting the common statements I have created a template. For TryCatchStatement and TryFinallyStatement I have created separated visit functions because:
I've also extended the unit tests by adding test cases for passing scenarios and a test case for a try-catch-finally statement.