File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2- """Simple linter to spot denylisted model usage within Django view modules."""
2+ """Check for model usage without provider scoping within Django view modules."""
33
44import argparse
55import re
99
1010REPO_ROOT = Path (__file__ ).parent .parent
1111
12- DENYLISTED_MODELS = (
13- "Appointment" ,
14- "Clinic" ,
15- "Participant" ,
16- "Symptom" ,
17- "BreastCancerHistoryItem" ,
12+ ALLOWLISTED_MODELS = (
13+ "User" ,
14+ "Provider" ,
15+ "BreastAugmentationHistoryItem" , # Temporarily allowed
16+ "CystHistoryItem" , # Temporarily allowed
17+ "ImplantedMedicalDeviceHistoryItem" , # Temporarily allowed
18+ "MastectomyOrLumpectomyHistoryItem" , # Temporarily allowed
19+ "ParticipantReportedMammogram" , # Temporarily allowed
1820)
21+
1922TARGETS = {
2023 "model.objects" : re .compile (r"(?P<model_name>\w+)\.objects" ),
2124 "model.get_object_or_404" : re .compile (r"(?P<model_name>\w+)\.get_object_or_404" ),
@@ -75,7 +78,7 @@ def find_matches(paths):
7578 for label , regex in TARGETS .items ():
7679 if match := regex .search (line ):
7780 model_name = match .group ("model_name" )
78- if model_name in DENYLISTED_MODELS :
81+ if model_name not in ALLOWLISTED_MODELS :
7982 yield Match (
8083 path = path ,
8184 line_number = line_number ,
You can’t perform that action at this time.
0 commit comments