Expose built-in rules in Ruby - #1008
Conversation
65d7c1e to
fd06555
Compare
567f063 to
bf902d7
Compare
bf902d7 to
f3185b1
Compare
| rb_ary_push(definitions, rule); | ||
| } | ||
|
|
||
| rdx_rule_definitions_free(definition_array); |
There was a problem hiding this comment.
I think we need to add an rb_ensure here to free the array when the above code raises exceptions.
There was a problem hiding this comment.
Similar to the other comment, this runs upon requiring Rubydex. If this code raises, then it's a bug we have to fix internally and don't want to swallow. There's no way for a consumer of Rubydex to make this code raise.
There was a problem hiding this comment.
It's not to swallow the exception tho. It's so that we can still free the definition_array in that case.
I know it's not likely to happen but I think so far we always make sure free's called properly in all scenarios.
There was a problem hiding this comment.
Yes, but in this case, we're not protecting ourselves from external code that might be incorrect. We'd be protecting ourselves against our own code, but we can ensure that is never raising on our side.
Fourth step towards #1000
This PR makes sure we automatically create
RuleDefinitionclasses for all built-in diagnostics. This allows us to treat rule definitions consistently between the linter and the graph, since they are all just classes that inherit fromRuleDefinition.The idea is basically to have an
allmethod in Rust that returns all rules and we use the names to create classes likeclass ParseError < RuleDefinition, which registers the identity of that rule in the Ruby side consistently with linting rules.