FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Classes/UselessClass.qhelp at codeql-cli-2.19.2 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
469
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
UselessClass.qhelp
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (26 loc) · 958 Bytes
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
UselessClass.qhelp
Copy path
File metadata and controls
35 lines (26 loc) · 958 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
30
31
32
33
34
35
<!
DOCTYPE
qhelp
PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<
qhelp
>
<
overview
>
<
p
> If a class has only one public method (other than its <
code
>__init__</
code
>)
it should be replaced with a function.
</
p
>
</
overview
>
<
recommendation
>
<
p
> Convert the single public method into a function.
If there is an <
code
>__init__</
code
> and it sets attributes on the <
code
>self</
code
>
then rename the <
code
>__init__</
code
> method and remove the <
code
>self</
code
> parameter
Make the public method an inner function and return that.</
p
>
<
p
>Delete the class.</
p
>
</
recommendation
>
<
example
>
<
p
>In this example the class only has a single method. This method does not need to be in its own
class. It should be a method on its own that takes <
code
>a</
code
> and <
code
>b</
code
> as parameters.
</
p
>
<
sample
src
=
"
UselessClass.py
"
/>
</
example
>
<
references
>
<
li
>Python: <
a
href
=
"
http://docs.python.org/tutorial/classes.html
"
>Classes</
a
>.</
li
>
</
references
>
</
qhelp
>
Back
|
FazBrowse Home
|
New Git URL