测试的扫描文件
This commit is contained in:
@@ -37,3 +37,33 @@ def missing_spaces():
|
||||
y=3*4
|
||||
if x==1:
|
||||
print(x)
|
||||
|
||||
|
||||
# 缺陷1: 未使用的导入
|
||||
import unused_module # 未使用
|
||||
import collections as col # 使用了 col 但 flake8 可能检测
|
||||
|
||||
|
||||
# 缺陷2: 未使用的变量
|
||||
def unused_variable_demo():
|
||||
"""演示未使用的变量"""
|
||||
result = calculate() # result 未被使用
|
||||
print("Function executed")
|
||||
|
||||
|
||||
def calculate():
|
||||
"""计算并返回结果"""
|
||||
return 42
|
||||
|
||||
|
||||
# 缺陷3: 未定义的变量
|
||||
def undefined_variable_demo():
|
||||
"""演示未定义的变量"""
|
||||
print(undefined_var) # undefined_var 未定义
|
||||
|
||||
|
||||
# 缺陷4: 变量在定义前使用
|
||||
def use_before_define():
|
||||
"""在定义前使用变量"""
|
||||
print(before_var) # before_var 在下面才定义
|
||||
before_var = 100
|
||||
|
||||
Reference in New Issue
Block a user