Merge pull request #20402 from michaelnebel/python/code-quality-extended

Python: Add most `medium` precision queries to the `code-quality-extended` suite.
This commit is contained in:
Michael Nebel
2025-09-17 13:48:35 +02:00
committed by GitHub
17 changed files with 55 additions and 32 deletions

View File

@@ -1,11 +1,7 @@
ql/python/ql/src/AlertSuppression.ql
ql/python/ql/src/Classes/MaybeUndefinedClassAttribute.ql
ql/python/ql/src/Classes/ShouldBeContextManager.ql
ql/python/ql/src/Classes/UndefinedClassAttribute.ql
ql/python/ql/src/Classes/UselessClass.ql
ql/python/ql/src/Expressions/NonPortableComparisonUsingIs.ql
ql/python/ql/src/Filters/ClassifyFiles.ql
ql/python/ql/src/Functions/ReturnValueIgnored.ql
ql/python/ql/src/Imports/ImportShadowedByLoopVar.ql
ql/python/ql/src/Imports/ImportStarUsed.ql
ql/python/ql/src/Imports/Imports.ql
@@ -59,16 +55,12 @@ ql/python/ql/src/Metrics/TransitiveImports.ql
ql/python/ql/src/Security/CWE-020-ExternalAPIs/ExternalAPIsUsedWithUntrustedData.ql
ql/python/ql/src/Security/CWE-020-ExternalAPIs/UntrustedDataToExternalAPI.ql
ql/python/ql/src/Security/CWE-798/HardcodedCredentials.ql
ql/python/ql/src/Statements/AssertLiteralConstant.ql
ql/python/ql/src/Statements/C_StyleParentheses.ql
ql/python/ql/src/Statements/DocStrings.ql
ql/python/ql/src/Statements/ExecUsed.ql
ql/python/ql/src/Statements/StringConcatenationInLoop.ql
ql/python/ql/src/Variables/Global.ql
ql/python/ql/src/Variables/ShadowBuiltin.ql
ql/python/ql/src/Variables/ShadowGlobal.ql
ql/python/ql/src/Variables/UndefinedGlobal.ql
ql/python/ql/src/Variables/UnusedParameter.ql
ql/python/ql/src/analysis/CallGraphEfficiency.ql
ql/python/ql/src/analysis/CallGraphMarginalEfficiency.ql
ql/python/ql/src/analysis/Consistency.ql

View File

