Skip to content

Commit 26b030f

Browse files
author
dilanbhalla
committed
fixed pr suggestions
1 parent dc73fcc commit 26b030f

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

python/ql/src/experimental/Classes/NamingConventionsClasses.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Write the class name beginning with an uppercase letter. For example, <code>clas
2222

2323
<li>
2424
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code<em>
25-
<a href="https://www.python.org/dev/peps/pep-0008/#class-names"</a>
25+
<a href="https://www.python.org/dev/peps/pep-0008/#class-names">Python Class Names</a>
2626
</li>
2727

2828
</references>

python/ql/src/experimental/Classes/NamingConventionsClasses.ql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
* @description A class name that begins with a lowercase letter decreases readability.
44
* @kind problem
55
* @problem.severity recommendation
6-
* @precision medium
7-
* @id python/misnamed-type
6+
* @id py/misnamed-class
87
* @tags maintainability
98
*/
109

1110
import python
1211

13-
from Class c
12+
from Class c, string first_char
1413
where
1514
c.inSource() and
16-
not c.getName().substring(0, 1).toUpperCase() = c.getName().substring(0, 1)
15+
first_char = c.getName().prefix(1) and
16+
not first_char = first_char.toUpperCase() and
17+
not exists(Class c1, string first_char1 |
18+
c1 != c and
19+
c1.getLocation().getFile() = c.getLocation().getFile() and
20+
first_char1 = c1.getName().prefix(1) and
21+
not first_char1 = first_char1.toUpperCase()
22+
)
1723
select c, "Class names should start in uppercase."

python/ql/src/experimental/Functions/NamingConventionsFunctions.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Write the function name beginning with an lowercase letter. For example, <code>j
2222

2323
<li>
2424
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code<em>
25-
<a href="https://www.python.org/dev/peps/pep-0008/#function-and-variable-names"</a>
25+
<a href="https://www.python.org/dev/peps/pep-0008/#function-and-variable-names">Python Function and Variable Names</a>
2626
</li>
2727

2828
</references>

python/ql/src/experimental/Functions/NamingConventionsFunctions.ql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
* @description A function name that begins with an uppercase letter decreases readability.
44
* @kind problem
55
* @problem.severity recommendation
6-
* @precision medium
7-
* @id python/misnamed-function
6+
* @id py/misnamed-function
87
* @tags maintainability
98
*/
109

1110
import python
1211

13-
from Function f
12+
from Function f, string first_char
1413
where
1514
f.inSource() and
16-
not f.getName().substring(0, 1).toLowerCase() = f.getName().substring(0, 1)
15+
first_char = f.getName().prefix(1) and
16+
not first_char = first_char.toLowerCase() and
17+
not exists(Function f1, string first_char1 |
18+
f1 != f and
19+
f1.getLocation().getFile() = f.getLocation().getFile() and
20+
first_char1 = f1.getName().prefix(1) and
21+
not first_char1 = first_char1.toLowerCase()
22+
)
1723
select f, "Function names should start in lowercase."

0 commit comments

Comments
 (0)