forked from autotest/tp-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tp-libvirt_review_comment_summary.rst
69 lines (63 loc) · 2.54 KB
/
tp-libvirt_review_comment_summary.rst
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
======================================
Review comment summary for tp-libvirt
======================================
Overview:
This doc summarize the most common review comments in tp-libvirt open source project.
For beginners or practice executor, it may provides some self-check before submitting to normal review in github.
======================================================================
Goal:
1)Provide one place to accumulate knowledge
2)Provide some helps to beginners or executors in coding or style format for tp-libvirt
======================================================================
More common issues during reviewing can be categorized as below.
Format::
--cfg file
trailing whitespaces
indent alignment
variable reusable
variable name(upper or lower case letter)
Module import order(better similar module stay together)
Spelling errors
--py file:
imported module one blank line
miss doc comments
doc comment need one empty line between comment and parameter
doc comment start with #<space>'
comments include multiple lines, need care ','
indent issue
trailing whitespace
unused variable
remove comment code(#...)
comment upper and lower letter issues
logging.debug("Find snapshots: %s", snap_names)
Spelling errors
======================================================================
Coding:
-- variable name issue:
name should be meaningful
-- depreciated method:
test.skip(remove raise)
autotest.client import utils
-- result assert
libvirt_vm.check_exit_status
-- resource cleanup
vm_connection_session close(exception gracefully close)
vm_backup.sync() called before any change
-- variable not definition
extreme situation: variable not definition such as conditional
-- parameters in method is not usable
Use autoflake to remove unused parameters
-- list index out of range
make sure that your list index
-- duplicate code avoidance
when code was called twice, better package them into one method
-- exception handling
miss do assert in throwing exception
======================================================================
Enhancement(Best practice):
-- conjunction two folders:use os.path.join(xx,xx)
-- avoid too generic logging message
-- not recommended to use mutable default value as an argument see: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
-- without timeout value in infinite loop
-- use with to open files
-- make sure this is run before sending patch:inspekt checkall --no-license-check <*>.py