@@ -10,7 +10,10 @@ ql/python/ql/src/Classes/DefineEqualsWhenAddingAttributes.ql
ql/python/ql/src/Classes/InconsistentMRO.ql
ql/python/ql/src/Classes/InitCallsSubclass/InitCallsSubclassMethod.ql
ql/python/ql/src/Classes/MutatingDescriptor.ql
ql/python/ql/src/Classes/OverwritingAttributeInSuperClass.ql
ql/python/ql/src/Classes/ShouldBeContextManager.ql
ql/python/ql/src/Classes/SubclassShadowing/SubclassShadowing.ql
ql/python/ql/src/Classes/UselessClass.ql
ql/python/ql/src/Classes/WrongNameForArgumentInClassInstantiation.ql
ql/python/ql/src/Classes/WrongNumberArgumentsInClassInstantiation.ql
ql/python/ql/src/Exceptions/CatchingBaseException.ql
@@ -37,6 +40,7 @@ ql/python/ql/src/Expressions/Formatting/WrongNumberArgumentsFor3101Format.ql
ql/python/ql/src/Expressions/HashedButNoHash.ql
ql/python/ql/src/Expressions/IncorrectComparisonUsingIs.ql
ql/python/ql/src/Expressions/NonCallableCalled.ql
ql/python/ql/src/Expressions/NonPortableComparisonUsingIs.ql
ql/python/ql/src/Expressions/Regex/BackspaceEscape.ql
ql/python/ql/src/Expressions/Regex/DuplicateCharacterInSet.ql
ql/python/ql/src/Expressions/Regex/MissingPartSpecialGroup.ql
@@ -61,10 +65,12 @@ ql/python/ql/src/Functions/NonCls.ql
ql/python/ql/src/Functions/NonSelf.ql
ql/python/ql/src/Functions/OverlyComplexDelMethod.ql
ql/python/ql/src/Functions/ReturnConsistentTupleSizes.ql
ql/python/ql/src/Functions/ReturnValueIgnored.ql
ql/python/ql/src/Functions/SignatureOverriddenMethod.ql
ql/python/ql/src/Functions/SignatureSpecialMethods.ql
ql/python/ql/src/Functions/UseImplicitNoneReturnValue.ql
ql/python/ql/src/Imports/EncodingError.ql
ql/python/ql/src/Imports/FromImportOfMutableAttribute.ql
ql/python/ql/src/Imports/ImportandImportFrom.ql
ql/python/ql/src/Imports/ModuleImportsItself.ql
ql/python/ql/src/Imports/MultipleImports.ql
@@ -73,7 +79,9 @@ ql/python/ql/src/Imports/UnintentionalImport.ql
ql/python/ql/src/Imports/UnusedImport.ql
ql/python/ql/src/Lexical/CommentedOutCode.ql
ql/python/ql/src/Resources/FileNotAlwaysClosed.ql
ql/python/ql/src/Statements/AssertLiteralConstant.ql
ql/python/ql/src/Statements/AssertOnTuple.ql
ql/python/ql/src/Statements/BreakOrReturnInFinally.ql
ql/python/ql/src/Statements/ConstantInConditional.ql
ql/python/ql/src/Statements/IterableStringOrSequence.ql
ql/python/ql/src/Statements/MismatchInMultipleAssignment.ql
@@ -82,6 +90,7 @@ ql/python/ql/src/Statements/NestedLoopsSameVariable.ql
ql/python/ql/src/Statements/NestedLoopsSameVariableWithReuse.ql
ql/python/ql/src/Statements/NonIteratorInForLoop.ql
ql/python/ql/src/Statements/RedundantAssignment.ql
ql/python/ql/src/Statements/ReturnOrYieldOutsideFunction.ql
ql/python/ql/src/Statements/ShouldUseWithStatement.ql
ql/python/ql/src/Statements/SideEffectInAssert.ql
ql/python/ql/src/Statements/StatementNoEffect.ql
@@ -95,7 +104,12 @@ ql/python/ql/src/Testing/ImpreciseAssert.ql
ql/python/ql/src/Variables/GlobalAtModuleLevel.ql
ql/python/ql/src/Variables/LoopVariableCapture/LoopVariableCapture.ql
ql/python/ql/src/Variables/MultiplyDefined.ql
ql/python/ql/src/Variables/ShadowBuiltin.ql
ql/python/ql/src/Variables/ShadowGlobal.ql
ql/python/ql/src/Variables/SuspiciousUnusedLoopIterationVariable.ql
ql/python/ql/src/Variables/UndefinedExport.ql
ql/python/ql/src/Variables/UndefinedPlaceHolder.ql
ql/python/ql/src/Variables/UninitializedLocal.ql
ql/python/ql/src/Variables/UnusedLocalVariable.ql
ql/python/ql/src/Variables/UnusedModuleVariable.ql
ql/python/ql/src/Variables/UnusedParameter.ql

View File

@@ -2,9 +2,9 @@
* @name Overwriting attribute in super-class or sub-class
* @description Assignment to self attribute overwrites attribute previously defined in subclass or superclass `__init__` method.
* @kind problem
* @tags reliability
* maintainability
* modularity
* @tags quality
* reliability
* correctness
* @problem.severity warning
* @sub-severity low
* @precision medium

View File

@@ -3,9 +3,10 @@
* @description Making a class a context manager allows instances to be used in a 'with' statement.
* This improves resource handling and code readability.
* @kind problem
* @tags maintainability
* @tags quality
* maintainability
* readability
* convention
* performance
* @problem.severity recommendation
* @sub-severity high
* @precision medium

