fixes invalid rule from hyphen (#11484)

## Summary

When using `add_rule.py`, it produces the following line in `codes.rs`
```
        (Flake8Async, "102") => (RuleGroup::Stable, rules::flake8-async::rules::BlockingOsCallInAsyncFunction),
```

Causing a syntax error.

This PR resolves that issue so that the script can be used again.

## Test Plan

Tested manually in new rule creation
This commit is contained in:
Evan Kohilas 2024-05-22 13:39:50 +10:00 committed by GitHub
parent 8848eca3c6
commit 3476e2f359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -137,7 +137,8 @@ pub(crate) fn {rule_name_snake}(checker: &mut Checker) {{}}
lines.append(line)
variant = pascal_case(linter)
rule = f"""rules::{linter.split(" ")[0]}::rules::{name}"""
linter_name = linter.split(" ")[0].replace("-", "_")
rule = f"""rules::{linter_name}::rules::{name}"""
lines.append(
" " * 8 + f"""({variant}, "{code}") => (RuleGroup::Preview, {rule}),\n""",
)