Skip to content

Commit 8ae6436

Browse files
committed
Fixed bug in release 0.1.5
1 parent 07b6398 commit 8ae6436

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

cfn_inline_lambda_linter/linter.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,26 +104,26 @@ def extractLambdaCode(resources, parameters, dict_to_check, args=None):
104104
if "python" in val:
105105
if args is None:
106106
process = subprocess.Popen(
107-
['python', '-m', 'flake8', "-", "--ignore=F828"],
107+
['python', '-m', 'flake8', "-", "--ignore=F821"],
108108
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
109109
)
110110
else:
111-
if "F828" in args:
111+
if "F821" in args:
112112
process = subprocess.Popen(
113113
['python', '-m', 'flake8', "-"] + args.split(),
114114
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
115115
)
116116
else:
117117
if "--ignore" in args:
118-
y=args.split("--ignore=")[1] + ",F828"
118+
y=args.split("--ignore=")[1] + ",F821"
119119
z=args.split("--ignore")[:-1] + ["--ignore=" + y]
120120
process = subprocess.Popen(
121121
['python', '-m', 'flake8', "-"] + z,
122122
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
123123
)
124124
else:
125125
process = subprocess.Popen(
126-
['python', '-m', 'flake8', "-", "--ignore=F828"] + args.split(),
126+
['python', '-m', 'flake8', "-", "--ignore=F821"] + args.split(),
127127
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
128128
)
129129
else:
@@ -140,26 +140,26 @@ def extractLambdaCode(resources, parameters, dict_to_check, args=None):
140140
if "python" in programming_lang:
141141
if args is None:
142142
process = subprocess.Popen(
143-
['python', '-m', 'flake8', "-", "--ignore=F828"],
143+
['python', '-m', 'flake8', "-", "--ignore=F821"],
144144
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
145145
)
146146
else:
147-
if "F828" in args:
147+
if "F821" in args:
148148
process = subprocess.Popen(
149149
['python', '-m', 'flake8', "-"] + args.split(),
150150
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
151151
)
152152
else:
153153
if "--ignore" in args:
154-
y=args.split("--ignore=")[1] + ",F828"
154+
y=args.split("--ignore=")[1] + ",F821"
155155
z=args.split("--ignore")[:-1] + ["--ignore=" + y]
156156
process = subprocess.Popen(
157157
['python', '-m', 'flake8', "-"] + z,
158158
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
159159
)
160160
else:
161161
process = subprocess.Popen(
162-
['python', '-m', 'flake8', "-", "--ignore=F828"] + args.split(),
162+
['python', '-m', 'flake8', "-", "--ignore=F821"] + args.split(),
163163
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
164164
)
165165
else:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cfn-inline-lambda-linter"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
description = "Prints out linting errors found in inline cloudformation lambda code"
55
authors = ["Saad Mohsin Khan <saadk687@gmail.com>"]
66
license = "MIT"

tests/integration_tests/test_linter_end_to_end.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def test_linter_simple_yaml_not_cloudformation(tmp_path, monkeypatch):
8585
# Should exit with code 0 (success) since it's skipping the file
8686
assert exc_info.value.code == 0
8787

