Skip to content

Commit 988f569

Browse files
authored
Smarter flow to rule E6101 (#3583)
* Smarter flow to rule E6101 * better len value in W6001
1 parent fbbea5c commit 988f569

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/cfnlint/rules/outputs/ImportValue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ImportValue(CloudFormationLintRule):
2525
def validate(
2626
self, validator: Validator, s: Any, instance: Any, schema: Any
2727
) -> Iterator[ValidationError]:
28-
if len(validator.context.path.path) >= 2:
28+
if len(validator.context.path.path) >= 3:
2929
if (
3030
validator.context.path.path[0] == "Outputs"
3131
and validator.context.path.path[2] == "Value"

src/cfnlint/rules/outputs/Value.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,27 @@ def validate(self, validator: Validator, _: Any, instance: Any, schema: Any):
3737
condition = instance.get("Condition")
3838
if condition:
3939
conditions = {condition: True}
40+
4041
validator = validator.evolve(
4142
context=validator.context.evolve(
4243
functions=list(FUNCTIONS),
4344
conditions=validator.context.conditions.evolve(
4445
conditions,
4546
),
46-
path=validator.context.path.descend(
47-
path=key,
48-
cfn_path=key,
49-
),
50-
),
47+
)
48+
)
49+
50+
for err in validator.descend(
51+
value,
5152
schema={
5253
"type": ["array", "string"],
5354
"items": {
5455
"type": "string",
5556
},
5657
},
57-
)
58-
59-
for err in self._iter_errors(validator, value):
60-
err.path.appendleft(key)
58+
path=key,
59+
property_path=key,
60+
):
61+
if err.rule is None:
62+
err.rule = self
6163
yield err

0 commit comments

Comments
 (0)