-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathSetterReturn.qhelp
45 lines (33 loc) · 1.04 KB
/
SetterReturn.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
38
39
40
41
42
43
44
45
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
Returning a value from a property setter function is useless, since it will
always be ignored.
</p>
</overview>
<recommendation>
<p>
Remove the return statement altogether, or replace it with a simple <code>return;</code>
statement that does not return a value.
</p>
</recommendation>
<example>
<p>
The following example shows a constructor function <code>Point</code> that uses property accessors
on <code>x</code> and <code>y</code> to ensure that they are only set to integer values. It returns
the new values for <code>x</code> and <code>y</code> from their setters, but these return values
will simply be ignored.
</p>
<sample src="examples/SetterReturn.js" />
<p>
It would be clearer to omit the return statements:
</p>
<sample src="examples/SetterReturnGood.js" />
</example>
<references>
<li>Mozilla Developer Network: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set">Property setters</a>.</li>
</references>
</qhelp>