-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python: Tag quality queries with quality
and sub category.
#19812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Excluded for now for uncertainty: incomplete ordering, import deprecated module
Excluded for now: unnecassary-delete; since the pattern is often intentional to break reference cycles, which the query doesn't account for; so uncertain about its claim of high precision
Excluded queries that are python 2 specific; as well as the cyclic import queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds the quality
tag (with top-level categories and subcategories) to existing Python queries and updates the Python code-quality suite.
- Standardize metadata: add
quality
tag and assign appropriate sub-category tags across many Python QL queries - Document change: add a change-note entry for the new quality-tag convention
- Update tests: expand the Python code-quality suite’s expected query list
Reviewed Changes
Copilot reviewed 94 out of 94 changed files in this pull request and generated no comments.
File | Description |
---|---|
python/ql/src/change-notes/2025-06-18-quality-query-metadata.md | Add entry describing the new quality category and sub-category tagging convention |
python/ql/src/**/*.ql | Add quality tag and assign one or more sub-category tags (reliability , maintainability , correctness , etc.) to each Python query |
python/ql/integration-tests/query-suite/python-code-quality.qls.expected | Update the expected list of queries included in the python-code-quality test suite |
Comments suppressed due to low confidence (2)
python/ql/integration-tests/query-suite/python-code-quality.qls.expected:1
- Paths in this expected list are missing the
python/
prefix (python/ql/src/...
) and won’t match the actual file locations; please restore the full relative path.
ql/src/Classes/ConflictingAttributesInBaseClasses.ql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a few comments/suggestions here and there, but overall this looks good to me. 👍
* maintainability | ||
* readability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems more like a reliability/correctness
issue to me.
* maintainability | ||
* readability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also seems more like reliability/correctness
.
* maintainability | ||
* convention | ||
* readability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if reliability/correctness
is a better choice here as well (though none of them seem to fit this case very well). In some sense, "printing during import" could be thought of as an "unintended consequence" (for users that were not expecting an import to print).
* maintainability | ||
* @tags quality | ||
* reliability | ||
* correctness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add performance
here.
@@ -2,7 +2,8 @@ | |||
* @name Module is imported more than once | |||
* @description Importing a module a second time has no effect and impairs readability | |||
* @kind problem | |||
* @tags maintainability | |||
* @tags quality | |||
* maintainability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add readability
here.
@@ -2,7 +2,8 @@ | |||
* @name Redundant assignment | |||
* @description Assigning a variable to itself is useless and very likely indicates an error in the code. | |||
* @kind problem | |||
* @tags reliability | |||
* @tags quality | |||
* maintainability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one could also be reliability/correctness
, but I don't feel strongly about it.
@@ -2,7 +2,8 @@ | |||
* @name Duplication in regular expression character class | |||
* @description Duplicate characters in a class have no effect and may indicate an error in the regular expression. | |||
* @kind problem | |||
* @tags reliability | |||
* @tags quality | |||
* reliability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should perhaps be maintainability
to fit the readability
subcategory?
Updated tags for high and very high precision quality queries, using the query metadata guide. It is intended that all of these queries will now be in the quality suite.
A few queries were excluded from this process:
The following queries are specific to python 2; we probably don't need them in the quality suite and could deprecate them at some point:
py/old-style-octal-literal
py/truncated-division
py/inconsistent-equality
py/property-in-old-style-class
py/slots-in-old-style-class
py/super-in-old-style
py/raises-tuple
py/unguarded-next-in-generator
py/use-of-apply
py/use-of-input
py/deprecated-slice-method
py/leaking-list-comprehension
The following queries I was uncertain about, so I have excluded for now:
py/incomplete-ordering
- While this query makes sense for python 3, its current implementation is specific to python 2; since it checks for all four comparison methods being defined, whereas in python 3 only__lt__
and__le__
need to be defined. Thus, as is, this query may have more FPs and a lower precision than itsprecision: high
tag suggests.py/import-deprecated-module
- This query includes a list of deprecated modules (and suggested replacements) that is very old; so uncertain of the utility of including it in the quality suite without updating it.py/unnecessary-delete
- I am uncertain about the precision/FP rate of this query, despite itsprecision: high
tag - since it is relatively common to usedel
to break reference cycles, which this query doesn't appear to account for.py/cyclic-import
andpy/unsafe-cyclic-import
- These queries were discussed at some point in a team meeting as queries that we are uncertain about maintaining (in the context of modernizing quality queries), due to its complexity and difficulty to distinguish cases in which the pattern is intentional and done carefully and correctly, from true positives.