@@ -193,6 +193,8 @@ def _apply_remediation(
193
193
"""
194
194
Applies remediation behavior to a codemod, that is, each changeset will only be associated with a single finging and no files will be written.
195
195
"""
196
+ if self ._should_skip (context ):
197
+ return None
196
198
results : ResultSet | None = self ._apply_detector (context )
197
199
198
200
if results is not None and not results :
@@ -248,6 +250,8 @@ def _apply_hardening(
248
250
"""
249
251
Applies hardening behavior to a codemod with the goal of integrating all fixes for each finding into the files.
250
252
"""
253
+ if self ._should_skip (context ):
254
+ return None
251
255
results : ResultSet | None = self ._apply_detector (context )
252
256
253
257
if results is not None and not results :
@@ -276,15 +280,15 @@ def _apply_hardening(
276
280
context .process_results (self .id , contexts )
277
281
return None
278
282
279
- def _apply_detector (self , context : CodemodExecutionContext ) -> ResultSet | None :
283
+ def _should_skip (self , context : CodemodExecutionContext ):
280
284
if self .provider and (
281
285
not (provider := context .providers .get_provider (self .provider ))
282
286
or not provider .is_available
283
287
):
284
288
logger .warning (
285
289
"provider %s is not available, skipping codemod" , self .provider
286
290
)
287
- return None
291
+ return True
288
292
289
293
if isinstance (self .detector , SemgrepRuleDetector ):
290
294
if (
@@ -296,7 +300,10 @@ def _apply_detector(self, context: CodemodExecutionContext) -> ResultSet | None:
296
300
"no results from semgrep for %s, skipping analysis" ,
297
301
self .id ,
298
302
)
299
- return None
303
+ return True
304
+ return False
305
+
306
+ def _apply_detector (self , context : CodemodExecutionContext ) -> ResultSet | None :
300
307
301
308
results : ResultSet | None = (
302
309
# It seems like semgrep doesn't like our fully-specified id format so pass in short name instead.
@@ -429,6 +436,7 @@ def apply(
429
436
self , context : CodemodExecutionContext , remediation : bool = False
430
437
) -> None | TokenUsage :
431
438
if remediation :
439
+ print ("0000000000000000000000000000000000000000000000000000000000" )
432
440
return self ._apply_remediation (context , self .requested_rules )
433
441
return self ._apply_hardening (context , self .requested_rules )
434
442
0 commit comments