-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathConsistentReturns.qhelp
37 lines (25 loc) · 1.02 KB
/
ConsistentReturns.qhelp
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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>When a function contains both explicit returns (<code>return value</code>) and implicit returns
(where code falls off the end of a function) this often indicates that a return
statement has been forgotten. It is best to return an explicit return value even when returning
<code>None</code> because this makes it easier for other developers to read your code.
</p>
</overview>
<recommendation>
<p>Add an explicit return at the end of the function.</p>
</recommendation>
<example>
<p>In the <code>check_state1</code> function, the developer probably did intend to use an implicit
return value of <code>None</code> as this equates to <code>False</code>. However, the function in
<code>check_state2</code> is easier to read.</p>
<sample src="ConsistentReturns.py" />
</example>
<references>
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/compound_stmts.html#function">Function definitions</a>.
</li>
</references>
</qhelp>