88-
def test_linter_lambda_with_sub_function_ignores_f828(tmp_path, monkeypatch):
89-
"""Test that F828 errors are ignored when Lambda code uses !Sub with CloudFormation parameters/resources"""
88+
def test_linter_lambda_with_sub_function_ignores_f821(tmp_path, monkeypatch):
89+
"""Test that F821 errors are ignored when Lambda code uses !Sub with CloudFormation parameters/resources"""
9090
file_path = tmp_path / "lambda_with_sub_template.yaml"
9191
file_path.write_text("""
9292
Parameters:

tests/unit_tests/test_extractLambdaCode.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,34 @@ def test_extract_lambda_code_missing_zipfile():
4545
# Should skip and leave status unchanged (or set to a specific value if your logic does)
4646
assert result["LambdaFunction"]["status"] == "SkippingLambda"
4747

48-
def test_extract_lambda_code_ignore_f828():
49-
"""Test that F828 errors are ignored when Lambda code uses CloudFormation substitutions."""
48+
def test_extract_lambda_code_ignore_f821():
49+
"""Test that F821 errors are ignored when Lambda code uses CloudFormation substitutions."""
5050
resources = {
5151
"LambdaFunction": {
5252
"Type": "AWS::Lambda::Function",
5353
"Properties": {
5454
"Runtime": "python3.8",
5555
"Code": {
56-
"ZipFile": "import boto3\nimport json\n\n# This would normally trigger F828 - undefined name\nmy_resource = ${MyResource}\nbucket_name = ${BucketName}\n\ndef handler(event, context):\n return {'statusCode': 200}"
56+
"ZipFile": "import boto3\nimport json\n\n# This would normally trigger F821 - undefined name\nmy_resource = ${MyResource}\nbucket_name = ${BucketName}\n\ndef handler(event, context):\n return {'statusCode': 200}"
5757
}
5858
}
5959
}
6060
}
6161
dict_to_check = {"LambdaFunction": {"status": "CodeNotFormatted"}}
6262
result = extractLambdaCode(resources, {}, dict_to_check, args=None)
6363

64-
# The linter should ignore F828 errors and not report them as failures
64+
# The linter should ignore F821 errors and not report them as failures
6565
errors = result["LambdaFunction"].get("errors", "")
66-
assert "F828" not in errors, "F828 should be ignored for CloudFormation substitutions"
66+
assert "F821" not in errors, "F821 should be ignored for CloudFormation substitutions"
6767

68-
# Since we're ignoring F828, the status should be FoundNoErrors (other errors might still exist)
69-
# But F828 specifically should not be present
68+
# Since we're ignoring F821, the status should be FoundNoErrors (other errors might still exist)
69+
# But F821 specifically should not be present
7070
if result["LambdaFunction"]["status"] == "FoundErrors":
71-
# If there are errors, make sure F828 is not one of them
72-
assert "F828" not in errors
71+
# If there are errors, make sure F821 is not one of them
72+
assert "F821" not in errors
7373

74-
def test_extract_lambda_code_ignore_f828_with_custom_args():
75-
"""Test that F828 is still ignored when custom flake8 args are provided."""
74+
def test_extract_lambda_code_ignore_f821_with_custom_args():
75+
"""Test that F821 is still ignored when custom flake8 args are provided."""
7676
resources = {
7777
"LambdaFunction": {
7878
"Type": "AWS::Lambda::Function",
@@ -86,14 +86,14 @@ def test_extract_lambda_code_ignore_f828_with_custom_args():
8686
}
8787
dict_to_check = {"LambdaFunction": {"status": "CodeNotFormatted"}}
8888

89-
# Test with custom args that don't mention F828
89+
# Test with custom args that don't mention F821
9090
result = extractLambdaCode(resources, {}, dict_to_check, args="--max-line-length=120")
9191

9292
errors = result["LambdaFunction"].get("errors", "")
93-
assert "F828" not in errors, "F828 should be ignored even with custom args"
93+
assert "F821" not in errors, "F821 should be ignored even with custom args"
9494

95-
def test_extract_lambda_code_ignore_f828_with_parameter_ref():
96-
"""Test that F828 is ignored when Runtime is referenced via parameter."""
95+
def test_extract_lambda_code_ignore_f821_with_parameter_ref():
96+
"""Test that F821 is ignored when Runtime is referenced via parameter."""
9797
resources = {
9898
"LambdaFunction": {
9999
"Type": "AWS::Lambda::Function",
@@ -115,4 +115,4 @@ def test_extract_lambda_code_ignore_f828_with_parameter_ref():
115115
result = extractLambdaCode(resources, parameters, dict_to_check, args=None)
116116

117117
errors = result["LambdaFunction"].get("errors", "")
118-
assert "F828" not in errors, "F828 should be ignored for parameter referenced runtime"
118+
assert "F821" not in errors, "F821 should be ignored for parameter referenced runtime"

0 commit comments

Comments
 (0)