Created
May 1, 2020 08:07
-
-
Save mallamanis/08a1f36a6ab3255b0e5783aa1b25d85f to your computer and use it in GitHub Desktop.
useCxManagerForOpen.ql
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 Use with open() as | |
* @description Consider using a context manager | |
* @kind problem | |
* @tags maintainability | |
* @problem.severity recommendation | |
* @sub-severity low | |
* @precision medium | |
* @id py/use-context-manager | |
*/ | |
import python | |
from Call call | |
where call.getFunc().pointsTo(Value::named("open")) | |
and not exists(With withStmt | withStmt.contains(call)) | |
select call, "Consider using a context manager along with this open() statement, instead of manually closing this file later." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment