Skip to content

Commit 34ebed1

Browse files
authored
Merge pull request #20402 from michaelnebel/python/code-quality-extended
Python: Add most `medium` precision queries to the `code-quality-extended` suite.
2 parents 6d33089 + c2628fe commit 34ebed1

17 files changed

+55
-32
lines changed

python/ql/integration-tests/query-suite/not_included_in_qls.expected

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
ql/python/ql/src/AlertSuppression.ql
22
ql/python/ql/src/Classes/MaybeUndefinedClassAttribute.ql
3-
ql/python/ql/src/Classes/ShouldBeContextManager.ql
43
ql/python/ql/src/Classes/UndefinedClassAttribute.ql
5-
ql/python/ql/src/Classes/UselessClass.ql
6-
ql/python/ql/src/Expressions/NonPortableComparisonUsingIs.ql
74
ql/python/ql/src/Filters/ClassifyFiles.ql
8-
ql/python/ql/src/Functions/ReturnValueIgnored.ql
95
ql/python/ql/src/Imports/ImportShadowedByLoopVar.ql
106
ql/python/ql/src/Imports/ImportStarUsed.ql
117
ql/python/ql/src/Imports/Imports.ql
@@ -59,16 +55,12 @@ ql/python/ql/src/Metrics/TransitiveImports.ql
5955
ql/python/ql/src/Security/CWE-020-ExternalAPIs/ExternalAPIsUsedWithUntrustedData.ql
6056
ql/python/ql/src/Security/CWE-020-ExternalAPIs/UntrustedDataToExternalAPI.ql
6157
ql/python/ql/src/Security/CWE-798/HardcodedCredentials.ql
62-
ql/python/ql/src/Statements/AssertLiteralConstant.ql
6358
ql/python/ql/src/Statements/C_StyleParentheses.ql
6459
ql/python/ql/src/Statements/DocStrings.ql
6560
ql/python/ql/src/Statements/ExecUsed.ql
6661
ql/python/ql/src/Statements/StringConcatenationInLoop.ql
6762
ql/python/ql/src/Variables/Global.ql
68-
ql/python/ql/src/Variables/ShadowBuiltin.ql
69-
ql/python/ql/src/Variables/ShadowGlobal.ql
7063
ql/python/ql/src/Variables/UndefinedGlobal.ql
71-
ql/python/ql/src/Variables/UnusedParameter.ql
7264
ql/python/ql/src/analysis/CallGraphEfficiency.ql
7365
ql/python/ql/src/analysis/CallGraphMarginalEfficiency.ql
7466
ql/python/ql/src/analysis/Consistency.ql

python/ql/integration-tests/query-suite/python-code-quality-extended.qls.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ ql/python/ql/src/Classes/DefineEqualsWhenAddingAttributes.ql
1010
ql/python/ql/src/Classes/InconsistentMRO.ql
1111
ql/python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql
1212
ql/python/ql/src/Classes/MutatingDescriptor.ql
13+
ql/python/ql/src/Classes/OverwritingAttributeInSuperClass.ql
14+
ql/python/ql/src/Classes/ShouldBeContextManager.ql
1315
ql/python/ql/src/Classes/SubclassShadowing/SubclassShadowing.ql
16+
ql/python/ql/src/Classes/UselessClass.ql
1417
ql/python/ql/src/Classes/WrongNameForArgumentInClassInstantiation.ql
1518
ql/python/ql/src/Classes/WrongNumberArgumentsInClassInstantiation.ql
1619
ql/python/ql/src/Exceptions/CatchingBaseException.ql
@@ -37,6 +40,7 @@ ql/python/ql/src/Expressions/Formatting/WrongNumberArgumentsFor3101Format.ql
3740
ql/python/ql/src/Expressions/HashedButNoHash.ql
3841
ql/python/ql/src/Expressions/IncorrectComparisonUsingIs.ql
3942
ql/python/ql/src/Expressions/NonCallableCalled.ql
43+
ql/python/ql/src/Expressions/NonPortableComparisonUsingIs.ql
4044
ql/python/ql/src/Expressions/Regex/BackspaceEscape.ql
4145
ql/python/ql/src/Expressions/Regex/DuplicateCharacterInSet.ql
4246
ql/python/ql/src/Expressions/Regex/MissingPartSpecialGroup.ql
@@ -61,10 +65,12 @@ ql/python/ql/src/Functions/NonCls.ql
6165
ql/python/ql/src/Functions/NonSelf.ql
6266
ql/python/ql/src/Functions/OverlyComplexDelMethod.ql
6367
ql/python/ql/src/Functions/ReturnConsistentTupleSizes.ql
68+
ql/python/ql/src/Functions/ReturnValueIgnored.ql
6469
ql/python/ql/src/Functions/SignatureOverriddenMethod.ql
6570
ql/python/ql/src/Functions/SignatureSpecialMethods.ql
6671
ql/python/ql/src/Functions/UseImplicitNoneReturnValue.ql
6772
ql/python/ql/src/Imports/EncodingError.ql
73+
ql/python/ql/src/Imports/FromImportOfMutableAttribute.ql
6874
ql/python/ql/src/Imports/ImportandImportFrom.ql
6975
ql/python/ql/src/Imports/ModuleImportsItself.ql
7076
ql/python/ql/src/Imports/MultipleImports.ql
@@ -73,7 +79,9 @@ ql/python/ql/src/Imports/UnintentionalImport.ql
7379
ql/python/ql/src/Imports/UnusedImport.ql
7480
ql/python/ql/src/Lexical/CommentedOutCode.ql
7581
ql/python/ql/src/Resources/FileNotAlwaysClosed.ql
82+
ql/python/ql/src/Statements/AssertLiteralConstant.ql
7683
ql/python/ql/src/Statements/AssertOnTuple.ql
84+
ql/python/ql/src/Statements/BreakOrReturnInFinally.ql
7785
ql/python/ql/src/Statements/ConstantInConditional.ql
7886
ql/python/ql/src/Statements/IterableStringOrSequence.ql
7987
ql/python/ql/src/Statements/MismatchInMultipleAssignment.ql
@@ -82,6 +90,7 @@ ql/python/ql/src/Statements/NestedLoopsSameVariable.ql
8290
ql/python/ql/src/Statements/NestedLoopsSameVariableWithReuse.ql
8391
ql/python/ql/src/Statements/NonIteratorInForLoop.ql
8492
ql/python/ql/src/Statements/RedundantAssignment.ql
93+
ql/python/ql/src/Statements/ReturnOrYieldOutsideFunction.ql
8594
ql/python/ql/src/Statements/ShouldUseWithStatement.ql
8695
ql/python/ql/src/Statements/SideEffectInAssert.ql
8796
ql/python/ql/src/Statements/StatementNoEffect.ql
@@ -95,7 +104,12 @@ ql/python/ql/src/Testing/ImpreciseAssert.ql
95104
ql/python/ql/src/Variables/GlobalAtModuleLevel.ql
96105
ql/python/ql/src/Variables/LoopVariableCapture/LoopVariableCapture.ql
97106
ql/python/ql/src/Variables/MultiplyDefined.ql
107+
ql/python/ql/src/Variables/ShadowBuiltin.ql
108+
ql/python/ql/src/Variables/ShadowGlobal.ql
98109
ql/python/ql/src/Variables/SuspiciousUnusedLoopIterationVariable.ql
99110
ql/python/ql/src/Variables/UndefinedExport.ql
111+
ql/python/ql/src/Variables/UndefinedPlaceHolder.ql
112+
ql/python/ql/src/Variables/UninitializedLocal.ql
100113
ql/python/ql/src/Variables/UnusedLocalVariable.ql
101114
ql/python/ql/src/Variables/UnusedModuleVariable.ql
115+
ql/python/ql/src/Variables/UnusedParameter.ql

