FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Expressions/UnnecessaryLambda.qhelp at master · cor0ps/codeql · GitHub
cor0ps
codeql
Repository navigation
Code
Issues
1
(1)
Pull requests
3
(3)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Expressions
/
UnnecessaryLambda.qhelp
Copy path
More file actions
More file actions
Latest commit
History
History
History
29 lines (23 loc) · 859 Bytes
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Expressions
/
UnnecessaryLambda.qhelp
Copy path
File metadata and controls
29 lines (23 loc) · 859 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!
DOCTYPE
qhelp
PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<
qhelp
>
<
overview
>
<
p
>A lambda that calls a function without modifying any of its parameters is unnecessary.
Python functions are first class objects and can be passed around in the same way as the resulting lambda.
</
p
>
</
overview
>
<
recommendation
>
<
p
>Remove the lambda, use the function directly.</
p
>
</
recommendation
>
<
example
>
<
p
>In this example a lambda is used unnecessarily in order to pass a method as an argument to <
code
>
call_with_x_squared</
code
>.</
p
>
<
sample
src
=
"
UnnecessaryLambda.py
"
/>
<
p
>This is not necessary as methods can be passed directly. They behave as callable objects.</
p
>
<
sample
src
=
"
UnnecessaryLambdaFix.py
"
/>
</
example
>
<
references
>
<
li
>Python: <
a
href
=
"
http://docs.python.org/2.7/reference/expressions.html#lambda
"
>lambdas</
a
>.</
li
>
</
references
>
</
qhelp
>
Back
|
FazBrowse Home
|
New Git URL