View File

@@ -2,8 +2,10 @@
* @name Useless class
* @description Class only defines one public method (apart from `__init__` or `__new__`) and should be replaced by a function
* @kind problem
* @tags maintainability
* @tags quality
* maintainability
* useless-code
* complexity
* @problem.severity recommendation
* @sub-severity low
* @precision medium

View File

@@ -2,8 +2,9 @@
* @name Non-portable comparison using is when operands support `__eq__`
* @description Comparison using 'is' when equivalence is not the same as identity and may not be portable.
* @kind problem
* @tags portability
* maintainability
* @tags quality
* reliability
* correctness
* @problem.severity recommendation
* @sub-severity low
* @precision medium

View File

@@ -2,11 +2,10 @@
* @name Ignored return value
* @description Ignoring return values may result in discarding errors or loss of information.
* @kind problem
* @tags reliability
* @tags quality
* reliability
* correctness
* readability
* convention
* statistical
* non-attributable
* external/cwe/cwe-252
* @problem.severity recommendation
* @sub-severity high

View File

@@ -2,9 +2,9 @@
* @name Importing value of mutable attribute
* @description Importing the value of a mutable attribute directly means that changes in global state will not be observed locally.
* @kind problem
* @tags reliability
* maintainability
* modularity
* @tags quality
* reliability
* correctness
* @problem.severity warning
* @sub-severity high
* @precision medium

View File

@@ -3,7 +3,8 @@
* @description An assert statement testing a literal constant value may exhibit
* different behavior when optimizations are enabled.
* @kind problem
* @tags reliability
* @tags quality
* reliability
* correctness
* @problem.severity recommendation
* @sub-severity low

View File

@@ -3,8 +3,10 @@
* @description Using a Break or Return statement in a finally block causes the
* Try-finally block to exit, discarding the exception.
* @kind problem
* @tags reliability
* maintainability
* @tags quality
* reliability
* error-handling
* correctness
* external/cwe/cwe-584
* @problem.severity warning
* @sub-severity low

View File

@@ -4,6 +4,7 @@
* makes it more difficult for other developers to maintain the code.
* @kind problem
* @tags maintainability
* readability
* @problem.severity recommendation
* @sub-severity low
* @precision medium

View File

@@ -2,7 +2,8 @@
* @name Use of 'return' or 'yield' outside a function
* @description Using 'return' or 'yield' outside a function causes a 'SyntaxError' at runtime.
* @kind problem
* @tags reliability
* @tags quality
* reliability
* correctness
* @problem.severity error
* @sub-severity low

View File

@@ -4,8 +4,10 @@
* makes the built-in object unusable within the current scope and makes the code
* more difficult to read.
* @kind problem
* @tags maintainability
* @tags quality
* maintainability
* readability
* correctness
* @problem.severity recommendation
* @sub-severity low
* @precision medium

View File

@@ -4,8 +4,10 @@
* makes the global variable unusable within the current scope and makes the code
* more difficult to read.
* @kind problem
* @tags maintainability
* @tags quality
* maintainability
* readability
* correctness
* @problem.severity recommendation
* @sub-severity low
* @precision medium

View File

@@ -2,7 +2,8 @@
* @name Use of an undefined placeholder variable
* @description Using a variable before it is initialized causes an exception.
* @kind problem
* @tags reliability
* @tags quality
* reliability
* correctness
* @problem.severity error
* @sub-severity low

View File

@@ -2,7 +2,8 @@
* @name Potentially uninitialized local variable
* @description Using a local variable before it is initialized causes an UnboundLocalError.
* @kind problem
* @tags reliability
* @tags quality
* reliability
* correctness
* @problem.severity error
* @sub-severity low

View File

@@ -2,7 +2,10 @@
* @name Unused parameter
* @description Parameter is defined but not used
* @kind problem
* @tags maintainability
* @tags quality
* reliability
* correctness
* readability
* @problem.severity recommendation
* @sub-severity high
* @precision medium