Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lint/ast-grep/fixtures/bad/follow_live_vs_max_outbound.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn stale_follow_needs_room(follow_live: usize, max_outbound: usize) -> bool {
false // cap deleted - unbounded follow_live
}
4 changes: 4 additions & 0 deletions lint/ast-grep/fixtures/bad/held_bodies_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
struct HeldBodies;
impl HeldBodies {
const CAP: usize = 1024;
}
2 changes: 2 additions & 0 deletions lint/ast-grep/fixtures/bad/pending_blocks_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// should fail - cap changed from 128
const MAX_PENDING_BLOCKS: usize = 1024;
1 change: 1 addition & 0 deletions lint/ast-grep/fixtures/bad/serve_blocks_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const MAX_SERVE_BLOCKS: usize = 32;
3 changes: 3 additions & 0 deletions lint/ast-grep/fixtures/good/follow_live_vs_max_outbound.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn stale_follow_needs_room(follow_live: usize, max_outbound: usize) -> bool {
follow_live >= max_outbound.max(1)
}
4 changes: 4 additions & 0 deletions lint/ast-grep/fixtures/good/held_bodies_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
struct HeldBodies;
impl HeldBodies {
const CAP: usize = 320;
}
2 changes: 2 additions & 0 deletions lint/ast-grep/fixtures/good/pending_blocks_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// should pass - correct cap per docs/ibd-memory.md Q-54
const MAX_PENDING_BLOCKS: usize = 128;
1 change: 1 addition & 0 deletions lint/ast-grep/fixtures/good/serve_blocks_cap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const MAX_SERVE_BLOCKS: usize = 16;
9 changes: 9 additions & 0 deletions lint/ast-grep/rules/follow-live-vs-max-outbound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id: follow-live-vs-max-outbound
language: rust
severity: error
message: "stale_follow_needs_room must be follow_live >= max_outbound.max(1) - see docs/ibd-memory.md:61 Q-54"
rule:
all:
- pattern: "fn stale_follow_needs_room($$$) -> bool { $$$ }"
- not:
pattern: "fn stale_follow_needs_room($$$) -> bool { $$$ $A >= $B.max(1) $$$ }"
19 changes: 19 additions & 0 deletions lint/ast-grep/rules/held-bodies-cap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
id: held-bodies-cap
language: rust
severity: error
message: "HeldBodies::CAP must be 320 - see docs/ibd-memory.md Q-54"
rule:
all:
- pattern: |
impl HeldBodies {
$$$
const CAP: $T = $VAL;
$$$
}
- not:
pattern: |
impl HeldBodies {
$$$
const CAP: $T = 320;
$$$
}
9 changes: 9 additions & 0 deletions lint/ast-grep/rules/pending-blocks-cap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id: pending-blocks-cap
language: rust
severity: error
message: "MAX_PENDING_BLOCKS must be 128 - see docs/ibd-memory.md Q-54"
rule:
all:
- pattern: "const MAX_PENDING_BLOCKS: $T = $VAL;"
- not:
pattern: "const MAX_PENDING_BLOCKS: $T = 128;"
9 changes: 9 additions & 0 deletions lint/ast-grep/rules/serve-blocks-cap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id: serve-blocks-cap
language: rust
severity: error
message: "MAX_SERVE_BLOCKS must be 16 - see docs/ibd-memory.md Q-54"
rule:
all:
- pattern: "const MAX_SERVE_BLOCKS: $T = $VAL;"
- not:
pattern: "const MAX_SERVE_BLOCKS: $T = 16;"
Loading