pr fixes, typo in qhelp file and helper method for queries

This commit is contained in:
Dilan
2021-03-19 16:43:29 -07:00
parent 26b030f8cc
commit 1385b22642
4 changed files with 29 additions and 19 deletions

View File

@@ -21,7 +21,7 @@ Write the class name beginning with an uppercase letter. For example, <code>clas
<references>
<li>
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code<em>
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code</em>
<a href="https://www.python.org/dev/peps/pep-0008/#class-names">Python Class Names</a>
</li>

View File

@@ -9,15 +9,20 @@
import python
from Class c, string first_char
predicate lower_case_class(Class c) {
exists(string first_char |
first_char = c.getName().prefix(1) and
not first_char = first_char.toUpperCase()
)
}
from Class c
where
c.inSource() and
first_char = c.getName().prefix(1) and
not first_char = first_char.toUpperCase() and
not exists(Class c1, string first_char1 |
lower_case_class(c) and
not exists(Class c1 |
c1 != c and
c1.getLocation().getFile() = c.getLocation().getFile() and
first_char1 = c1.getName().prefix(1) and
not first_char1 = first_char1.toUpperCase()
lower_case_class(c1)
)
select c, "Class names should start in uppercase."

View File

@@ -21,7 +21,7 @@ Write the function name beginning with an lowercase letter. For example, <code>j
<references>
<li>
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code<em>
Guido van Rossum, Barry Warsaw, Nick Coghlan <em>PEP 8 -- Style Guide for Python Code</em>
<a href="https://www.python.org/dev/peps/pep-0008/#function-and-variable-names">Python Function and Variable Names</a>
</li>

View File

@@ -9,15 +9,20 @@
import python
from Function f, string first_char
where
f.inSource() and
first_char = f.getName().prefix(1) and
not first_char = first_char.toLowerCase() and
not exists(Function f1, string first_char1 |
f1 != f and
f1.getLocation().getFile() = f.getLocation().getFile() and
first_char1 = f1.getName().prefix(1) and
not first_char1 = first_char1.toLowerCase()
predicate upper_case_function(Function func) {
exists(string first_char |
first_char = func.getName().prefix(1) and
not first_char = first_char.toLowerCase()
)
select f, "Function names should start in lowercase."
}
from Function func
where
func.inSource() and
upper_case_function(func) and
not exists(Function func1 |
func1 != func and
func1.getLocation().getFile() = func.getLocation().getFile() and
upper_case_function(func1)
)
select func, "Function names should start in lowercase."