-
Notifications
You must be signed in to change notification settings - Fork 4
/
remove-debugging-statements.yaml
89 lines (84 loc) · 2.35 KB
/
remove-debugging-statements.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# These optional rules flag or remove various debugging statements.
#
# All rules in this file have the tags:
#
# * `remove-debugging-statements`
# * `no-debug`.
#
rules:
- id: remove-breakpoint
description: Remove breakpoints from production code
explanation: Breakpoints shouldn't be used in production code.
pattern: breakpoint(...)
replacement: ''
tests:
- match: breakpoint()
- match: breakpoint("sth")
tags:
- remove-debugging-statements
- no-debug
- id: remove-pdb-set_trace
description: Remove `pdb.set_trace` calls from production code
explanation: Breakpoints shouldn't be used in production code.
pattern: pdb.set_trace(...)
replacement: ''
tests:
- match: |
import pdb
pdb.set_trace()
- match: |
import pdb as pdb_debug
pdb_debug.set_trace()
tags:
- remove-debugging-statements
- no-debug
- id: flag-print
description: Remove `print` statements from production code
explanation: |
`print` statements shouldn't be used in production code.
Use:
* a CLI framework for output
* `logger.debug()` for debugging information.
pattern: print(...)
tests:
- match: print("sth")
- match: print(x, y)
- no-match: custom_print("sth")
tags:
- remove-debugging-statements
- no-debug
- id: flag-streamlit-show
description: Don't use Streamlit's `experimental_show` in production code
explanation: |
`st.experimental_show` should be used only for debugging purposes. See the [Streamlit docs](https://docs.streamlit.io/library/api-reference/utilities/st.experimental_show) Use `st.write()` in production
pattern: streamlit.experimental_show(...)
replacement: ''
tests:
- match: |
import streamlit as st
st.experimental_show(df)
- match: |
import streamlit as st
def some_function():
st.experimental_show(df)
- match: |
import streamlit
streamlit.experimental_show(df)
- no-match: |
import streamlit as st
st.snow(df)
- match: |
from streamlit import experimental_show
experimental_show(something)
- match: |
from streamlit import experimental_show as exp_show
exp_show(something)
- no-match: other_package.experimental_show()
- no-match: |
import st_other_package as st
def some_function():
st.experimental_show(df)
tags:
- remove-debugging-statements
- no-debug
- streamlit