@@ -29,7 +29,8 @@ def get_ql_property(cls: schema.Class, prop: schema.Property):
2929 ** common_args ,
3030 singular = inflection .camelize (prop .name ),
3131 tablename = inflection .tableize (cls .name ),
32- tableparams = ["this" ] + ["result" if p is prop else "_" for p in cls .properties if p .is_single ],
32+ tableparams = [
33+ "this" ] + ["result" if p is prop else "_" for p in cls .properties if p .is_single ],
3334 )
3435 elif prop .is_repeated :
3536 return ql .Property (
@@ -49,7 +50,8 @@ def get_ql_property(cls: schema.Class, prop: schema.Property):
4950 elif prop .is_predicate :
5051 return ql .Property (
5152 ** common_args ,
52- singular = inflection .camelize (prop .name , uppercase_first_letter = False ),
53+ singular = inflection .camelize (
54+ prop .name , uppercase_first_letter = False ),
5355 tablename = inflection .underscore (f"{ cls .name } _{ prop .name } " ),
5456 tableparams = ["this" ],
5557 )
@@ -62,6 +64,7 @@ def get_ql_class(cls: schema.Class):
6264 final = not cls .derived ,
6365 properties = [get_ql_property (cls , p ) for p in cls .properties ],
6466 dir = cls .dir ,
67+ skip_qltest = "no_qltest" in cls .tags ,
6568 )
6669
6770
@@ -100,20 +103,22 @@ def format(codeql, files):
100103 log .debug (line .strip ())
101104
102105
103- def _get_all_properties (cls : ql .Class , lookup : typing .Dict [str , ql .Class ]) -> typing .Iterable [ql .Property ]:
106+ def _get_all_properties (cls : ql .Class , lookup : typing .Dict [str , ql .Class ]) -> typing .Iterable [
107+ typing .Tuple [ql .Class , ql .Property ]]:
104108 for b in cls .bases :
105- for p in _get_all_properties (lookup [b ], lookup ):
106- yield p
109+ base = lookup [b ]
110+ for item in _get_all_properties (base , lookup ):
111+ yield item
107112 for p in cls .properties :
108- yield p
113+ yield cls , p
109114
110115
111116def _get_all_properties_to_be_tested (cls : ql .Class , lookup : typing .Dict [str , ql .Class ]) -> typing .Iterable [
112117 ql .PropertyForTest ]:
113118 # deduplicate using id
114119 already_seen = set ()
115- for p in _get_all_properties (cls , lookup ):
116- if not p .skip_qltest and id (p ) not in already_seen :
120+ for c , p in _get_all_properties (cls , lookup ):
121+ if not ( c . skip_qltest or p .skip_qltest or id (p ) in already_seen ) :
117122 already_seen .add (id (p ))
118123 yield ql .PropertyForTest (p .getter , p .type , p .is_single , p .is_predicate , p .is_repeated )
119124
@@ -153,30 +158,35 @@ def generate(opts, renderer):
153158 renderer .render (c , qll )
154159 stub_file = stub_out / c .path .with_suffix (".qll" )
155160 if not stub_file .is_file () or is_generated (stub_file ):
156- stub = ql .Stub (name = c .name , base_import = get_import (qll , opts .swift_dir ))
161+ stub = ql .Stub (
162+ name = c .name , base_import = get_import (qll , opts .swift_dir ))
157163 renderer .render (stub , stub_file )
158164
159165 # for example path/to/elements -> path/to/elements.qll
160166 include_file = stub_out .with_suffix (".qll" )
161167 all_imports = ql .ImportList (list (sorted (imports .values ())))
162168 renderer .render (all_imports , include_file )
163169
164- renderer .render (ql .GetParentImplementation (classes ), out / 'GetImmediateParent.qll' )
170+ renderer .render (ql .GetParentImplementation (
171+ classes ), out / 'GetImmediateParent.qll' )
165172
166173 for c in classes :
167- if not c .final :
174+ if not c .final or c . skip_qltest :
168175 continue
169176 test_dir = test_out / c .path
170177 test_dir .mkdir (parents = True , exist_ok = True )
171178 if not any (test_dir .glob ("*.swift" )):
172179 log .warning (f"no test source in { c .path } " )
173- renderer .render (ql .MissingTestInstructions (), test_dir / missing_test_source_filename )
180+ renderer .render (ql .MissingTestInstructions (),
181+ test_dir / missing_test_source_filename )
174182 continue
175183 total_props , partial_props = _partition (_get_all_properties_to_be_tested (c , lookup ),
176184 lambda p : p .is_single or p .is_predicate )
177- renderer .render (ql .ClassTester (class_name = c .name , properties = total_props ), test_dir / f"{ c .name } .ql" )
185+ renderer .render (ql .ClassTester (class_name = c .name ,
186+ properties = total_props ), test_dir / f"{ c .name } .ql" )
178187 for p in partial_props :
179- renderer .render (ql .PropertyTester (class_name = c .name , property = p ), test_dir / f"{ c .name } _{ p .getter } .ql" )
188+ renderer .render (ql .PropertyTester (class_name = c .name ,
189+ property = p ), test_dir / f"{ c .name } _{ p .getter } .ql" )
180190
181191 renderer .cleanup (existing )
182192 if opts .ql_format :
0 commit comments