File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5454 "unsafe block" => /unsafe\s *\{ /
5555} . freeze
5656
57+ # These counts are not style rules. They are ratchets for patterns that tend to
58+ # grow accidental architecture surface area: shared mutable state, stringly
59+ # typed maps, unjoined background tasks, and unsafe code. If a future PR needs
60+ # more of one, bump the budget in that PR so reviewers see the tradeoff.
61+ WATCH_PATTERN_BUDGETS = {
62+ "Arc<Mutex" => 40 ,
63+ "Arc<RwLock" => 11 ,
64+ "HashMap<String, String>" => 70 ,
65+ "tokio::spawn" => 141 ,
66+ "unsafe block" => 15
67+ } . freeze
68+
5769def rust_files
5870 files = [ ]
5971 Find . find ( ROOT . join ( "crates" ) . to_s ) do |path |
@@ -103,4 +115,12 @@ def relative(path)
103115 puts " #{ name } : #{ count } "
104116end
105117
118+ WATCH_PATTERN_BUDGETS . each do |name , budget |
119+ count = pattern_counts . fetch ( name , 0 )
120+ next unless count > budget
121+
122+ warn "#{ name } : #{ count } occurrences exceeds architecture budget #{ budget } "
123+ failed = true
124+ end
125+
106126abort ( "architecture ratchets failed" ) if failed
You can’t perform that action at this time.
0 commit comments