'''Check that parameters without key as title breaks validation.'''
withpytest.raises(RuleValidationError,match=fr'^Rule {rule.id} should have a parameter name declared with `.name` before the bock, for each parameter'):
'''Check that forgetting the language for sources breaks validation'''
rule=invalid_rule('S100','cfamily')
withpytest.raises(RuleValidationError,match=re.escape(f'Rule {rule.id} has non highlighted code example in section "Noncompliant Code Example".\nUse [source,cpp] or [source,text] before the opening \'----\'.')):
'''Check that forgetting the language for sources breaks validation in case of multiple blocks too'''
rule=invalid_rule('S100','java')
withpytest.raises(RuleValidationError,match=re.escape(f'Rule {rule.id} has non highlighted code example in section "Noncompliant Code Example".\nUse [source,java] or [source,text] before the opening \'----\'.')):
'''Check that forgetting the language for sources breaks validation'''
rule=invalid_rule('S100','csharp')
withpytest.raises(RuleValidationError,match=re.escape(f'Rule {rule.id} has unknown language "unknown" in code example in section "Noncompliant Code Example".\nAre you looking for "csharp"?')):
'''Check that having "How to fix it" subsections using framework names that are not inside the "allowed_framework_names.adoc" file breaks validation'''
rule=invalid_rule('S101','csharp')
withpytest.raises(RuleValidationError,match=f'Rule csharp:S101 has a "How to fix it" section for an unsupported framework: "Foo Bar Framework"'):
'''Check that having more than the current hard limit (6) "How to fix it" subsections breaks validation'''
rule=invalid_rule('S101','javascript')
withpytest.raises(RuleValidationError,match=f'Rule javascript:S101 has more than 6 "How to fix it" subsections. Please ensure this limit can be increased with PM/UX teams'):
'''Check that having "How to fix it" subsections without the parent "How to fix it?" section breaks validation'''
rule=invalid_rule('S101','python')
withpytest.raises(RuleValidationError,match=f'Rule python:S101 has "How to fix it" subsections for frameworks outside a defined "How to fix it\\?" section'):