aboutsummaryrefslogtreecommitdiff
path: root/examples/static-analysis
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-07-14 13:01:23 +0100
committerAkshay <[email protected]>2024-07-14 13:01:23 +0100
commit9ad06d721c1e481c82b4f43df819d76e35757282 (patch)
treedebfca71dcdaeac93ac12abedd377f66cf4341fc /examples/static-analysis
parent83b537bb860643ebdabc43ab47cb8645da8a2e6d (diff)
add examples
Diffstat (limited to 'examples/static-analysis')
-rw-r--r--examples/static-analysis/none_comparisons.tbsp24
-rw-r--r--examples/static-analysis/sample.py3
2 files changed, 27 insertions, 0 deletions
diff --git a/examples/static-analysis/none_comparisons.tbsp b/examples/static-analysis/none_comparisons.tbsp
new file mode 100644
index 0000000..2d65426
--- /dev/null
+++ b/examples/static-analysis/none_comparisons.tbsp
@@ -0,0 +1,24 @@
1BEGIN {
2 bool in_equal_compare = false;
3 string comparison_text = "";
4}
5
6enter comparison_operator {
7 if (text(node.operators) == "==") {
8 in_equal_compare = true;
9 comparison_text = text(node);
10 };
11}
12
13leave comparison_operator {
14 in_equal_compare = false;
15}
16
17enter none {
18 if (in_equal_compare) {
19 print("using `==` to compare with None, use `is None` instead:\n\t");
20 print(comparison_text);
21 print("\n");
22 } else {
23 };
24}
diff --git a/examples/static-analysis/sample.py b/examples/static-analysis/sample.py
new file mode 100644
index 0000000..7c3ed09
--- /dev/null
+++ b/examples/static-analysis/sample.py
@@ -0,0 +1,3 @@
1def foo():
2 if bar == None:
3 print("none")