diff options
Diffstat (limited to 'tests/extensions/data')
-rw-r--r-- | tests/extensions/data/bad_builtin.py | 4 | ||||
-rw-r--r-- | tests/extensions/data/broad_try_clause.py | 49 | ||||
-rw-r--r-- | tests/extensions/data/compare_to_zero.py | 28 | ||||
-rw-r--r-- | tests/extensions/data/docstring.py | 40 | ||||
-rw-r--r-- | tests/extensions/data/elif.py | 26 | ||||
-rw-r--r-- | tests/extensions/data/empty_comment.py | 9 | ||||
-rw-r--r-- | tests/extensions/data/empty_string_comparison.py | 16 | ||||
-rw-r--r-- | tests/extensions/data/mccabe.py | 205 | ||||
-rw-r--r-- | tests/extensions/data/overlapping_exceptions.py | 45 | ||||
-rw-r--r-- | tests/extensions/data/overlapping_exceptions_py33.py | 18 | ||||
-rw-r--r-- | tests/extensions/data/redefined.py | 85 |
11 files changed, 0 insertions, 525 deletions
diff --git a/tests/extensions/data/bad_builtin.py b/tests/extensions/data/bad_builtin.py deleted file mode 100644 index fd3e5c054..000000000 --- a/tests/extensions/data/bad_builtin.py +++ /dev/null @@ -1,4 +0,0 @@ -# pylint: disable=missing-docstring - -TEST = map(str, (1, 2, 3)) # [bad-builtin] -TEST1 = filter(str, (1, 2, 3)) # [bad-builtin] diff --git a/tests/extensions/data/broad_try_clause.py b/tests/extensions/data/broad_try_clause.py deleted file mode 100644 index 2bbc4e7a2..000000000 --- a/tests/extensions/data/broad_try_clause.py +++ /dev/null @@ -1,49 +0,0 @@ -# pylint: disable=missing-docstring, invalid-name - -MY_DICTIONARY = {"key_one": 1, "key_two": 2, "key_three": 3} - -try: # [max-try-statements] - value = MY_DICTIONARY["key_one"] - value += 1 - print("This one has an except clause only.") -except KeyError: - pass - -try: # [max-try-statements] - value = MY_DICTIONARY["key_one"] - value += 1 - print("This one has a finally clause only.") -finally: - pass - -try: # [max-try-statements] - value = MY_DICTIONARY["key_one"] - value += 1 - print("This one has an except clause...") - print("and also a finally clause!") -except KeyError: - pass -finally: - pass - -try: # [max-try-statements] - if "key_one" in MY_DICTIONARY: - entered_if_body = True - print("This verifies that content inside of an if statement is counted too.") - else: - entered_if_body = False - - while False: - print("This verifies that content inside of a while loop is counted too.") - - for item in []: - print("This verifies that content inside of a for loop is counted too.") - - -except KeyError: - pass - -try: - value = MY_DICTIONARY["key_one"] -except KeyError: - value = 0 diff --git a/tests/extensions/data/compare_to_zero.py b/tests/extensions/data/compare_to_zero.py deleted file mode 100644 index 29fd13994..000000000 --- a/tests/extensions/data/compare_to_zero.py +++ /dev/null @@ -1,28 +0,0 @@ -# pylint: disable=literal-comparison,missing-docstring - -X = 123 -Y = len('test') - -if X is 0: # [compare-to-zero] - pass - -if Y is not 0: # [compare-to-zero] - pass - -if X == 0: # [compare-to-zero] - pass - -if Y != 0: # [compare-to-zero] - pass - -if X > 0: - pass - -if X < 0: - pass - -if 0 < X: - pass - -if 0 > X: - pass diff --git a/tests/extensions/data/docstring.py b/tests/extensions/data/docstring.py deleted file mode 100644 index 8f34c657f..000000000 --- a/tests/extensions/data/docstring.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Checks of Dosctrings 'docstring-first-line-empty' 'bad-docstring-quotes'""" - - -def check_messages(*messages): - """ - docstring""" - return messages - -def function2(): - """Test Ok""" - -class FFFF: - """ - Test Docstring First Line Empty - """ - - def method1(self): - ''' - Test Triple Single Quotes docstring - ''' - - def method2(self): - "bad docstring 1" - - def method3(self): - 'bad docstring 2' - - def method4(self): - ' """bad docstring 3 ' - - @check_messages('bad-open-mode', 'redundant-unittest-assert', - 'deprecated-module') - def method5(self): - """Test OK 1 with decorators""" - - def method6(self): - r"""Test OK 2 with raw string""" - - def method7(self): - u"""Test OK 3 with unicode string""" diff --git a/tests/extensions/data/elif.py b/tests/extensions/data/elif.py deleted file mode 100644 index 22e79c1db..000000000 --- a/tests/extensions/data/elif.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Checks use of "else if" triggers a refactor message""" - -def my_function(): - """docstring""" - myint = 2 - if myint > 5: - pass - else: - if myint <= 5: - pass - else: - myint = 3 - if myint > 2: - if myint > 3: - pass - elif myint == 3: - pass - elif myint < 3: - pass - else: - if myint: - pass - else: - if myint: - pass - myint = 4 diff --git a/tests/extensions/data/empty_comment.py b/tests/extensions/data/empty_comment.py deleted file mode 100644 index 8a18df2eb..000000000 --- a/tests/extensions/data/empty_comment.py +++ /dev/null @@ -1,9 +0,0 @@ -"""empty-comment test-case""" -A = 5 # -# -A = '#' + '1' -print(A) # -print("A=", A) # should not be an error# -A = "#pe\0ace#love#" # -A = "peace#love" # \0 peace'#'''' love#peace'''-'#love'-"peace#love"# -####### diff --git a/tests/extensions/data/empty_string_comparison.py b/tests/extensions/data/empty_string_comparison.py deleted file mode 100644 index c6dcf8ea8..000000000 --- a/tests/extensions/data/empty_string_comparison.py +++ /dev/null @@ -1,16 +0,0 @@ -# pylint: disable=literal-comparison,missing-docstring - -X = '' -Y = 'test' - -if X is '': # [compare-to-empty-string] - pass - -if Y is not "": # [compare-to-empty-string] - pass - -if X == "": # [compare-to-empty-string] - pass - -if Y != '': # [compare-to-empty-string] - pass diff --git a/tests/extensions/data/mccabe.py b/tests/extensions/data/mccabe.py deleted file mode 100644 index fdbdb5f0c..000000000 --- a/tests/extensions/data/mccabe.py +++ /dev/null @@ -1,205 +0,0 @@ -"""Checks use of "too-complex" check""" - - -def f1(): - """McCabe rating: 1""" - pass - - -def f2(n): - """McCabe rating: 1""" - k = n + 4 - s = k + n - return s - - -def f3(n): - """McCabe rating: 3""" - if n > 3: - return "bigger than three" - elif n > 4: - return "is never executed" - else: - return "smaller than or equal to three" - - -def f4(): - """McCabe rating: 2""" - for i in range(10): - print(i) - - -def f5(mylist): - """McCabe rating: 2""" - for i in mylist: - print(i) - else: - print(None) - - -def f6(n): - """McCabe rating: 2""" - if n > 4: - return f(n - 1) - else: - return n - - -def f7(): - """McCabe rating: 3""" - def b(): - """McCabe rating: 2""" - def c(): - """McCabe rating: 1""" - pass - c() - b() - - -def f8(): - """McCabe rating: 4""" - try: - print(1) - except TypeA: - print(2) - except TypeB: - print(3) - else: - print(4) - - -def f9(): - """McCabe rating: 9""" - myint = 2 - if myint > 5: - pass - else: - if myint <= 5: - pass - else: - myint = 3 - if myint > 2: - if myint > 3: - pass - elif myint == 3: - pass - elif myint < 3: - pass - else: - if myint: - pass - else: - if myint: - pass - myint = 4 - - -def f10(): - """McCabe rating: 11""" - myint = 2 - if myint == 5: - return myint - elif myint == 6: - return myint - elif myint == 7: - return myint - elif myint == 8: - return myint - elif myint == 9: - return myint - elif myint == 10: - if myint == 8: - while True: - return True - elif myint == 8: - with myint: - return 8 - else: - if myint == 2: - return myint - return myint - return myint - - -class MyClass1(object): - """Class of example to test mccabe""" - _name = 'MyClass' # To force a tail.node=None - - def method1(): - """McCabe rating: 1""" - pass - - def method2(self, param1): - """McCabe rating: 18""" - if not param1: - pass - pass - if param1: - pass - else: - pass - - pass - - if param1: - pass - if param1: - pass - if param1: - pass - if param1: - pass - if param1: - pass - if param1: - pass - if param1: - for value in range(5): - pass - - pass - for count in range(6): - with open('myfile') as fp: - count += 1 - pass - pass - try: - pass - if not param1: - pass - else: - pass - if param1: - raise BaseException('Error') - with open('myfile2') as fp2: - pass - pass - finally: - if param1 is not None: - pass - for count2 in range(8): - try: - pass - except BaseException('Error2'): - pass - return param1 - - -for count in range(10): - if count == 1: - exit(0) - elif count == 2: - exit(1) - else: - exit(2) - - -def method3(self): - try: - if True: - pass - else: - pass - finally: - pass - return True diff --git a/tests/extensions/data/overlapping_exceptions.py b/tests/extensions/data/overlapping_exceptions.py deleted file mode 100644 index 5ee50f314..000000000 --- a/tests/extensions/data/overlapping_exceptions.py +++ /dev/null @@ -1,45 +0,0 @@ -# pylint: disable=missing-docstring - -class SomeException(Exception): - pass - -class SubclassException(SomeException): - pass - -AliasException = SomeException - -try: - pass -except (SomeException, SomeException): # [overlapping-except] - pass - -try: - pass -except (SomeException, SubclassException): # [overlapping-except] - pass - -try: - pass -except (SomeException, AliasException): # [overlapping-except] - pass - -try: - pass -except (AliasException, SubclassException): # [overlapping-except] - pass - -try: - pass -# +1:[overlapping-except, overlapping-except, overlapping-except] -except (SomeException, AliasException, SubclassException): - pass - -try: - pass -except (ArithmeticError, FloatingPointError): # [overlapping-except] - pass - -try: - pass -except (ValueError, UnicodeDecodeError): # [overlapping-except] - pass diff --git a/tests/extensions/data/overlapping_exceptions_py33.py b/tests/extensions/data/overlapping_exceptions_py33.py deleted file mode 100644 index 16d5c30d1..000000000 --- a/tests/extensions/data/overlapping_exceptions_py33.py +++ /dev/null @@ -1,18 +0,0 @@ -# pylint: disable=missing-docstring - -import socket - -try: - pass -except (IOError, OSError): # [overlapping-except] - pass - -try: - pass -except (socket.error, OSError): # [overlapping-except] - pass - -try: - pass -except (ConnectionError, socket.error): # [overlapping-except] - pass diff --git a/tests/extensions/data/redefined.py b/tests/extensions/data/redefined.py deleted file mode 100644 index 8829c4383..000000000 --- a/tests/extensions/data/redefined.py +++ /dev/null @@ -1,85 +0,0 @@ -"""Checks variable types aren't redefined within a method or a function""" - -# pylint: disable=too-few-public-methods,missing-docstring,unused-variable,invalid-name, useless-object-inheritance - -_OK = True - -class MyClass(object): - - class Klass(object): - def __init__(self): - self.var2 = 'var' - - def __init__(self): - self.var = True - self.var1 = 2 - self.var2 = 1. - self.var1 = 2. # [redefined-variable-type] - self.a_str = "hello" - a_str = False - (a_str, b_str) = (1, 2) # no support for inference on tuple assignment - a_str = 2.0 if self.var else 1.0 - - def _getter(self): - return self.a_str - def _setter(self, val): - self.a_str = val - var2 = property(_getter, _setter) - - def some_method(self): - def func(): - var = 1 - test = 'bar' - var = 'baz' # [redefined-variable-type] - self.var = 1 # the rule checks for redefinitions in the scope of a function or method - test = 'foo' - myint = 2 - myint = False # [redefined-variable-type] - -_OK = "This is OK" # [redefined-variable-type] - -if _OK: - SOME_FLOAT = 1. - -def dummy_function(): - return 2 - -def other_function(): - instance = MyClass() - instance = True # [redefined-variable-type] - -SOME_FLOAT = dummy_function() # [redefined-variable-type] - -A_GLOB = None -A_GLOB = [1, 2, 3] - -def func2(x): - if x: - var = 'foo' - else: - var = True - - if x: - var2 = 'foo' - elif not x: - var2 = 2 - else: - pass - - if x: - var3 = 'foo' - var3 = 2 # [redefined-variable-type] - else: - pass - - var = 2 # [redefined-variable-type] - - if x: - pass - elif not x: - var4 = True - elif _OK: - pass - else: - var4 = 2. - var4 = 'baz' # [redefined-variable-type] |