python/ql/src/Classes/OverwritingAttributeInSuperClass.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* @name Overwriting attribute in super-class or sub-class
33
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass `__init__` method.
44
* @kind problem
5-
* @tags reliability
6-
* maintainability
7-
* modularity
5+
* @tags quality
6+
* reliability
7+
* correctness
88
* @problem.severity warning
99
* @sub-severity low
1010
* @precision medium

python/ql/src/Classes/ShouldBeContextManager.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
* @description Making a class a context manager allows instances to be used in a 'with' statement.
44
* This improves resource handling and code readability.
55
* @kind problem
6-
* @tags maintainability
6+
* @tags quality
7+
* maintainability
78
* readability
8-
* convention
9+
* performance
910
* @problem.severity recommendation
1011
* @sub-severity high
1112
* @precision medium

python/ql/src/Classes/UselessClass.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
* @name Useless class
33
* @description Class only defines one public method (apart from `__init__` or `__new__`) and should be replaced by a function
44
* @kind problem
5-
* @tags maintainability
5+
* @tags quality
6+
* maintainability
67
* useless-code
8+
* complexity
79
* @problem.severity recommendation
810
* @sub-severity low
911
* @precision medium

python/ql/src/Expressions/NonPortableComparisonUsingIs.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
* @name Non-portable comparison using is when operands support `__eq__`
33
* @description Comparison using 'is' when equivalence is not the same as identity and may not be portable.
44
* @kind problem
5-
* @tags portability
6-
* maintainability
5+
* @tags quality
6+
* reliability
7+
* correctness
78
* @problem.severity recommendation
89
* @sub-severity low
910
* @precision medium

python/ql/src/Functions/ReturnValueIgnored.ql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
* @name Ignored return value
33
* @description Ignoring return values may result in discarding errors or loss of information.
44
* @kind problem
5-
* @tags reliability
5+
* @tags quality
6+
* reliability
7+
* correctness
68
* readability
7-
* convention
8-
* statistical
9-
* non-attributable
109
* external/cwe/cwe-252
1110
* @problem.severity recommendation
1211
* @sub-severity high

python/ql/src/Imports/FromImportOfMutableAttribute.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* @name Importing value of mutable attribute
33
* @description Importing the value of a mutable attribute directly means that changes in global state will not be observed locally.
44
* @kind problem
5-
* @tags reliability
6-
* maintainability
7-
* modularity
5+
* @tags quality
6+
* reliability
7+
* correctness
88
* @problem.severity warning
99
* @sub-severity high
1010
* @precision medium

python/ql/src/Statements/AssertLiteralConstant.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* @description An assert statement testing a literal constant value may exhibit
44
* different behavior when optimizations are enabled.
55
* @kind problem
6-
* @tags reliability
6+
* @tags quality
7+
* reliability
78
* correctness
89
* @problem.severity recommendation
910
* @sub-severity low

python/ql/src/Statements/BreakOrReturnInFinally.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* @description Using a Break or Return statement in a finally block causes the
44
* Try-finally block to exit, discarding the exception.
55
* @kind problem
6-
* @tags reliability
7-
* maintainability
6+
* @tags quality
7+
* reliability
8+
* error-handling
9+
* correctness
810
* external/cwe/cwe-584
911
* @problem.severity warning
1012
* @sub-severity low

0 commit comments

Comments
 (0)