diff --git a/python/ql/test/2/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref b/python/ql/test/2/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref index e2e9a180ab1..f43176f3d7a 100644 --- a/python/ql/test/2/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref +++ b/python/ql/test/2/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref @@ -1,2 +1 @@ -query: Classes/InconsistentMRO.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/InconsistentMRO.ql \ No newline at end of file diff --git a/python/ql/test/2/query-tests/Classes/inconsistent-mro/inconsistent_mro.py b/python/ql/test/2/query-tests/Classes/inconsistent-mro/inconsistent_mro.py index a8e76c6bfb1..34677864834 100644 --- a/python/ql/test/2/query-tests/Classes/inconsistent-mro/inconsistent_mro.py +++ b/python/ql/test/2/query-tests/Classes/inconsistent-mro/inconsistent_mro.py @@ -6,7 +6,7 @@ class X(object): class Y(X): pass -class Z(X, Y): # $ Alert +class Z(X, Y): pass class O: diff --git a/python/ql/test/2/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref b/python/ql/test/2/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref index 35f6da7add5..d4986ffc84c 100644 --- a/python/ql/test/2/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref +++ b/python/ql/test/2/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/MaybeUndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/MaybeUndefinedClassAttribute.ql diff --git a/python/ql/test/2/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref b/python/ql/test/2/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref index f0e8fb72278..7ac0a3b18b7 100644 --- a/python/ql/test/2/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref +++ b/python/ql/test/2/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/UndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/UndefinedClassAttribute.ql diff --git a/python/ql/test/2/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref b/python/ql/test/2/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref index 7a7911ca440..6d49710a759 100644 --- a/python/ql/test/2/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref +++ b/python/ql/test/2/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref @@ -1,2 +1 @@ -query: Exceptions/IllegalExceptionHandlerType.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Exceptions/IllegalExceptionHandlerType.ql \ No newline at end of file diff --git a/python/ql/test/2/query-tests/Exceptions/general/IllegalRaise.qlref b/python/ql/test/2/query-tests/Exceptions/general/IllegalRaise.qlref index 2bee772260a..5a515d5656d 100644 --- a/python/ql/test/2/query-tests/Exceptions/general/IllegalRaise.qlref +++ b/python/ql/test/2/query-tests/Exceptions/general/IllegalRaise.qlref @@ -1,2 +1 @@ -query: Exceptions/IllegalRaise.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Exceptions/IllegalRaise.ql \ No newline at end of file diff --git a/python/ql/test/2/query-tests/Exceptions/general/exceptions_test.py b/python/ql/test/2/query-tests/Exceptions/general/exceptions_test.py index 023b490eaae..6e82bc02890 100644 --- a/python/ql/test/2/query-tests/Exceptions/general/exceptions_test.py +++ b/python/ql/test/2/query-tests/Exceptions/general/exceptions_test.py @@ -14,4 +14,4 @@ def raise_tuple(cond): raise (Exception, "bananas", 17) else: #This is an error - raise (17, "bananas", Exception) # $ Alert[py/illegal-raise] + raise (17, "bananas", Exception) diff --git a/python/ql/test/2/query-tests/Expressions/TruncatedDivision.qlref b/python/ql/test/2/query-tests/Expressions/TruncatedDivision.qlref index 17d539c3226..fa2c2cbf006 100644 --- a/python/ql/test/2/query-tests/Expressions/TruncatedDivision.qlref +++ b/python/ql/test/2/query-tests/Expressions/TruncatedDivision.qlref @@ -1,2 +1 @@ -query: Expressions/TruncatedDivision.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/TruncatedDivision.ql diff --git a/python/ql/test/2/query-tests/Expressions/TruncatedDivision_test.py b/python/ql/test/2/query-tests/Expressions/TruncatedDivision_test.py index 64ef262edb8..6f265b824fb 100644 --- a/python/ql/test/2/query-tests/Expressions/TruncatedDivision_test.py +++ b/python/ql/test/2/query-tests/Expressions/TruncatedDivision_test.py @@ -62,14 +62,14 @@ print(average([1.0, 2.0])) # This case is bad, and is a minimal obvious case that should be bad. It # SHOULD be found by the query. -print(3 / 2) # $ Alert[py/truncated-division] +print(3 / 2) # This case is bad. It uses indirect returns of integers through function calls # to produce the problem. I -print(return_three() / return_two()) # $ Alert[py/truncated-division] +print(return_three() / return_two()) diff --git a/python/ql/test/2/query-tests/Statements/IterableStringOrSequence.qlref b/python/ql/test/2/query-tests/Statements/IterableStringOrSequence.qlref index c24806ccf30..e8f1ce1b79e 100644 --- a/python/ql/test/2/query-tests/Statements/IterableStringOrSequence.qlref +++ b/python/ql/test/2/query-tests/Statements/IterableStringOrSequence.qlref @@ -1,2 +1 @@ -query: Statements/IterableStringOrSequence.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/IterableStringOrSequence.ql \ No newline at end of file diff --git a/python/ql/test/2/query-tests/Statements/statements_test.py b/python/ql/test/2/query-tests/Statements/statements_test.py index 729b1fd7616..46e91c25c31 100644 --- a/python/ql/test/2/query-tests/Statements/statements_test.py +++ b/python/ql/test/2/query-tests/Statements/statements_test.py @@ -18,7 +18,7 @@ def f(x): s = u"Hello World" else: s = [ u'Hello', u'World'] - for thing in s: # $ Alert[py/iteration-string-and-sequence] + for thing in s: print (thing) import fake_six diff --git a/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.py b/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.py index 847d0ce4f8e..d7ec86a2256 100644 --- a/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.py +++ b/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.py @@ -1,6 +1,6 @@ -__all__ = [ "x", "y", "z", "module" ] # $ Alert[py/undefined-export] +__all__ = [ "x", "y", "z", "module" ] x = 1 if 0: diff --git a/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.qlref b/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.qlref index d964148077e..3e5d31e4748 100644 --- a/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.qlref +++ b/python/ql/test/2/query-tests/Variables/undefined/UndefinedExport.qlref @@ -1,2 +1 @@ -query: Variables/UndefinedExport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UndefinedExport.ql diff --git a/python/ql/test/2/query-tests/Variables/undefined/UndefinedGlobal.qlref b/python/ql/test/2/query-tests/Variables/undefined/UndefinedGlobal.qlref index e69631e746b..ea9f5a03842 100644 --- a/python/ql/test/2/query-tests/Variables/undefined/UndefinedGlobal.qlref +++ b/python/ql/test/2/query-tests/Variables/undefined/UndefinedGlobal.qlref @@ -1,2 +1 @@ -query: Variables/UndefinedGlobal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UndefinedGlobal.ql diff --git a/python/ql/test/2/query-tests/Variables/undefined/UninitializedLocal.qlref b/python/ql/test/2/query-tests/Variables/undefined/UninitializedLocal.qlref index 90233ce6188..f2d0e603554 100644 --- a/python/ql/test/2/query-tests/Variables/undefined/UninitializedLocal.qlref +++ b/python/ql/test/2/query-tests/Variables/undefined/UninitializedLocal.qlref @@ -1,2 +1 @@ -query: Variables/UninitializedLocal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UninitializedLocal.ql diff --git a/python/ql/test/2/query-tests/Variables/undefined/package/__init__.py b/python/ql/test/2/query-tests/Variables/undefined/package/__init__.py index d0f80d5e890..85f1f2ac24f 100644 --- a/python/ql/test/2/query-tests/Variables/undefined/package/__init__.py +++ b/python/ql/test/2/query-tests/Variables/undefined/package/__init__.py @@ -1 +1 @@ -__all__ = [ "module", "not_exists" ] # $ Alert[py/undefined-export] \ No newline at end of file +__all__ = [ "module", "not_exists" ] \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref b/python/ql/test/3/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref index f3385f506bf..e542a6176ad 100644 --- a/python/ql/test/3/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref +++ b/python/ql/test/3/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref @@ -1,2 +1 @@ -query: Classes/DefineEqualsWhenAddingAttributes.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/DefineEqualsWhenAddingAttributes.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Classes/equals-attr/test.py b/python/ql/test/3/query-tests/Classes/equals-attr/test.py index b6f3e0eb3be..0ab18d0ad43 100644 --- a/python/ql/test/3/query-tests/Classes/equals-attr/test.py +++ b/python/ql/test/3/query-tests/Classes/equals-attr/test.py @@ -9,7 +9,7 @@ class RedefineEquals: def __eq__(self, other): return other is "Tuesday" -class C(RedefineEquals): # $ Alert +class C(RedefineEquals): def __init__(self, args): self.a, self.b = args diff --git a/python/ql/test/3/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref b/python/ql/test/3/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref index e2e9a180ab1..f43176f3d7a 100644 --- a/python/ql/test/3/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref +++ b/python/ql/test/3/query-tests/Classes/inconsistent-mro/InconsistentMRO.qlref @@ -1,2 +1 @@ -query: Classes/InconsistentMRO.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/InconsistentMRO.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Classes/inconsistent-mro/inconsistent_mro.py b/python/ql/test/3/query-tests/Classes/inconsistent-mro/inconsistent_mro.py index 9cb04f1df97..34677864834 100644 --- a/python/ql/test/3/query-tests/Classes/inconsistent-mro/inconsistent_mro.py +++ b/python/ql/test/3/query-tests/Classes/inconsistent-mro/inconsistent_mro.py @@ -6,12 +6,12 @@ class X(object): class Y(X): pass -class Z(X, Y): # $ Alert +class Z(X, Y): pass class O: pass #This is OK in Python 2 -class N(object, O): # $ Alert +class N(object, O): pass \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref b/python/ql/test/3/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref index 35f6da7add5..d4986ffc84c 100644 --- a/python/ql/test/3/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref +++ b/python/ql/test/3/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/MaybeUndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/MaybeUndefinedClassAttribute.ql diff --git a/python/ql/test/3/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref b/python/ql/test/3/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref index f0e8fb72278..7ac0a3b18b7 100644 --- a/python/ql/test/3/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref +++ b/python/ql/test/3/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/UndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/UndefinedClassAttribute.ql diff --git a/python/ql/test/3/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref b/python/ql/test/3/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref index c6b6ca3d30f..3599f204f55 100644 --- a/python/ql/test/3/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref +++ b/python/ql/test/3/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNameForArgumentInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNameForArgumentInCall.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref b/python/ql/test/3/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref index 68dc510d5c6..1bffe8f1cad 100644 --- a/python/ql/test/3/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref +++ b/python/ql/test/3/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNumberArgumentsInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNumberArgumentsInCall.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Expressions/Arguments/wrong_arguments.py b/python/ql/test/3/query-tests/Expressions/Arguments/wrong_arguments.py index 1242af144b6..729177ea0b4 100644 --- a/python/ql/test/3/query-tests/Expressions/Arguments/wrong_arguments.py +++ b/python/ql/test/3/query-tests/Expressions/Arguments/wrong_arguments.py @@ -9,8 +9,8 @@ f(1, 2, 3, kw1=1) f(1, 2, kw1=1, kw2=2) #Not OK -f(1, 2, 3, kw1=1, kw3=3) # $ Alert[py/call/wrong-named-argument] -f(1, 2, 3, kw3=3) # $ Alert[py/call/wrong-named-argument] +f(1, 2, 3, kw1=1, kw3=3) +f(1, 2, 3, kw3=3) #ODASA-5897 @@ -21,4 +21,4 @@ def ok(): return analyze_member_access(msg, original=original, chk=chk) def bad(): - return analyze_member_access(msg, original, chk=chk) # $ Alert[py/call/wrong-arguments] + return analyze_member_access(msg, original, chk=chk) diff --git a/python/ql/test/3/query-tests/Expressions/Formatting/WrongNumberArgumentsForFormat.qlref b/python/ql/test/3/query-tests/Expressions/Formatting/WrongNumberArgumentsForFormat.qlref index 744334a6aeb..0d127e1b618 100644 --- a/python/ql/test/3/query-tests/Expressions/Formatting/WrongNumberArgumentsForFormat.qlref +++ b/python/ql/test/3/query-tests/Expressions/Formatting/WrongNumberArgumentsForFormat.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNumberArgumentsForFormat.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNumberArgumentsForFormat.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Expressions/TruncatedDivision/TruncatedDivision.qlref b/python/ql/test/3/query-tests/Expressions/TruncatedDivision/TruncatedDivision.qlref index 17d539c3226..fa2c2cbf006 100644 --- a/python/ql/test/3/query-tests/Expressions/TruncatedDivision/TruncatedDivision.qlref +++ b/python/ql/test/3/query-tests/Expressions/TruncatedDivision/TruncatedDivision.qlref @@ -1,2 +1 @@ -query: Expressions/TruncatedDivision.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/TruncatedDivision.ql diff --git a/python/ql/test/3/query-tests/Statements/iter/IterableStringOrSequence.qlref b/python/ql/test/3/query-tests/Statements/iter/IterableStringOrSequence.qlref index c24806ccf30..e8f1ce1b79e 100644 --- a/python/ql/test/3/query-tests/Statements/iter/IterableStringOrSequence.qlref +++ b/python/ql/test/3/query-tests/Statements/iter/IterableStringOrSequence.qlref @@ -1,2 +1 @@ -query: Statements/IterableStringOrSequence.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/IterableStringOrSequence.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Statements/iter/NonIteratorInForLoop.qlref b/python/ql/test/3/query-tests/Statements/iter/NonIteratorInForLoop.qlref index b7697d64d8f..fb09cace29a 100644 --- a/python/ql/test/3/query-tests/Statements/iter/NonIteratorInForLoop.qlref +++ b/python/ql/test/3/query-tests/Statements/iter/NonIteratorInForLoop.qlref @@ -1,2 +1 @@ -query: Statements/NonIteratorInForLoop.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/NonIteratorInForLoop.ql \ No newline at end of file diff --git a/python/ql/test/3/query-tests/Statements/iter/async_iterator.py b/python/ql/test/3/query-tests/Statements/iter/async_iterator.py index 76972058a02..fdde931eace 100644 --- a/python/ql/test/3/query-tests/Statements/iter/async_iterator.py +++ b/python/ql/test/3/query-tests/Statements/iter/async_iterator.py @@ -23,5 +23,5 @@ async def good(): yield x async def bad(): - async for x in MissingAiter(): # $ Alert[py/non-iterable-in-for-loop] + async for x in MissingAiter(): yield x diff --git a/python/ql/test/3/query-tests/Statements/iter/statements_test.py b/python/ql/test/3/query-tests/Statements/iter/statements_test.py index daf811f3f83..33b3f4aae5c 100644 --- a/python/ql/test/3/query-tests/Statements/iter/statements_test.py +++ b/python/ql/test/3/query-tests/Statements/iter/statements_test.py @@ -18,7 +18,7 @@ def f(x): s = u"Hello World" else: s = [ u'Hello', u'World'] - for thing in s: # $ Alert[py/iteration-string-and-sequence] + for thing in s: print (thing) @@ -31,7 +31,7 @@ class Color(Enum): def colors(): for color in Color: print(color) - for color in 1: # $ Alert[py/non-iterable-in-for-loop] + for color in 1: print(color) colors() diff --git a/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.py b/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.py index 84a717c0314..fc1a03f6e1c 100644 --- a/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.py +++ b/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.py @@ -1,6 +1,6 @@ -__all__ = [ "x", "y", "z", "module", "w" ] # $ Alert[py/undefined-export] +__all__ = [ "x", "y", "z", "module", "w" ] x = 1 if 0: diff --git a/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.qlref b/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.qlref index d964148077e..3e5d31e4748 100644 --- a/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.qlref +++ b/python/ql/test/3/query-tests/Variables/undefined/UndefinedExport.qlref @@ -1,2 +1 @@ -query: Variables/UndefinedExport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UndefinedExport.ql diff --git a/python/ql/test/3/query-tests/Variables/undefined/UninitializedLocal.qlref b/python/ql/test/3/query-tests/Variables/undefined/UninitializedLocal.qlref index 90233ce6188..f2d0e603554 100644 --- a/python/ql/test/3/query-tests/Variables/undefined/UninitializedLocal.qlref +++ b/python/ql/test/3/query-tests/Variables/undefined/UninitializedLocal.qlref @@ -1,2 +1 @@ -query: Variables/UninitializedLocal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UninitializedLocal.ql diff --git a/python/ql/test/3/query-tests/Variables/undefined/enum_convert.py b/python/ql/test/3/query-tests/Variables/undefined/enum_convert.py index db6b89b8f7f..58979d0b4c9 100644 --- a/python/ql/test/3/query-tests/Variables/undefined/enum_convert.py +++ b/python/ql/test/3/query-tests/Variables/undefined/enum_convert.py @@ -5,4 +5,4 @@ IntEnum._convert( __name__, lambda C: C.isupper() and C.startswith('AF_')) -__all__ = [ "Maybe", "Maybe_not" ] # $ Alert[py/undefined-export] +__all__ = [ "Maybe", "Maybe_not" ] diff --git a/python/ql/test/3/query-tests/Variables/undefined/package/__init__.py b/python/ql/test/3/query-tests/Variables/undefined/package/__init__.py index d0f80d5e890..85f1f2ac24f 100644 --- a/python/ql/test/3/query-tests/Variables/undefined/package/__init__.py +++ b/python/ql/test/3/query-tests/Variables/undefined/package/__init__.py @@ -1 +1 @@ -__all__ = [ "module", "not_exists" ] # $ Alert[py/undefined-export] \ No newline at end of file +__all__ = [ "module", "not_exists" ] \ No newline at end of file diff --git a/python/ql/test/experimental/library-tests/CallGraph-implicit-init/InlineCallGraphTest.qlref b/python/ql/test/experimental/library-tests/CallGraph-implicit-init/InlineCallGraphTest.qlref index e7b837c8900..25117a4582b 100644 --- a/python/ql/test/experimental/library-tests/CallGraph-implicit-init/InlineCallGraphTest.qlref +++ b/python/ql/test/experimental/library-tests/CallGraph-implicit-init/InlineCallGraphTest.qlref @@ -1 +1 @@ -query: ../CallGraph/InlineCallGraphTest.ql +../CallGraph/InlineCallGraphTest.ql diff --git a/python/ql/test/experimental/library-tests/CallGraph-imports/InlineCallGraphTest.qlref b/python/ql/test/experimental/library-tests/CallGraph-imports/InlineCallGraphTest.qlref index e7b837c8900..25117a4582b 100644 --- a/python/ql/test/experimental/library-tests/CallGraph-imports/InlineCallGraphTest.qlref +++ b/python/ql/test/experimental/library-tests/CallGraph-imports/InlineCallGraphTest.qlref @@ -1 +1 @@ -query: ../CallGraph/InlineCallGraphTest.ql +../CallGraph/InlineCallGraphTest.ql diff --git a/python/ql/test/experimental/library-tests/CallGraph-type-annotations/InlineCallGraphTest.qlref b/python/ql/test/experimental/library-tests/CallGraph-type-annotations/InlineCallGraphTest.qlref index e7b837c8900..25117a4582b 100644 --- a/python/ql/test/experimental/library-tests/CallGraph-type-annotations/InlineCallGraphTest.qlref +++ b/python/ql/test/experimental/library-tests/CallGraph-type-annotations/InlineCallGraphTest.qlref @@ -1 +1 @@ -query: ../CallGraph/InlineCallGraphTest.ql +../CallGraph/InlineCallGraphTest.ql diff --git a/python/ql/test/query-tests/Classes/Arguments/WrongNameForArgumentInClassInstantiation.qlref b/python/ql/test/query-tests/Classes/Arguments/WrongNameForArgumentInClassInstantiation.qlref index e093d3ebd68..408766dcbf4 100644 --- a/python/ql/test/query-tests/Classes/Arguments/WrongNameForArgumentInClassInstantiation.qlref +++ b/python/ql/test/query-tests/Classes/Arguments/WrongNameForArgumentInClassInstantiation.qlref @@ -1,2 +1 @@ -query: Classes/WrongNameForArgumentInClassInstantiation.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/WrongNameForArgumentInClassInstantiation.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Classes/Arguments/WrongNumberArgumentsInClassInstantiation.qlref b/python/ql/test/query-tests/Classes/Arguments/WrongNumberArgumentsInClassInstantiation.qlref index cbf14318e59..4fdda20e163 100644 --- a/python/ql/test/query-tests/Classes/Arguments/WrongNumberArgumentsInClassInstantiation.qlref +++ b/python/ql/test/query-tests/Classes/Arguments/WrongNumberArgumentsInClassInstantiation.qlref @@ -1,2 +1 @@ -query: Classes/WrongNumberArgumentsInClassInstantiation.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/WrongNumberArgumentsInClassInstantiation.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Classes/Arguments/wrong_arguments.py b/python/ql/test/query-tests/Classes/Arguments/wrong_arguments.py index 5c03d0b0849..7363fdebef4 100644 --- a/python/ql/test/query-tests/Classes/Arguments/wrong_arguments.py +++ b/python/ql/test/query-tests/Classes/Arguments/wrong_arguments.py @@ -34,22 +34,22 @@ class F7(object): # Too few arguments -F0() # $ Alert[py/call/wrong-number-class-arguments] -F1() # $ Alert[py/call/wrong-number-class-arguments] -F2() # $ Alert[py/call/wrong-number-class-arguments] -F3() # $ Alert[py/call/wrong-number-class-arguments] -F4() # $ Alert[py/call/wrong-number-class-arguments] -F5() # $ Alert[py/call/wrong-number-class-arguments] -F6(1) # $ Alert[py/call/wrong-number-class-arguments] -F7(1,2) # $ Alert[py/call/wrong-number-class-arguments] +F0() +F1() +F2() +F3() +F4() +F5() +F6(1) +F7(1,2) #Too many arguments -F0(1,2) # $ Alert[py/call/wrong-number-class-arguments] -F1(1,2,3) # $ Alert[py/call/wrong-number-class-arguments] -F5(1,2,3) # $ Alert[py/call/wrong-number-class-arguments] -F6(1,2,3) # $ Alert[py/call/wrong-number-class-arguments] -F6(1,2,3,4) # $ Alert[py/call/wrong-number-class-arguments] +F0(1,2) +F1(1,2,3) +F5(1,2,3) +F6(1,2,3) +F6(1,2,3,4) #OK @@ -62,9 +62,9 @@ F2(1,2,3,4,5,6) #Illegal name -F0(y=1) # $ Alert[py/call/wrong-named-class-argument] -F1(z=1) # $ Alert[py/call/wrong-named-class-argument] -F2(x=0, y=1) # $ Alert[py/call/wrong-named-class-argument] +F0(y=1) +F1(z=1) +F2(x=0, y=1) #Ok name @@ -82,12 +82,12 @@ t3 = (1,2,3) f(*t2) #Too many -F6(*(1,2,3)) # $ Alert[py/call/wrong-number-class-arguments] -F6(*t3) # $ Alert[py/call/wrong-number-class-arguments] +F6(*(1,2,3)) +F6(*t3) #Ok F6(**{'x':1, 'y':2}) #Illegal name -F6(**{'x':1, 'y':2, 'z':3}) # $ Alert[py/call/wrong-named-class-argument] +F6(**{'x':1, 'y':2, 'z':3}) diff --git a/python/ql/test/query-tests/Classes/conflicting/ConflictingAttributesInBaseClasses.qlref b/python/ql/test/query-tests/Classes/conflicting/ConflictingAttributesInBaseClasses.qlref index efd0250ca2e..3d6fa6534c5 100644 --- a/python/ql/test/query-tests/Classes/conflicting/ConflictingAttributesInBaseClasses.qlref +++ b/python/ql/test/query-tests/Classes/conflicting/ConflictingAttributesInBaseClasses.qlref @@ -1,2 +1 @@ -query: Classes/ConflictingAttributesInBaseClasses.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/ConflictingAttributesInBaseClasses.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Classes/conflicting/test.py b/python/ql/test/query-tests/Classes/conflicting/test.py index 4bb75114034..624cea77ce5 100644 --- a/python/ql/test/query-tests/Classes/conflicting/test.py +++ b/python/ql/test/query-tests/Classes/conflicting/test.py @@ -23,7 +23,7 @@ class CB2(Common): return 0 -class Conflict(CB1, CB2): # $ Alert +class Conflict(CB1, CB2): pass class Override1(Common): diff --git a/python/ql/test/query-tests/Classes/descriptors/MutatingDescriptor.qlref b/python/ql/test/query-tests/Classes/descriptors/MutatingDescriptor.qlref index 17ec44acc88..08449405ad6 100644 --- a/python/ql/test/query-tests/Classes/descriptors/MutatingDescriptor.qlref +++ b/python/ql/test/query-tests/Classes/descriptors/MutatingDescriptor.qlref @@ -1,2 +1 @@ -query: Classes/MutatingDescriptor.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/MutatingDescriptor.ql diff --git a/python/ql/test/query-tests/Classes/descriptors/test.py b/python/ql/test/query-tests/Classes/descriptors/test.py index b33ae25440f..180ade50e36 100644 --- a/python/ql/test/query-tests/Classes/descriptors/test.py +++ b/python/ql/test/query-tests/Classes/descriptors/test.py @@ -7,7 +7,7 @@ class MutatingDescriptor(object): def __get__(self, obj, obj_type): #Modified state is visible to all instances. - self.my_obj = obj # $ Alert + self.my_obj = obj return self def __call__(self, *args): @@ -22,4 +22,4 @@ class MutatingDescriptor(object): def not_ok(self, value): #Modified state is visible to all instances. - self.my_obj = value # $ Alert + self.my_obj = value diff --git a/python/ql/test/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref b/python/ql/test/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref index f3385f506bf..e542a6176ad 100644 --- a/python/ql/test/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref +++ b/python/ql/test/query-tests/Classes/equals-attr/DefineEqualsWhenAddingAttributes.qlref @@ -1,2 +1 @@ -query: Classes/DefineEqualsWhenAddingAttributes.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/DefineEqualsWhenAddingAttributes.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Classes/equals-attr/attr_eq_test.py b/python/ql/test/query-tests/Classes/equals-attr/attr_eq_test.py index a5b1857f878..e1e545fe9ef 100644 --- a/python/ql/test/query-tests/Classes/equals-attr/attr_eq_test.py +++ b/python/ql/test/query-tests/Classes/equals-attr/attr_eq_test.py @@ -18,7 +18,7 @@ class Point(object): def __hash__(self): return hash((self._x, self._y)) -class BadColorPoint(Point): # $ Alert +class BadColorPoint(Point): def __init__(self, x, y, color): Point.__init__(self, x, y) diff --git a/python/ql/test/query-tests/Classes/overwriting-attribute/OverwritingAttributeInSuperClass.qlref b/python/ql/test/query-tests/Classes/overwriting-attribute/OverwritingAttributeInSuperClass.qlref index dcea036ee60..b29c4d25025 100644 --- a/python/ql/test/query-tests/Classes/overwriting-attribute/OverwritingAttributeInSuperClass.qlref +++ b/python/ql/test/query-tests/Classes/overwriting-attribute/OverwritingAttributeInSuperClass.qlref @@ -1,2 +1 @@ -query: Classes/OverwritingAttributeInSuperClass.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/OverwritingAttributeInSuperClass.ql diff --git a/python/ql/test/query-tests/Classes/overwriting-attribute/overwriting_attribute.py b/python/ql/test/query-tests/Classes/overwriting-attribute/overwriting_attribute.py index a17bfd662d8..0372db0b215 100644 --- a/python/ql/test/query-tests/Classes/overwriting-attribute/overwriting_attribute.py +++ b/python/ql/test/query-tests/Classes/overwriting-attribute/overwriting_attribute.py @@ -2,7 +2,7 @@ class C(object): def __init__(self): - self.var = 0 # $ Alert + self.var = 0 class D(C): @@ -20,4 +20,4 @@ class F(E): def __init__(self): E.__init__(self) - self.var = 1 # $ Alert + self.var = 1 diff --git a/python/ql/test/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref b/python/ql/test/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref index 35f6da7add5..d4986ffc84c 100644 --- a/python/ql/test/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref +++ b/python/ql/test/query-tests/Classes/undefined-attribute/MaybeUndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/MaybeUndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/MaybeUndefinedClassAttribute.ql diff --git a/python/ql/test/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref b/python/ql/test/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref index f0e8fb72278..7ac0a3b18b7 100644 --- a/python/ql/test/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref +++ b/python/ql/test/query-tests/Classes/undefined-attribute/UndefinedClassAttribute.qlref @@ -1,2 +1 @@ -query: Classes/UndefinedClassAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Classes/UndefinedClassAttribute.ql diff --git a/python/ql/test/query-tests/Classes/undefined-attribute/undefined_attribute.py b/python/ql/test/query-tests/Classes/undefined-attribute/undefined_attribute.py index 207e8f837d6..0eec9974ef1 100644 --- a/python/ql/test/query-tests/Classes/undefined-attribute/undefined_attribute.py +++ b/python/ql/test/query-tests/Classes/undefined-attribute/undefined_attribute.py @@ -21,10 +21,10 @@ class Attributes(object): print (self.local_exists) def neca1(self): - print (self.not_exists) # $ Alert[py/undefined-attribute] + print (self.not_exists) def neca2(self): - print (self.may_exist) # $ Alert[py/maybe-undefined-attribute] + print (self.may_exist) #This is OK class SetViaDict(object): @@ -106,7 +106,7 @@ class DecoratedInit(object): class NoInit(object): def use_y(self): - return self.y # $ Alert[py/undefined-attribute] + return self.y #This is also OK class SetLocally2(object): @@ -181,7 +181,7 @@ class Test1(object): self.return_queue = frame.method.queue def use_it(self): - return self.return_queue # $ Alert[py/maybe-undefined-attribute] + return self.return_queue #Check for FPs when overriding builtin methods @@ -247,15 +247,15 @@ class Customer1(object): class Odasa4619a(object): def call(self): - host = self.glance_host # $ Alert[py/undefined-attribute] - port = self.glance_port # $ Alert[py/undefined-attribute] + host = self.glance_host + port = self.glance_port class Odasa4619b(object): def call(self): - host = self.glance_host # $ Alert[py/maybe-undefined-attribute] - port = self.glance_port # $ Alert[py/maybe-undefined-attribute] + host = self.glance_host + port = self.glance_port @decorator def foo(self): diff --git a/python/ql/test/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref b/python/ql/test/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref index 7a7911ca440..6d49710a759 100644 --- a/python/ql/test/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref +++ b/python/ql/test/query-tests/Exceptions/general/IllegalExceptionHandlerType.qlref @@ -1,2 +1 @@ -query: Exceptions/IllegalExceptionHandlerType.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Exceptions/IllegalExceptionHandlerType.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Exceptions/general/IllegalRaise.qlref b/python/ql/test/query-tests/Exceptions/general/IllegalRaise.qlref index 2bee772260a..5a515d5656d 100644 --- a/python/ql/test/query-tests/Exceptions/general/IllegalRaise.qlref +++ b/python/ql/test/query-tests/Exceptions/general/IllegalRaise.qlref @@ -1,2 +1 @@ -query: Exceptions/IllegalRaise.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Exceptions/IllegalRaise.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Exceptions/general/exceptions_test.py b/python/ql/test/query-tests/Exceptions/general/exceptions_test.py index 2b2c2accf6e..81ec5b52302 100644 --- a/python/ql/test/query-tests/Exceptions/general/exceptions_test.py +++ b/python/ql/test/query-tests/Exceptions/general/exceptions_test.py @@ -37,21 +37,21 @@ class NotException2(object): pass def illegal_raise_type(): - raise NotException1 # $ Alert[py/illegal-raise] + raise NotException1 def illegal_raise_value1(): - raise "Exception" # $ Alert[py/illegal-raise] + raise "Exception" def illegal_raise_value2(): - raise NotException2() # $ Alert[py/illegal-raise] + raise NotException2() def illegal_handler(): try: illegal_raise() - except NotException1: # $ Alert[py/useless-except] + except NotException1: #Must do something print("NotException1") - except NotException2: # $ Alert[py/useless-except] + except NotException2: #Must do something print("NotException2") @@ -135,7 +135,7 @@ def a_number(): def illegal_handler2(): try: illegal_raise() - except a_number(): # $ Alert[py/useless-except] + except a_number(): print ("Caught exception") def stop_iter_ok(seq): diff --git a/python/ql/test/query-tests/Exceptions/general/pypy_test.py b/python/ql/test/query-tests/Exceptions/general/pypy_test.py index 12d373e428e..857e78d6d94 100644 --- a/python/ql/test/query-tests/Exceptions/general/pypy_test.py +++ b/python/ql/test/query-tests/Exceptions/general/pypy_test.py @@ -11,9 +11,10 @@ def test(): try: a = A() raise a - except 42: # $ Alert[py/useless-except] + except 42: #Some comment pass except A: #Another comment pass + diff --git a/python/ql/test/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref b/python/ql/test/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref index c6b6ca3d30f..3599f204f55 100644 --- a/python/ql/test/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref +++ b/python/ql/test/query-tests/Expressions/Arguments/WrongNameForArgumentInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNameForArgumentInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNameForArgumentInCall.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref b/python/ql/test/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref index 68dc510d5c6..1bffe8f1cad 100644 --- a/python/ql/test/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref +++ b/python/ql/test/query-tests/Expressions/Arguments/WrongNumberArgumentsInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNumberArgumentsInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNumberArgumentsInCall.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/Arguments/use_mox.py b/python/ql/test/query-tests/Expressions/Arguments/use_mox.py index 0af38ad3798..35d35574895 100644 --- a/python/ql/test/query-tests/Expressions/Arguments/use_mox.py +++ b/python/ql/test/query-tests/Expressions/Arguments/use_mox.py @@ -25,9 +25,9 @@ C.m1(1,2) #But normal functions are treated normally -f0() # $ Alert[py/call/wrong-arguments] -f1(1) # $ Alert[py/call/wrong-arguments] +f0() +f1(1) #As are normal methods -C().m0() # $ Alert[py/call/wrong-arguments] -C().m1(1) # $ Alert[py/call/wrong-arguments] +C().m0() +C().m1(1) diff --git a/python/ql/test/query-tests/Expressions/Arguments/wrong_arguments.py b/python/ql/test/query-tests/Expressions/Arguments/wrong_arguments.py index dffafbeee76..284d1d19bc3 100644 --- a/python/ql/test/query-tests/Expressions/Arguments/wrong_arguments.py +++ b/python/ql/test/query-tests/Expressions/Arguments/wrong_arguments.py @@ -26,22 +26,22 @@ def f7(x, y, z): # Too few arguments -f0() # $ Alert[py/call/wrong-arguments] -f1() # $ Alert[py/call/wrong-arguments] -f2() # $ Alert[py/call/wrong-arguments] -f3() # $ Alert[py/call/wrong-arguments] -f4() # $ Alert[py/call/wrong-arguments] -f5() # $ Alert[py/call/wrong-arguments] -f6(1) # $ Alert[py/call/wrong-arguments] -f7(1,2) # $ Alert[py/call/wrong-arguments] +f0() +f1() +f2() +f3() +f4() +f5() +f6(1) +f7(1,2) #Too many arguments -f0(1,2) # $ Alert[py/call/wrong-arguments] -f1(1,2,3) # $ Alert[py/call/wrong-arguments] -f5(1,2,3) # $ Alert[py/call/wrong-arguments] -f6(1,2,3) # $ Alert[py/call/wrong-arguments] -f6(1,2,3,4) # $ Alert[py/call/wrong-arguments] +f0(1,2) +f1(1,2,3) +f5(1,2,3) +f6(1,2,3) +f6(1,2,3,4) #OK @@ -54,9 +54,9 @@ f2(1,2,3,4,5,6) #Illegal name -f0(y=1) # $ Alert[py/call/wrong-named-argument] -f1(z=1) # $ Alert[py/call/wrong-named-argument] -f2(x=0, y=1) # $ Alert[py/call/wrong-named-argument] +f0(y=1) +f1(z=1) +f2(x=0, y=1) #Ok name @@ -78,12 +78,12 @@ l1d() l1d(1) #Too many -l0(1) # $ Alert[py/call/wrong-arguments] -l1(1,2) # $ Alert[py/call/wrong-arguments] -l1d(1,2) # $ Alert[py/call/wrong-arguments] +l0(1) +l1(1,2) +l1d(1,2) #Too few -l1() # $ Alert[py/call/wrong-arguments] +l1() t2 = (1,2) @@ -93,14 +93,14 @@ t3 = (1,2,3) f(*t2) #Too many -f6(*(1,2,3)) # $ Alert[py/call/wrong-arguments] -f6(*t3) # $ Alert[py/call/wrong-arguments] +f6(*(1,2,3)) +f6(*t3) #Ok f6(**{'x':1, 'y':2}) #Illegal name -f6(**{'x':1, 'y':2, 'z':3}) # $ Alert[py/call/wrong-named-argument] +f6(**{'x':1, 'y':2, 'z':3}) #Theoretically -1 arguments required. Don't report class C(object): @@ -112,7 +112,7 @@ C().f() #Too many and wrong name -- check only wrong name is flagged. -f1(x, y, z=1) # $ Alert[py/call/wrong-named-argument] +f1(x, y, z=1) #Overriding and call is wrong. @@ -127,5 +127,5 @@ class Eggs2(Eggs1): pass e = Eggs1() if cond else Eggs2() -e.spam(0) # $ Alert[py/call/wrong-arguments] +e.spam(0) diff --git a/python/ql/test/query-tests/Expressions/callable/NonCallableCalled.qlref b/python/ql/test/query-tests/Expressions/callable/NonCallableCalled.qlref index e26b890fde8..ea8577e6f9f 100644 --- a/python/ql/test/query-tests/Expressions/callable/NonCallableCalled.qlref +++ b/python/ql/test/query-tests/Expressions/callable/NonCallableCalled.qlref @@ -1,2 +1 @@ -query: Expressions/NonCallableCalled.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/NonCallableCalled.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/callable/test.py b/python/ql/test/query-tests/Expressions/callable/test.py index 3ccb238db3f..5498fba7292 100644 --- a/python/ql/test/query-tests/Expressions/callable/test.py +++ b/python/ql/test/query-tests/Expressions/callable/test.py @@ -13,9 +13,9 @@ class IsCallable(object): def call_non_callable(arg): non = NonCallable() - non(arg) # $ Alert - ()() # $ Alert - []() # $ Alert + non(arg) + ()() + []() dont_know = MaybeCallable() dont_know() # Not a violation ok = IsCallable() @@ -23,7 +23,7 @@ def call_non_callable(arg): if hasattr(non, "__call__"): non(arg) # OK due to guard if hasattr(non, "__init__"): - non(arg) # $ Alert # Not OK due to wrong guard + non(arg) # Not OK due to wrong guard import six @@ -44,7 +44,7 @@ def foo(): raise NotImplemented() def bar(): - return NotImplemented() # $ Alert + return NotImplemented() # FP due to decorator @@ -60,7 +60,7 @@ class Foo(object): @some_decorator @classmethod def new_instance(cls, new_arg): - return cls(new_arg) # $ SPURIOUS: Alert # TODO: FP + return cls(new_arg) # TODO: FP f1 = Foo(1) f2 = f1.new_instance(2) diff --git a/python/ql/test/query-tests/Expressions/eq/NonPortableComparisonUsingIs.qlref b/python/ql/test/query-tests/Expressions/eq/NonPortableComparisonUsingIs.qlref index a62a6a40f60..13c08534293 100644 --- a/python/ql/test/query-tests/Expressions/eq/NonPortableComparisonUsingIs.qlref +++ b/python/ql/test/query-tests/Expressions/eq/NonPortableComparisonUsingIs.qlref @@ -1,2 +1 @@ -query: Expressions/NonPortableComparisonUsingIs.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/NonPortableComparisonUsingIs.ql diff --git a/python/ql/test/query-tests/Expressions/eq/expressions_test.py b/python/ql/test/query-tests/Expressions/eq/expressions_test.py index 632616583c3..7c02b1fbc48 100644 --- a/python/ql/test/query-tests/Expressions/eq/expressions_test.py +++ b/python/ql/test/query-tests/Expressions/eq/expressions_test.py @@ -48,7 +48,7 @@ if "Hello World" is s: # $ Alert[py/comparison-using-is] #This is OK in CPython, but may not be portable s = str(7) -if "7" is s: # $ Alert[py/comparison-using-is-non-portable] +if "7" is s: print ("OK") #And some data flow diff --git a/python/ql/test/query-tests/Expressions/general/ContainsNonContainer.qlref b/python/ql/test/query-tests/Expressions/general/ContainsNonContainer.qlref index b52c39ed26d..71df405e72c 100644 --- a/python/ql/test/query-tests/Expressions/general/ContainsNonContainer.qlref +++ b/python/ql/test/query-tests/Expressions/general/ContainsNonContainer.qlref @@ -1,2 +1 @@ -query: Expressions/ContainsNonContainer.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/ContainsNonContainer.ql diff --git a/python/ql/test/query-tests/Expressions/general/ExpectedMappingForFormatString.qlref b/python/ql/test/query-tests/Expressions/general/ExpectedMappingForFormatString.qlref index fd322b848dc..83e92584ef2 100644 --- a/python/ql/test/query-tests/Expressions/general/ExpectedMappingForFormatString.qlref +++ b/python/ql/test/query-tests/Expressions/general/ExpectedMappingForFormatString.qlref @@ -1,2 +1 @@ -query: Expressions/ExpectedMappingForFormatString.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/ExpectedMappingForFormatString.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/general/HashedButNoHash.qlref b/python/ql/test/query-tests/Expressions/general/HashedButNoHash.qlref index f30fd92870f..ee53e367499 100644 --- a/python/ql/test/query-tests/Expressions/general/HashedButNoHash.qlref +++ b/python/ql/test/query-tests/Expressions/general/HashedButNoHash.qlref @@ -1,2 +1 @@ -query: Expressions/HashedButNoHash.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/HashedButNoHash.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/general/UnnecessaryLambda.qlref b/python/ql/test/query-tests/Expressions/general/UnnecessaryLambda.qlref index 9141c5e49a6..49b3873f83c 100644 --- a/python/ql/test/query-tests/Expressions/general/UnnecessaryLambda.qlref +++ b/python/ql/test/query-tests/Expressions/general/UnnecessaryLambda.qlref @@ -1,2 +1 @@ -query: Expressions/UnnecessaryLambda.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/UnnecessaryLambda.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/general/WrongNumberArgumentsForFormat.qlref b/python/ql/test/query-tests/Expressions/general/WrongNumberArgumentsForFormat.qlref index 744334a6aeb..0d127e1b618 100644 --- a/python/ql/test/query-tests/Expressions/general/WrongNumberArgumentsForFormat.qlref +++ b/python/ql/test/query-tests/Expressions/general/WrongNumberArgumentsForFormat.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNumberArgumentsForFormat.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNumberArgumentsForFormat.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Expressions/general/expressions_test.py b/python/ql/test/query-tests/Expressions/general/expressions_test.py index 71e0d1ba7cf..7be69bb7f98 100644 --- a/python/ql/test/query-tests/Expressions/general/expressions_test.py +++ b/python/ql/test/query-tests/Expressions/general/expressions_test.py @@ -8,9 +8,9 @@ def dup_key(): def simple_func(*args, **kwrgs): pass #Unnecessary lambdas -lambda arg0, arg1: simple_func(arg0, arg1) # $ Alert[py/unnecessary-lambda] -lambda arg0, *arg1: simple_func(arg0, *arg1) # $ Alert[py/unnecessary-lambda] -lambda arg0, **arg1: simple_func(arg0, **arg1) # $ Alert[py/unnecessary-lambda] +lambda arg0, arg1: simple_func(arg0, arg1) +lambda arg0, *arg1: simple_func(arg0, *arg1) +lambda arg0, **arg1: simple_func(arg0, **arg1) # these lambdas are_ necessary lambda arg0, arg1=1: simple_func(arg0, arg1) lambda arg0, arg1: simple_func(arg0, *arg1) @@ -39,7 +39,7 @@ x.__del__() # $ Alert[py/explicit-call-to-delete] #Unhashable object def func(): mapping = dict(); unhash = list() - return mapping[unhash] # $ Alert[py/hash-unhashable-value] + return mapping[unhash] #Using 'is' when should be using '==' s = "Hello " + "World" @@ -86,9 +86,9 @@ class XIter(object): def non_container(): seq = XIter() - if 1 in seq: # $ Alert[py/member-test-non-container] + if 1 in seq: pass - if 1 not in seq: # $ Alert[py/member-test-non-container] + if 1 not in seq: pass #Container inheriting from builtin @@ -138,15 +138,15 @@ class SubTest(Test): #Some more lambdas #Unnecessary lambdas -lambda arg0: len(arg0) # $ Alert[py/unnecessary-lambda] -lambda arg0: XIter.next(arg0) # $ Alert[py/unnecessary-lambda] +lambda arg0: len(arg0) +lambda arg0: XIter.next(arg0) class UL(object): def f(self, x): pass def g(self): - return lambda x: self.f(x) # $ Alert[py/unnecessary-lambda] + return lambda x: self.f(x) # these lambdas are necessary lambda arg0: XIter.next(arg0, arg1) diff --git a/python/ql/test/query-tests/Expressions/general/str_fmt_test.py b/python/ql/test/query-tests/Expressions/general/str_fmt_test.py index f7441ef9a8a..2bccc2253cc 100644 --- a/python/ql/test/query-tests/Expressions/general/str_fmt_test.py +++ b/python/ql/test/query-tests/Expressions/general/str_fmt_test.py @@ -2,16 +2,16 @@ def expected_mapping_for_fmt_string(): x = [ u'list', u'not', u'mapping' ] - print (u"%(name)s" % x) # $ Alert[py/percent-format/not-mapping] + print (u"%(name)s" % x) def unsupported_format_char(arg): print (u"%Z" % arg) # $ Alert[py/percent-format/unsupported-character] def wrong_arg_count_format(arg): - print(u"%s %s" % (arg, arg, 0)) # $ Alert[py/percent-format/wrong-arguments] + print(u"%s %s" % (arg, arg, 0)) format = u"%hd" args = (1, u'foo') - print(format % args) # $ Alert[py/percent-format/wrong-arguments] + print(format % args) def ok(): diff --git a/python/ql/test/query-tests/Functions/general/ExplicitReturnInInit.qlref b/python/ql/test/query-tests/Functions/general/ExplicitReturnInInit.qlref index df13334dcbf..a23550c4865 100644 --- a/python/ql/test/query-tests/Functions/general/ExplicitReturnInInit.qlref +++ b/python/ql/test/query-tests/Functions/general/ExplicitReturnInInit.qlref @@ -1,2 +1 @@ -query: Functions/ExplicitReturnInInit.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/ExplicitReturnInInit.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/general/IterReturnsNonIterator.qlref b/python/ql/test/query-tests/Functions/general/IterReturnsNonIterator.qlref index 14655b261d4..3d0965f7b11 100644 --- a/python/ql/test/query-tests/Functions/general/IterReturnsNonIterator.qlref +++ b/python/ql/test/query-tests/Functions/general/IterReturnsNonIterator.qlref @@ -1 +1 @@ -query: Functions/IterReturnsNonIterator.ql +Functions/IterReturnsNonIterator.ql diff --git a/python/ql/test/query-tests/Functions/general/OverlyComplexDelMethod.qlref b/python/ql/test/query-tests/Functions/general/OverlyComplexDelMethod.qlref index 90dba842c0e..601501aac30 100644 --- a/python/ql/test/query-tests/Functions/general/OverlyComplexDelMethod.qlref +++ b/python/ql/test/query-tests/Functions/general/OverlyComplexDelMethod.qlref @@ -1,2 +1 @@ -query: Functions/OverlyComplexDelMethod.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/OverlyComplexDelMethod.ql diff --git a/python/ql/test/query-tests/Functions/general/explicit_return_in_init.py b/python/ql/test/query-tests/Functions/general/explicit_return_in_init.py index 9024b13aa78..1c26e5f31e5 100644 --- a/python/ql/test/query-tests/Functions/general/explicit_return_in_init.py +++ b/python/ql/test/query-tests/Functions/general/explicit_return_in_init.py @@ -1,7 +1,7 @@ class ExplicitReturnInInit(object): def __init__(self): - return self # $ Alert[py/explicit-return-in-init] + return self # These are OK class ExplicitReturnNoneInInit(object): @@ -99,4 +99,4 @@ class InitReturnsCallResult6(object): p = procedure_implicit_none() else: p = not_ok - return p() # $ Alert[py/explicit-return-in-init] + return p() diff --git a/python/ql/test/query-tests/Functions/general/protocols.py b/python/ql/test/query-tests/Functions/general/protocols.py index 68f0aaf29c0..dd12fc3ed40 100644 --- a/python/ql/test/query-tests/Functions/general/protocols.py +++ b/python/ql/test/query-tests/Functions/general/protocols.py @@ -71,7 +71,7 @@ class AlmostIterable(object): class MegaDel(object): - def __del__(self): # $ Alert[py/overly-complex-delete] + def __del__(self): a = self.x + self.y if a: print(a) diff --git a/python/ql/test/query-tests/Functions/overriding/IncorrectlyOverriddenMethod.qlref b/python/ql/test/query-tests/Functions/overriding/IncorrectlyOverriddenMethod.qlref index 9d5a8324c79..d1637c1f1d3 100644 --- a/python/ql/test/query-tests/Functions/overriding/IncorrectlyOverriddenMethod.qlref +++ b/python/ql/test/query-tests/Functions/overriding/IncorrectlyOverriddenMethod.qlref @@ -1,2 +1 @@ -query: Functions/IncorrectlyOverriddenMethod.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/IncorrectlyOverriddenMethod.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/overriding/IncorrectlySpecifiedOverriddenMethod.qlref b/python/ql/test/query-tests/Functions/overriding/IncorrectlySpecifiedOverriddenMethod.qlref index 258840b2fc4..8a07cb1297e 100644 --- a/python/ql/test/query-tests/Functions/overriding/IncorrectlySpecifiedOverriddenMethod.qlref +++ b/python/ql/test/query-tests/Functions/overriding/IncorrectlySpecifiedOverriddenMethod.qlref @@ -1,2 +1 @@ -query: Functions/IncorrectlySpecifiedOverriddenMethod.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/IncorrectlySpecifiedOverriddenMethod.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/overriding/WrongNameForArgumentInCall.qlref b/python/ql/test/query-tests/Functions/overriding/WrongNameForArgumentInCall.qlref index c6b6ca3d30f..3599f204f55 100644 --- a/python/ql/test/query-tests/Functions/overriding/WrongNameForArgumentInCall.qlref +++ b/python/ql/test/query-tests/Functions/overriding/WrongNameForArgumentInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNameForArgumentInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNameForArgumentInCall.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/overriding/WrongNumberArgumentsInCall.qlref b/python/ql/test/query-tests/Functions/overriding/WrongNumberArgumentsInCall.qlref index 68dc510d5c6..1bffe8f1cad 100644 --- a/python/ql/test/query-tests/Functions/overriding/WrongNumberArgumentsInCall.qlref +++ b/python/ql/test/query-tests/Functions/overriding/WrongNumberArgumentsInCall.qlref @@ -1,2 +1 @@ -query: Expressions/WrongNumberArgumentsInCall.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Expressions/WrongNumberArgumentsInCall.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/overriding/test.py b/python/ql/test/query-tests/Functions/overriding/test.py index 64056370046..879efdbe291 100644 --- a/python/ql/test/query-tests/Functions/overriding/test.py +++ b/python/ql/test/query-tests/Functions/overriding/test.py @@ -2,10 +2,10 @@ class Base(object): - def meth1(self): # $ Alert[py/inheritance/incorrect-overridden-signature] + def meth1(self): pass - def meth2(self, spam): # $ Alert[py/inheritance/incorrect-overridden-signature] + def meth2(self, spam): pass def meth3(self): @@ -13,18 +13,18 @@ class Base(object): def foo(self): self.meth1() - self.meth1(0) # $ Alert[py/call/wrong-arguments] - self.meth2() # $ Alert[py/call/wrong-arguments] + self.meth1(0) + self.meth2() self.meth2(0) - self.meth1(spam="eggs") # $ Alert[py/call/wrong-named-argument] + self.meth1(spam="eggs") self.meth2(spam="eggs") class Derived(Base): - def meth1(self, spam): # $ Alert[py/inheritance/signature-mismatch] Alert[py/inheritance/incorrect-overriding-signature] # Has 1 more arg, base called in Base.foo + def meth1(self, spam): # $ Alert[py/inheritance/signature-mismatch] # Has 1 more arg, base called in Base.foo pass - def meth2(self): # $ Alert[py/inheritance/signature-mismatch] Alert[py/inheritance/incorrect-overriding-signature] # Has 1 fewer arg, base called in Base.foo + def meth2(self): # $ Alert[py/inheritance/signature-mismatch] # Has 1 fewer arg, base called in Base.foo pass def meth3(self, eggs): # $ Alert[py/inheritance/signature-mismatch] # Has 1 more arg. Method is not called. @@ -61,7 +61,7 @@ x.meth("hi") class BlameBase(object): - def meth(self): # $ Alert[py/inheritance/incorrect-overridden-signature] + def meth(self): pass class Correct1(BlameBase): @@ -109,7 +109,7 @@ class Base2: self.meth1() self.meth1(x=2) self.meth3() - self.meth3(x=2) # $ Alert[py/call/wrong-named-argument] + self.meth3(x=2) self.meth6(2, 3, 4) self.meth7() self.meth8(1,y=3) diff --git a/python/ql/test/query-tests/Functions/return_values/ConsistentReturns.qlref b/python/ql/test/query-tests/Functions/return_values/ConsistentReturns.qlref index 6f10808f42b..0904074f25b 100644 --- a/python/ql/test/query-tests/Functions/return_values/ConsistentReturns.qlref +++ b/python/ql/test/query-tests/Functions/return_values/ConsistentReturns.qlref @@ -1,2 +1 @@ -query: Functions/ConsistentReturns.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/ConsistentReturns.ql diff --git a/python/ql/test/query-tests/Functions/return_values/ReturnValueIgnored.qlref b/python/ql/test/query-tests/Functions/return_values/ReturnValueIgnored.qlref index ded6bf8e609..61002533ef4 100644 --- a/python/ql/test/query-tests/Functions/return_values/ReturnValueIgnored.qlref +++ b/python/ql/test/query-tests/Functions/return_values/ReturnValueIgnored.qlref @@ -1,2 +1 @@ -query: Functions/ReturnValueIgnored.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/ReturnValueIgnored.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/return_values/UseImplicitNoneReturnValue.qlref b/python/ql/test/query-tests/Functions/return_values/UseImplicitNoneReturnValue.qlref index af71ab6388e..b23115e8950 100644 --- a/python/ql/test/query-tests/Functions/return_values/UseImplicitNoneReturnValue.qlref +++ b/python/ql/test/query-tests/Functions/return_values/UseImplicitNoneReturnValue.qlref @@ -1,2 +1 @@ -query: Functions/UseImplicitNoneReturnValue.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Functions/UseImplicitNoneReturnValue.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Functions/return_values/functions_test.py b/python/ql/test/query-tests/Functions/return_values/functions_test.py index 8a8e947e84d..fdd89275761 100644 --- a/python/ql/test/query-tests/Functions/return_values/functions_test.py +++ b/python/ql/test/query-tests/Functions/return_values/functions_test.py @@ -15,11 +15,11 @@ def ok2(x): else: return "Hi" -def cr1(x): # $ Alert[py/mixed-returns] +def cr1(x): if x: return 4 -def cr2(x): # $ Alert[py/mixed-returns] +def cr2(x): if x: return 4 else: @@ -74,7 +74,7 @@ def ok4(x): def use_implicit_return_value(arg): - x = do_nothing() # $ Alert[py/procedure-return-value-used] + x = do_nothing() return call_non_callable(arg) #The return in the lambda is OK as it is auto-generated @@ -156,9 +156,9 @@ def do_nothing(): def return_value_ignored(): - ok2() # $ Alert[py/ignored-return-value] - ok4() # $ Alert[py/ignored-return-value] - sorted([1,2]) # $ Alert[py/ignored-return-value] + ok2() + ok4() + sorted([1,2]) d = {} @@ -231,7 +231,7 @@ def mutli_return(arg): if arg: return do_something() else: - return do_nothing() # $ Alert[py/procedure-return-value-used] + return do_nothing() #Modification of parameter with default @@ -333,7 +333,7 @@ def mismatched_multi_assign(x): return a,b -def ok_match(x): # $ SPURIOUS: Alert[py/mixed-returns] # FP +def ok_match(x): # FP match x: case True | 'true': return 0 @@ -341,7 +341,7 @@ def ok_match(x): # $ SPURIOUS: Alert[py/mixed-returns] # FP raise ValueError(x) -def ok_match2(x): # $ SPURIOUS: Alert[py/mixed-returns] # FP +def ok_match2(x): # FP match x: case None: return 0 diff --git a/python/ql/test/query-tests/Imports/PyCheckerTests/ModuleImportsItself.qlref b/python/ql/test/query-tests/Imports/PyCheckerTests/ModuleImportsItself.qlref index a5a25747abf..e6bc27b3065 100644 --- a/python/ql/test/query-tests/Imports/PyCheckerTests/ModuleImportsItself.qlref +++ b/python/ql/test/query-tests/Imports/PyCheckerTests/ModuleImportsItself.qlref @@ -1,2 +1 @@ -query: Imports/ModuleImportsItself.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/ModuleImportsItself.ql diff --git a/python/ql/test/query-tests/Imports/PyCheckerTests/imports_test.py b/python/ql/test/query-tests/Imports/PyCheckerTests/imports_test.py index b8fa4a7ae37..f8a4a4b139e 100644 --- a/python/ql/test/query-tests/Imports/PyCheckerTests/imports_test.py +++ b/python/ql/test/query-tests/Imports/PyCheckerTests/imports_test.py @@ -5,7 +5,7 @@ import test_module2 # $ Alert[py/import-and-import-from] from test_module2 import func #Module imports itself -import imports_test # $ Alert[py/import-own-module] +import imports_test import pkg_ok import pkg_notok diff --git a/python/ql/test/query-tests/Imports/PyCheckerTests/pkg_notok/__init__.py b/python/ql/test/query-tests/Imports/PyCheckerTests/pkg_notok/__init__.py index ecfa5291dc3..3c7abf44e5e 100644 --- a/python/ql/test/query-tests/Imports/PyCheckerTests/pkg_notok/__init__.py +++ b/python/ql/test/query-tests/Imports/PyCheckerTests/pkg_notok/__init__.py @@ -1,7 +1,7 @@ class Foo(object): pass -import pkg_notok # $ Alert[py/import-and-import-from] Alert[py/import-own-module] +import pkg_notok # $ Alert[py/import-and-import-from] # This import is a bit tricky. It will make `bar` available in as `pkg_notok.bar` as a # side effect (see https://docs.python.org/3/reference/import.html#submodules), but the @@ -9,6 +9,6 @@ import pkg_notok # $ Alert[py/import-and-import-from] Alert[py/import-own-module # module imports itself. import pkg_notok.bar -from pkg_notok import Foo # $ Alert[py/import-own-module] -from pkg_notok import Foo as NotOkFoo # $ Alert[py/import-own-module] -from pkg_notok import * # $ Alert[py/import-own-module] +from pkg_notok import Foo +from pkg_notok import Foo as NotOkFoo +from pkg_notok import * diff --git a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/ModuleLevelCyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/ModuleLevelCyclicImport.qlref index e0e35483fed..8b9bc8c123a 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/ModuleLevelCyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/ModuleLevelCyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/ModuleLevelCyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/ModuleLevelCyclicImport.ql diff --git a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module3.py b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module3.py index e3d76ff53a7..83f5eda9557 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module3.py +++ b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module3.py @@ -5,4 +5,4 @@ import module4 @dataclasses.dataclass() class Foo: - bars: typing.List[module4.Bar] # $ Alert + bars: typing.List[module4.Bar] diff --git a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module4.py b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module4.py index e7864e9b6ca..b6da208fbe3 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module4.py +++ b/python/ql/test/query-tests/Imports/cyclic-module-annotations-fp/module4.py @@ -5,5 +5,5 @@ import module3 @dataclasses.dataclass() class Bar: - def is_in_foo(self, foo: module3.Foo): # $ Alert + def is_in_foo(self, foo: module3.Foo): return self in foo.bars diff --git a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/CyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/CyclicImport.qlref index 082797c9226..814bba9fad6 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/CyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/CyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/CyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/CyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/ModuleLevelCyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/ModuleLevelCyclicImport.qlref index e0e35483fed..5119f8fdaae 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/ModuleLevelCyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/false-negative/ModuleLevelCyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/ModuleLevelCyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/ModuleLevelCyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/CyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/CyclicImport.qlref index 082797c9226..814bba9fad6 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/CyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/CyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/CyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/CyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/ModuleLevelCyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/ModuleLevelCyclicImport.qlref index e0e35483fed..5119f8fdaae 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/ModuleLevelCyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module-package-fp/true-negative/ModuleLevelCyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/ModuleLevelCyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/ModuleLevelCyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/CyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module/CyclicImport.qlref index 082797c9226..814bba9fad6 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/CyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module/CyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/CyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/CyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/ModuleLevelCyclicImport.qlref b/python/ql/test/query-tests/Imports/cyclic-module/ModuleLevelCyclicImport.qlref index e0e35483fed..5119f8fdaae 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/ModuleLevelCyclicImport.qlref +++ b/python/ql/test/query-tests/Imports/cyclic-module/ModuleLevelCyclicImport.qlref @@ -1,2 +1 @@ -query: Imports/ModuleLevelCyclicImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/ModuleLevelCyclicImport.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module1.py b/python/ql/test/query-tests/Imports/cyclic-module/module1.py index e17ac87cdca..55ef075e9e6 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module1.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module1.py @@ -1,20 +1,20 @@ # potentially crashing cycles import module2 -import module3 # $ Alert[py/cyclic-import] +import module3 -a1 = module2.a2 # $ Alert[py/unsafe-cyclic-import] +a1 = module2.a2 b1 = 2 # bad style cycles -import module4 # $ Alert[py/cyclic-import] +import module4 def foo(): - import module5 # $ Alert[py/cyclic-import] + import module5 # okay, because some of the cycle is not top level -import module6 # $ Alert[py/cyclic-import] +import module6 # OK because this import occurs after relevant definition (a1) -import module8 # $ Alert[py/cyclic-import] +import module8 #OK because cycle is guarded by `if False:` from module10 import x diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module2.py b/python/ql/test/query-tests/Imports/cyclic-module/module2.py index 81899e72e56..333b8516adb 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module2.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module2.py @@ -1,4 +1,4 @@ import module1 # direct use -a2 = module1.a1 # $ Alert[py/unsafe-cyclic-import] \ No newline at end of file +a2 = module1.a1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module3.py b/python/ql/test/query-tests/Imports/cyclic-module/module3.py index dd391cfcf5a..2180fb54a28 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module3.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module3.py @@ -1,2 +1,2 @@ # use via import member -from module1 import a1 # $ Alert[py/unsafe-cyclic-import] \ No newline at end of file +from module1 import a1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module4.py b/python/ql/test/query-tests/Imports/cyclic-module/module4.py index 790e92121d5..65db406bb45 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module4.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module4.py @@ -1 +1 @@ -import module1 # $ Alert[py/cyclic-import] \ No newline at end of file +import module1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module5.py b/python/ql/test/query-tests/Imports/cyclic-module/module5.py index 790e92121d5..65db406bb45 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module5.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module5.py @@ -1 +1 @@ -import module1 # $ Alert[py/cyclic-import] \ No newline at end of file +import module1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module6.py b/python/ql/test/query-tests/Imports/cyclic-module/module6.py index df0376aceaa..5a5fcd149ac 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module6.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module6.py @@ -1,2 +1,2 @@ def foo(): - import module7 # $ Alert[py/cyclic-import] \ No newline at end of file + import module7 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module7.py b/python/ql/test/query-tests/Imports/cyclic-module/module7.py index 6a961467bad..d0b18ba5894 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module7.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module7.py @@ -1 +1 @@ -from module1 import a1 # $ Alert[py/cyclic-import] \ No newline at end of file +from module1 import a1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module8.py b/python/ql/test/query-tests/Imports/cyclic-module/module8.py index 8117f9a6f9c..185ee214da8 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module8.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module8.py @@ -1,4 +1,4 @@ -import module1 # $ Alert[py/cyclic-import] +import module1 class Foo(object): a = module1.a1 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/cyclic-module/module9.py b/python/ql/test/query-tests/Imports/cyclic-module/module9.py index b8dfb4e10a6..06ab5b93305 100644 --- a/python/ql/test/query-tests/Imports/cyclic-module/module9.py +++ b/python/ql/test/query-tests/Imports/cyclic-module/module9.py @@ -1,6 +1,6 @@ x = 1 -import main # $ Alert[py/cyclic-import] +import main y = 2 \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/general/FromImportOfMutableAttribute.qlref b/python/ql/test/query-tests/Imports/general/FromImportOfMutableAttribute.qlref index 302bb0895a6..9353115309f 100644 --- a/python/ql/test/query-tests/Imports/general/FromImportOfMutableAttribute.qlref +++ b/python/ql/test/query-tests/Imports/general/FromImportOfMutableAttribute.qlref @@ -1,2 +1 @@ -query: Imports/FromImportOfMutableAttribute.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/FromImportOfMutableAttribute.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Imports/general/UnintentionalImport.qlref b/python/ql/test/query-tests/Imports/general/UnintentionalImport.qlref index 0ea9a54298f..4f1b985d5c2 100644 --- a/python/ql/test/query-tests/Imports/general/UnintentionalImport.qlref +++ b/python/ql/test/query-tests/Imports/general/UnintentionalImport.qlref @@ -1,2 +1 @@ -query: Imports/UnintentionalImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/UnintentionalImport.ql diff --git a/python/ql/test/query-tests/Imports/general/imports_mutable.py b/python/ql/test/query-tests/Imports/general/imports_mutable.py index 91efefc7e9f..0519a2071d8 100644 --- a/python/ql/test/query-tests/Imports/general/imports_mutable.py +++ b/python/ql/test/query-tests/Imports/general/imports_mutable.py @@ -1,4 +1,4 @@ -from mutable_attr import x, y # $ Alert[py/import-of-mutable-attribute] +from mutable_attr import x, y def f(): print(x) diff --git a/python/ql/test/query-tests/Imports/general/imports_test.py b/python/ql/test/query-tests/Imports/general/imports_test.py index 8a4faf16a34..f0f881ffb53 100644 --- a/python/ql/test/query-tests/Imports/general/imports_test.py +++ b/python/ql/test/query-tests/Imports/general/imports_test.py @@ -19,7 +19,7 @@ for module in range(10): # $ Alert[py/import-shadowed-loop-variable] #Import * used from module import * # $ Alert[py/import-star-used] -from module_without_all import * # $ Alert[py/import-star-used] Alert[py/polluting-import] +from module_without_all import * # $ Alert[py/import-star-used] #Unused import diff --git a/python/ql/test/query-tests/Imports/unused/UnusedImport.qlref b/python/ql/test/query-tests/Imports/unused/UnusedImport.qlref index 103f075bb14..e6bb7ab44cb 100644 --- a/python/ql/test/query-tests/Imports/unused/UnusedImport.qlref +++ b/python/ql/test/query-tests/Imports/unused/UnusedImport.qlref @@ -1,2 +1 @@ -query: Imports/UnusedImport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Imports/UnusedImport.ql diff --git a/python/ql/test/query-tests/Imports/unused/import_structure_1.py b/python/ql/test/query-tests/Imports/unused/import_structure_1.py index 3afada1956b..a76fe99f12c 100644 --- a/python/ql/test/query-tests/Imports/unused/import_structure_1.py +++ b/python/ql/test/query-tests/Imports/unused/import_structure_1.py @@ -2,7 +2,7 @@ # lines from typing import Optional -from unknown import foo, bar # $ Alert +from unknown import foo, bar var: Optional['foo'] = None diff --git a/python/ql/test/query-tests/Imports/unused/import_structure_2.py b/python/ql/test/query-tests/Imports/unused/import_structure_2.py index 01db62d54f8..90d4255ba39 100644 --- a/python/ql/test/query-tests/Imports/unused/import_structure_2.py +++ b/python/ql/test/query-tests/Imports/unused/import_structure_2.py @@ -3,6 +3,6 @@ from typing import Optional from unknown import foo -from unknown import bar # $ Alert +from unknown import bar var: Optional['foo'] = None diff --git a/python/ql/test/query-tests/Imports/unused/imports_test.py b/python/ql/test/query-tests/Imports/unused/imports_test.py index d3c7068dd88..71363235987 100644 --- a/python/ql/test/query-tests/Imports/unused/imports_test.py +++ b/python/ql/test/query-tests/Imports/unused/imports_test.py @@ -1,13 +1,13 @@ #Multiple imports on a single line -import module1, module2 # $ Alert +import module1, module2 #Cyclic import -import cycle # $ Alert +import cycle #Top level cyclic import -import top_level_cycle # $ Alert +import top_level_cycle #Import shadowed by loop variable @@ -24,14 +24,14 @@ from module_without_all import * #Unused import from module2 import func1 -from module2 import func2 # $ Alert +from module2 import func2 module1.func func1 #Duplicate import import module1 -import module2 # $ Alert +import module2 #OK -- Import used in epytext documentation. import used_in_docs @@ -113,6 +113,6 @@ def baz() -> Optional['subexpression_return_type']: pass -from pytest_fixtures import not_a_fixture # $ Alert # BAD +from pytest_fixtures import not_a_fixture # BAD from pytest_fixtures import fixture, wrapped_fixture # GOOD (pytest fixtures are used implicitly by pytest) from pytest_fixtures import session_fixture, wrapped_autouse_fixture # GOOD (pytest fixtures are used implicitly by pytest) diff --git a/python/ql/test/query-tests/Metrics/cyclo/CyclomaticComplexity.qlref b/python/ql/test/query-tests/Metrics/cyclo/CyclomaticComplexity.qlref index 8e150c5a5c8..c74ae215bb4 100644 --- a/python/ql/test/query-tests/Metrics/cyclo/CyclomaticComplexity.qlref +++ b/python/ql/test/query-tests/Metrics/cyclo/CyclomaticComplexity.qlref @@ -1 +1 @@ -query: Metrics/CyclomaticComplexity.ql +Metrics/CyclomaticComplexity.ql diff --git a/python/ql/test/query-tests/Metrics/imports/DirectImports.qlref b/python/ql/test/query-tests/Metrics/imports/DirectImports.qlref index 0878b889263..84fe2dc5805 100644 --- a/python/ql/test/query-tests/Metrics/imports/DirectImports.qlref +++ b/python/ql/test/query-tests/Metrics/imports/DirectImports.qlref @@ -1 +1 @@ -query: Metrics/DirectImports.ql +Metrics/DirectImports.ql diff --git a/python/ql/test/query-tests/Metrics/imports/TransitiveImports.qlref b/python/ql/test/query-tests/Metrics/imports/TransitiveImports.qlref index 35e369b89b4..1bacdce45c2 100644 --- a/python/ql/test/query-tests/Metrics/imports/TransitiveImports.qlref +++ b/python/ql/test/query-tests/Metrics/imports/TransitiveImports.qlref @@ -1 +1 @@ -query: Metrics/TransitiveImports.ql +Metrics/TransitiveImports.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Statements/general/MismatchInMultipleAssignment.qlref b/python/ql/test/query-tests/Statements/general/MismatchInMultipleAssignment.qlref index a78c64ad718..f7e01617f9e 100644 --- a/python/ql/test/query-tests/Statements/general/MismatchInMultipleAssignment.qlref +++ b/python/ql/test/query-tests/Statements/general/MismatchInMultipleAssignment.qlref @@ -1,2 +1 @@ -query: Statements/MismatchInMultipleAssignment.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/MismatchInMultipleAssignment.ql diff --git a/python/ql/test/query-tests/Statements/general/NonIteratorInForLoop.qlref b/python/ql/test/query-tests/Statements/general/NonIteratorInForLoop.qlref index b7697d64d8f..fb09cace29a 100644 --- a/python/ql/test/query-tests/Statements/general/NonIteratorInForLoop.qlref +++ b/python/ql/test/query-tests/Statements/general/NonIteratorInForLoop.qlref @@ -1,2 +1 @@ -query: Statements/NonIteratorInForLoop.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/NonIteratorInForLoop.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Statements/general/RedundantAssignment.qlref b/python/ql/test/query-tests/Statements/general/RedundantAssignment.qlref index e6247e1cf4c..2c3b08d8766 100644 --- a/python/ql/test/query-tests/Statements/general/RedundantAssignment.qlref +++ b/python/ql/test/query-tests/Statements/general/RedundantAssignment.qlref @@ -1,2 +1 @@ -query: Statements/RedundantAssignment.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/RedundantAssignment.ql diff --git a/python/ql/test/query-tests/Statements/general/StringConcatenationInLoop.qlref b/python/ql/test/query-tests/Statements/general/StringConcatenationInLoop.qlref index 74361f59d07..cf694f99e48 100644 --- a/python/ql/test/query-tests/Statements/general/StringConcatenationInLoop.qlref +++ b/python/ql/test/query-tests/Statements/general/StringConcatenationInLoop.qlref @@ -1,2 +1 @@ -query: Statements/StringConcatenationInLoop.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/StringConcatenationInLoop.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Statements/general/performance.py b/python/ql/test/query-tests/Statements/general/performance.py index 6a217579c0a..261f8bad1ef 100644 --- a/python/ql/test/query-tests/Statements/general/performance.py +++ b/python/ql/test/query-tests/Statements/general/performance.py @@ -3,10 +3,10 @@ def y(seq): y_accum = '' for s in seq: - y_accum += s # $ Alert[py/string-concatenation-in-loop] + y_accum += s def z(seq): z_accum = '' for s in seq: - z_accum = z_accum + s # $ Alert[py/string-concatenation-in-loop] + z_accum = z_accum + s diff --git a/python/ql/test/query-tests/Statements/general/statements_test.py b/python/ql/test/query-tests/Statements/general/statements_test.py index a1c6b3c970e..dd2a49abd16 100644 --- a/python/ql/test/query-tests/Statements/general/statements_test.py +++ b/python/ql/test/query-tests/Statements/general/statements_test.py @@ -16,7 +16,7 @@ def not_cc(): #Mismatch in multiple assignment def mima(): - x, y, z = 1, 2 # $ Alert[py/mismatched-multiple-assignment] + x, y, z = 1, 2 return x, y, z #Statement has no effect (4 statements, 3 of which are violations) @@ -51,10 +51,10 @@ ok = ok # Pyflakes class Redundant(object): x = x # OK - x = x # $ Alert[py/redundant-assignment] # violation + x = x # violation def __init__(self, args): - args = args # $ Alert[py/redundant-assignment] # violation + args = args # violation if sys.version_info < (3,): bytes = str @@ -116,7 +116,7 @@ def maybe_property(x): class WithoutProp(object): def meth(self): - self.x = self.x # $ Alert[py/redundant-assignment] + self.x = self.x #Accessing a property has an effect: def prop_acc(): @@ -166,7 +166,7 @@ if False: def error_mismatched_multi_assign_list(): - a,b,c = [1,2,3,4,5] # $ Alert[py/mismatched-multiple-assignment] + a,b,c = [1,2,3,4,5] def returning_different_tuple_sizes(x): if x: @@ -175,7 +175,7 @@ def returning_different_tuple_sizes(x): return 1,2,3,4,5,6 def error_indirect_mismatched_multi_assign(x): - a, b, c = returning_different_tuple_sizes(x) # $ Alert[py/mismatched-multiple-assignment] + a, b, c = returning_different_tuple_sizes(x) return a, b, c diff --git a/python/ql/test/query-tests/Statements/general/test.py b/python/ql/test/query-tests/Statements/general/test.py index 1461782a535..013f3eabc90 100644 --- a/python/ql/test/query-tests/Statements/general/test.py +++ b/python/ql/test/query-tests/Statements/general/test.py @@ -47,7 +47,7 @@ class NonIterator(object): def __init__(self): pass -for x in NonIterator(): # $ Alert[py/non-iterable-in-for-loop] +for x in NonIterator(): do_something(x) #None in for loop diff --git a/python/ql/test/query-tests/Statements/no_effect/StatementNoEffect.qlref b/python/ql/test/query-tests/Statements/no_effect/StatementNoEffect.qlref index c265c03e884..300e28e96c6 100644 --- a/python/ql/test/query-tests/Statements/no_effect/StatementNoEffect.qlref +++ b/python/ql/test/query-tests/Statements/no_effect/StatementNoEffect.qlref @@ -1,2 +1 @@ -query: Statements/StatementNoEffect.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Statements/StatementNoEffect.ql diff --git a/python/ql/test/query-tests/Statements/no_effect/assert_raises.py b/python/ql/test/query-tests/Statements/no_effect/assert_raises.py index 4ffcf94937e..d9bd6825252 100644 --- a/python/ql/test/query-tests/Statements/no_effect/assert_raises.py +++ b/python/ql/test/query-tests/Statements/no_effect/assert_raises.py @@ -6,6 +6,6 @@ class T(unittest.TestCase): l = 10 s = [0] with self.assertRaises(TypeError): - l[1000] # $ Alert[py/ineffectual-statement] + l[1000] with self.assertRaises(IndexError): - s[1] # $ Alert[py/ineffectual-statement] + s[1] diff --git a/python/ql/test/query-tests/Statements/no_effect/test.py b/python/ql/test/query-tests/Statements/no_effect/test.py index 14f5207637c..45286aaea9f 100644 --- a/python/ql/test/query-tests/Statements/no_effect/test.py +++ b/python/ql/test/query-tests/Statements/no_effect/test.py @@ -21,9 +21,9 @@ import sys #Statement has no effect (4 statements, 3 of which are violations) "Not a docstring" # This is acceptable as strings can be used as comments. -len # $ Alert[py/ineffectual-statement] -sys.argv + [] # $ Alert[py/ineffectual-statement] -3 == 4 # $ Alert[py/ineffectual-statement] +len +sys.argv + [] +3 == 4 #The 'sys' statements have an effect try: @@ -77,7 +77,7 @@ x.deco x.deco + 2 #No effect -x.func # $ Alert[py/ineffectual-statement] +x.func #Cannot infer what attribute is, so be conservative x.thing @@ -113,7 +113,7 @@ def possible_fps(x): h = Horrible() h + "innocent bystander" h < "upstanding citizen" - x - 3 # $ Alert[py/ineffectual-statement] #True positive + x - 3 #True positive # Forgotten raise. diff --git a/python/ql/test/query-tests/Variables/general/ShadowGlobal.qlref b/python/ql/test/query-tests/Variables/general/ShadowGlobal.qlref index a7e7b3c4bad..d3d632da035 100644 --- a/python/ql/test/query-tests/Variables/general/ShadowGlobal.qlref +++ b/python/ql/test/query-tests/Variables/general/ShadowGlobal.qlref @@ -1,2 +1 @@ -query: Variables/ShadowGlobal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/ShadowGlobal.ql diff --git a/python/ql/test/query-tests/Variables/general/variables_test.py b/python/ql/test/query-tests/Variables/general/variables_test.py index d4d7e3aeb65..add95766b13 100644 --- a/python/ql/test/query-tests/Variables/general/variables_test.py +++ b/python/ql/test/query-tests/Variables/general/variables_test.py @@ -11,7 +11,7 @@ def sh1(x): #Shadow Global def sh2(x): - sh1 = x + 1 # $ Alert[py/local-shadows-global] #Shadows + sh1 = x + 1 #Shadows sh1 = x + 0 # no shadowing warning for 2nd def return sh1 diff --git a/python/ql/test/query-tests/Variables/undefined/UndefinedExport.qlref b/python/ql/test/query-tests/Variables/undefined/UndefinedExport.qlref index d964148077e..3e5d31e4748 100644 --- a/python/ql/test/query-tests/Variables/undefined/UndefinedExport.qlref +++ b/python/ql/test/query-tests/Variables/undefined/UndefinedExport.qlref @@ -1,2 +1 @@ -query: Variables/UndefinedExport.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UndefinedExport.ql diff --git a/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.py b/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.py index 85d26ff76f1..0438d8e84b3 100644 --- a/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.py +++ b/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.py @@ -19,12 +19,12 @@ def f(parameter): helper # Explicitly as import a # Imlicitly from ud_helper defined - ug2 # $ Alert[py/undefined-global-variable] # ERROR - e # $ Alert[py/undefined-global-variable] # ERROR Defined in ud_helper, but not in __all__ + ug2 # ERROR + e # ERROR Defined in ud_helper, but not in __all__ int float __file__ #OK all files have __file__ defined - __path__ # $ Alert[py/undefined-global-variable] #ERROR only modules have __path__ defined + __path__ #ERROR only modules have __path__ defined len #Ok defined in builtins monkey1 #Ok monkey-patched builtins @@ -120,7 +120,7 @@ class Cls(object): pfp3 += 1 def only_report_once(): - ug3 # $ Alert[py/undefined-global-variable] + ug3 ug3 ug3 ug3 diff --git a/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.qlref b/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.qlref index e69631e746b..ea9f5a03842 100644 --- a/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.qlref +++ b/python/ql/test/query-tests/Variables/undefined/UndefinedGlobal.qlref @@ -1,2 +1 @@ -query: Variables/UndefinedGlobal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UndefinedGlobal.ql diff --git a/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.py b/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.py index 24a09f1be33..26e109af5a2 100644 --- a/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.py +++ b/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.py @@ -2,7 +2,7 @@ class C: def m1(self): - y = ug1 # $ Alert[py/undefined-global-variable] + y = ug1 x = 1 return y @@ -10,16 +10,16 @@ class C: return p def m3(self, x1): - return u2 # $ Alert[py/uninitialized-local-variable] + return u2 u2 = x1 def m4(self, x2): if x2: u3 = 1 - return u3 # $ Alert[py/uninitialized-local-variable] + return u3 def f(): - y = ug1 # $ Alert[py/undefined-global-variable] + y = ug1 x = 1 return y @@ -34,7 +34,7 @@ def q(x4): def j(u4): del u4 - return u4 # $ Alert[py/uninitialized-local-variable] + return u4 def k(x5): x5 + 1 @@ -43,7 +43,7 @@ def k(x5): def m(x6): if x6: u6 = 1 - u6 # $ Alert[py/uninitialized-local-variable] + u6 #The following are not uninitialized, but unreachable. u6 u6 @@ -66,13 +66,13 @@ def check_del(cond): del u8 else: pass - u8 # $ Alert[py/uninitialized-local-variable] + u8 if cond: u9 = 1 del u9 else: u9 = 2 - u9 # $ Alert[py/uninitialized-local-variable] + u9 if cond: x10 = 1 del x10 @@ -82,10 +82,10 @@ def check_del(cond): x10 u11 = 1 del u11 - u11 # $ Alert[py/uninitialized-local-variable] + u11 u12 = "hi" del u12 - del u12 # $ Alert[py/uninitialized-local-variable] + del u12 #x will always be defined. def const_range(): @@ -116,7 +116,7 @@ def use_def_conditional(cond4, cond5): u14 = 1 x16 = 2 if cond5: - return u14 # $ Alert[py/uninitialized-local-variable] + return u14 def init_and_set_flag_in_try(f): @@ -148,7 +148,7 @@ def split_not_OK(): except: cond = not False if not not cond: - return u19 # $ Alert[py/uninitialized-local-variable] + return u19 def double_is_none(x): if x is not None: @@ -160,7 +160,7 @@ def double_is_none(x): #ODASA-4241 def def_in_post_loop(seq): - j(x) # $ Alert[py/uninitialized-local-variable] + j(x) x = [] for p in seq: x = p @@ -173,9 +173,9 @@ def f(cond1, cond2): else: y = 1 if cond2: - return x # $ Alert[py/uninitialized-local-variable] + return x else: - return y # $ Alert[py/uninitialized-local-variable] + return y def needs_splitting(var): if var: diff --git a/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.qlref b/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.qlref index 90233ce6188..f2d0e603554 100644 --- a/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.qlref +++ b/python/ql/test/query-tests/Variables/undefined/UninitializedLocal.qlref @@ -1,2 +1 @@ -query: Variables/UninitializedLocal.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UninitializedLocal.ql diff --git a/python/ql/test/query-tests/Variables/undefined/decorated_exports.py b/python/ql/test/query-tests/Variables/undefined/decorated_exports.py index 137807a0e00..aad8e347909 100644 --- a/python/ql/test/query-tests/Variables/undefined/decorated_exports.py +++ b/python/ql/test/query-tests/Variables/undefined/decorated_exports.py @@ -1,16 +1,16 @@ import dotted -__all__ = ["foo", "bar", "baz", "not_defined"] # $ Alert[py/undefined-export] +__all__ = ["foo", "bar", "baz", "not_defined"] @dotted.decorator def foo(): pass -@undotted_decorator # $ Alert[py/undefined-global-variable] +@undotted_decorator def bar(): pass -@not_imported.but_dotted # $ Alert[py/undefined-global-variable] +@not_imported.but_dotted def baz(): pass diff --git a/python/ql/test/query-tests/Variables/undefined/exports.py b/python/ql/test/query-tests/Variables/undefined/exports.py index cb59cc6958d..b12a501710c 100644 --- a/python/ql/test/query-tests/Variables/undefined/exports.py +++ b/python/ql/test/query-tests/Variables/undefined/exports.py @@ -1,4 +1,4 @@ -__all__ = ["foo", "bar", "baz", "quux", "blat", "frob", "nosuch", "i_got_it_elsewhere"] # $ Alert[py/undefined-export] +__all__ = ["foo", "bar", "baz", "quux", "blat", "frob", "nosuch", "i_got_it_elsewhere"] with open("foo.txt") as f: foo = f.read() diff --git a/python/ql/test/query-tests/Variables/undefined/odasa3987.py b/python/ql/test/query-tests/Variables/undefined/odasa3987.py index 43444bb80cd..9c3a5fa5b2f 100644 --- a/python/ql/test/query-tests/Variables/undefined/odasa3987.py +++ b/python/ql/test/query-tests/Variables/undefined/odasa3987.py @@ -8,7 +8,7 @@ def f(cond1, cond2): except Exception: if cond2: var = 7 - if var == 1: # $ Alert[py/uninitialized-local-variable] + if var == 1: var = var + 1 elif var == 2: var +- 3 diff --git a/python/ql/test/query-tests/Variables/unused/UnusedModuleVariable.qlref b/python/ql/test/query-tests/Variables/unused/UnusedModuleVariable.qlref index 8709d1bd604..587ad951076 100644 --- a/python/ql/test/query-tests/Variables/unused/UnusedModuleVariable.qlref +++ b/python/ql/test/query-tests/Variables/unused/UnusedModuleVariable.qlref @@ -1,2 +1 @@ -query: Variables/UnusedModuleVariable.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UnusedModuleVariable.ql \ No newline at end of file diff --git a/python/ql/test/query-tests/Variables/unused/UnusedParameter.qlref b/python/ql/test/query-tests/Variables/unused/UnusedParameter.qlref index 1ab2f09ae4f..b37e4859c1b 100644 --- a/python/ql/test/query-tests/Variables/unused/UnusedParameter.qlref +++ b/python/ql/test/query-tests/Variables/unused/UnusedParameter.qlref @@ -1,2 +1 @@ -query: Variables/UnusedParameter.ql -postprocess: utils/test/InlineExpectationsTestQuery.ql +Variables/UnusedParameter.ql diff --git a/python/ql/test/query-tests/Variables/unused/variables_test.py b/python/ql/test/query-tests/Variables/unused/variables_test.py index 9b29c1d0103..42f8324ca56 100644 --- a/python/ql/test/query-tests/Variables/unused/variables_test.py +++ b/python/ql/test/query-tests/Variables/unused/variables_test.py @@ -22,7 +22,7 @@ __hidden_marker = False #Unused parameter, local and global -def u1(x): # $ Alert[py/unused-parameter] +def u1(x): return 0 def u2(): @@ -45,8 +45,8 @@ class D(C): pass #Unused module variable -not_used_var1 = 17 # $ Alert[py/unused-global-variable] -not_used_var2 = 18 # $ Alert[py/unused-global-variable] +not_used_var1 = 17 +not_used_var2 = 18 is_used_var1 = 19 is_used_var2 = 20 @@ -83,7 +83,7 @@ def f(t): # Entirely unused tuple -a,b,c = t # $ Alert[py/unused-global-variable] +a,b,c = t def f(t): a,b,c = t # $ Alert[py/unused-local-variable] @@ -97,7 +97,7 @@ def second_def_undefined(): #And gloablly glob_var = 0 use(glob_var) -glob_var = 1 # $ Alert[py/unused-global-variable] # unused +glob_var = 1 # unused diff --git a/python/ql/test/query-tests/analysis/Consistency/Consistency.qlref b/python/ql/test/query-tests/analysis/Consistency/Consistency.qlref index 0343f08ebf4..6abbdd6dd64 100644 --- a/python/ql/test/query-tests/analysis/Consistency/Consistency.qlref +++ b/python/ql/test/query-tests/analysis/Consistency/Consistency.qlref @@ -1 +1 @@ -query: analysis/Consistency.ql +analysis/Consistency.ql diff --git a/python/ql/test/query-tests/analysis/pointsto/FailedInference.qlref b/python/ql/test/query-tests/analysis/pointsto/FailedInference.qlref index 991e596544b..b08adfa00b5 100644 --- a/python/ql/test/query-tests/analysis/pointsto/FailedInference.qlref +++ b/python/ql/test/query-tests/analysis/pointsto/FailedInference.qlref @@ -1 +1 @@ -query: analysis/FailedInference.ql +analysis/FailedInference.ql