Skip to content

Commit 31a421c

Browse files
authored
Update I1022 to allow functions (#3961)
1 parent dce29a6 commit 31a421c

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/cfnlint/rules/functions/SubNotJoin.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313

1414
class SubNotJoin(CloudFormationLintRule):
15-
"""Check if Join is being used with no join characters"""
16-
1715
id = "I1022"
1816
shortdesc = "Use Sub instead of Join"
1917
description = (
@@ -35,6 +33,9 @@ def _check_element(self, element):
3533
return True
3634

3735
def _check_elements(self, elements):
36+
if not isinstance(elements, list):
37+
return False
38+
3839
for element in elements:
3940
if not self._check_element(element):
4041
return False
@@ -55,7 +56,7 @@ def validate(
5556

5657
if self._check_elements(value[1]):
5758
yield ValidationError(
58-
("Prefer using Fn::Sub over Fn::Join with an" " empty delimiter"),
59+
("Prefer using Fn::Sub over Fn::Join with an empty delimiter"),
5960
path=deque([key, 0]),
6061
rule=self,
6162
)

test/unit/rules/functions/test_sub_not_join.py

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ def rule():
2020
@pytest.fixture
2121
def template():
2222
return {
23+
"Parameters": {
24+
"MyList": {
25+
"Type": "CommaDelimitedList",
26+
},
27+
},
2328
"Resources": {
2429
"MyResource": {
2530
"Type": "AWS::S3::Bucket",
@@ -37,6 +42,12 @@ def template():
3742
{"type": "string"},
3843
[],
3944
),
45+
(
46+
"Valid Fn::Join with a list parameter",
47+
{"Fn::Join": ["", {"Ref": "MyList"}]},
48+
{"type": "string"},
49+
[],
50+
),
4051
(
4152
"Invalid Fn::Join with an empty string",
4253
{"Fn::Join": ["", ["foo", "bar"]]},

0 commit comments

Comments
 (0)