def match()

in qs_cfn_lint_rules/InclusiveLanguage.py [0:0]


    def match(self, cfn):
        """Find all strings and match a deny list of sub strings"""
        message = '"{0}" may be interpreted as a biased term. Consider a more inclusive alternative, such as {1}'
        matches = []

        def recurse_template(item, path=None):
            if path is None:
                path = []
            if isinstance(item, dict):
                for k, v in item.items():
                    p = path.copy()
                    p.append(k)
#                    recurse_template(k, p)
                    recurse_template(v, p)
            if isinstance(item, list):
                for i in range(len(item)-1):
                    p = path.copy()
                    p.append(i)
                    recurse_template(item[i], p)
            if isinstance(item, str):
                t = match(item)
                if t:
                    matches.append(RuleMatch(path, message.format(t[0], t[1])))
            return matches

        recurse_template(cfn.template)
        return matches

        if self.id in cfn.template.get("Metadata", {}).get("QSLint", {}).get("Exclusions", []):
            return matches
        if "Metadata" in cfn.template.keys():
            if "AWS::CloudFormation::Interface" in cfn.template["Metadata"].keys():
                if "ParameterGroups" in cfn.template["Metadata"]["AWS::CloudFormation::Interface"].keys():
                    for x in cfn.template["Metadata"]["AWS::CloudFormation::Interface"]["ParameterGroups"]:
                        labels += x['Parameters']

        if "Parameters" not in cfn.template.keys():
            return matches
        else:
            for x in cfn.template["Parameters"]:
                if str(x) not in labels:
                    matches.append(RuleMatch(["Parameters", x], message.format(x)))
        return matches