v0.1.0-pre.012
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_rust_general_rules.py
|
||||
# version: 5
|
||||
# version: 6
|
||||
|
||||
"""Audit mechanically verifiable Rust rules shared by all Rust projects."""
|
||||
|
||||
@@ -96,6 +96,7 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
|
||||
violations.append(Violation("RUST016", relative, index, "re-export aliases are forbidden"))
|
||||
previous_export_line: int | None = None
|
||||
previous_export_visibility: str | None = None
|
||||
previous_export_path: str | None = None
|
||||
blank_since_export = False
|
||||
for index, line in enumerate(lines, 1):
|
||||
if not line.strip():
|
||||
@@ -119,12 +120,30 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
|
||||
"re-export block contains an empty line",
|
||||
)
|
||||
)
|
||||
export_path = line.split(" use ", 1)[1]
|
||||
if (
|
||||
previous_export_line is not None
|
||||
and previous_export_visibility == visibility
|
||||
and not blank_since_export
|
||||
and previous_export_path is not None
|
||||
and export_path < previous_export_path
|
||||
):
|
||||
violations.append(
|
||||
Violation(
|
||||
"RUST023",
|
||||
relative,
|
||||
index,
|
||||
"re-export block is not ordered alphabetically",
|
||||
)
|
||||
)
|
||||
previous_export_line = index
|
||||
previous_export_visibility = visibility
|
||||
previous_export_path = export_path
|
||||
blank_since_export = False
|
||||
continue
|
||||
previous_export_line = None
|
||||
previous_export_visibility = None
|
||||
previous_export_path = None
|
||||
blank_since_export = False
|
||||
if path.name in {"lib.rs", "main.rs"}:
|
||||
for attribute in ("#![warn(missing_docs)]", "#![deny(unreachable_pub)]", "#![forbid(unsafe_code)]"):
|
||||
|
||||
Reference in New Issue
Block a user