Created
April 30, 2020 18:01
-
-
Save mallamanis/8eaf1eac5509e583fbf60df302f70cf2 to your computer and use it in GitHub Desktop.
Prefer iglob instead of glob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name Prefer iglob | |
* @description Use iglob instead of glob | |
* @kind problem | |
* @tags speed | |
* @problem.severity recommendation | |
* @sub-severity low | |
* @precision high | |
* @id py/use-iglob | |
*/ | |
import python | |
predicate is_glob(Call call) { | |
call.getFunc().pointsTo(Value::named("glob.glob")) | |
} | |
from AstNode node | |
where | |
is_glob(node.(For).getIter().(Call)) or | |
is_glob(node.(ListComp).getIterable()) or | |
is_glob(node.(SetComp).getIterable()) or | |
is_glob(node.(DictComp).getIterable()) or | |
is_glob(node.(GeneratorExp).getIterable()) | |
select node, "Prefer `iglob` to `glob`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment