Skip to content

Commit 9a6fbb7

Browse files
authored
Merge pull request #29 from naaa760/feat/diff-rule-presets
docs: add diff rule presets for threading guardrails
2 parents c9657b8 + eadf244 commit 9a6fbb7

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
rules:
2+
- description: "Avoid raw threading.Thread; prefer ThreadPoolExecutor"
3+
enabled: true
4+
severity: "medium"
5+
event_types: ["pull_request"]
6+
parameters:
7+
file_patterns: ["**/*.py"]
8+
forbidden_patterns:
9+
- "threading\\.Thread"
10+
11+
- description: "Warn when ThreadPoolExecutor max_workers is greater than 10"
12+
enabled: true
13+
severity: "medium"
14+
event_types: ["pull_request"]
15+
parameters:
16+
file_patterns: ["**/*.py"]
17+
forbidden_patterns:
18+
- "ThreadPoolExecutor\\(max_workers\\s*=\\s*(1[1-9]|[2-9][0-9]|\\d{3,})"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Diff rule presets (threading guardrails)
2+
3+
These presets use the diff-aware validators already supported by Watchflow. Paste them directly into `.watchflow/rules.yaml` or upload to watchflow.dev as a YAML file. They avoid any unsupported sections (no `actions`, only `description`, `enabled`, `severity`, `event_types`, and `parameters` with `file_patterns`, `require_patterns`, `forbidden_patterns`).
4+
5+
## Preset file
6+
7+
The file `docs/assets/threading-guardrails.yaml` contains ready-to-use rules:
8+
9+
```yaml
10+
rules:
11+
- description: "Avoid raw threading.Thread; prefer ThreadPoolExecutor"
12+
enabled: true
13+
severity: "medium"
14+
event_types: ["pull_request"]
15+
parameters:
16+
file_patterns: ["**/*.py"]
17+
forbidden_patterns:
18+
- "threading\\.Thread"
19+
20+
- description: "Warn when ThreadPoolExecutor max_workers is greater than 10"
21+
enabled: true
22+
severity: "medium"
23+
event_types: ["pull_request"]
24+
parameters:
25+
file_patterns: ["**/*.py"]
26+
forbidden_patterns:
27+
- "ThreadPoolExecutor\\(max_workers\\s*=\\s*(1[1-9]|[2-9][0-9]|\\d{3,})"
28+
```
29+
30+
## How to use on watchflow.dev
31+
32+
1) Click “Upload config” (or paste the YAML directly if enabled).
33+
2) Ensure event type is `pull_request`.
34+
3) Adjust file globs or regexes as needed for your repo.
35+
36+
If the form still shows “Rule not supported,” it means the UI is filtering diff-pattern rules. In that case, use the YAML upload path or apply the config directly in your repo. A follow-up change to the site can whitelist these presets so they appear without warnings.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ nav:
6262
- Getting Started:
6363
- Quick Start: getting-started/quick-start.md
6464
- Configuration: getting-started/configuration.md
65+
- Diff Rule Presets: getting-started/diff-rule-presets.md
6566
- Features & Capabilities:
6667
- Features: features.md
6768
- Comparative Analysis: benchmarks.md

0 commit comments

Comments
 (0)