Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documenting cfn-lint --update-documentation in rule documentation #1374

Merged
merged 2 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ To include these rules, use the `-e/include-experimental` argument when running


## Rules
The following **136** rules are applied by this linter:
(_This documentation is generated from the Rules, do not alter this manually_)
(_This documentation is generated by running `cfn-lint --update-documentation`, do not alter this manually_)

The following **140** rules are applied by this linter:

| Rule ID | Title | Description | Config<br />(Name:Type:Default) | Source | Tags |
| -------- | ----- | ----------- | ---------- | ------ | ---- |
Expand All @@ -72,7 +73,7 @@ The following **136** rules are applied by this linter:
| E1026<a name="E1026"></a> | Cannot reference resources in the Conditions block of the template | Check that any Refs in the Conditions block uses no resources | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#w2ab2c21c28c21c45) | `functions`,`ref` |
| E1027<a name="E1027"></a> | Check dynamic references secure strings are in supported locations | Dynamic References Secure Strings are only supported for a small set of resource properties. Validate that they are being used in the correct location when checking values and Fn::Sub in resource properties. Currently doesn't check outputs, maps, conditions, parameters, and descriptions. | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html) | `functions`,`dynamic reference` |
| E1028<a name="E1028"></a> | Check Fn::If structure for validity | Check Fn::If to make sure its valid. Condition has to be a string. | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-if) | `functions`,`if` |
| E1029<a name="E1029"></a> | Sub is required if a variable is used in a string | If a substitution variable exists in a string but isn't wrapped with the Fn::Sub function the deployment will fail. | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html) | `functions`,`sub` |
| E1029<a name="E1029"></a> | Sub is required if a variable is used in a string | If a substitution variable exists in a string but isn't wrapped with the Fn::Sub function the deployment will fail. | custom_excludes:string: | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html) | `functions`,`sub` |
| E2001<a name="E2001"></a> | Parameters have appropriate properties | Making sure the parameters are properly configured | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) | `parameters` |
| E2002<a name="E2002"></a> | Parameters have appropriate type | Making sure the parameters have a correct type | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html#parmtypes) | `parameters` |
| E2003<a name="E2003"></a> | Parameters have appropriate names | Check if Parameters are properly named (A-Za-z0-9) | | [Source](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html#parameters-section-structure-requirements) | `parameters` |
Expand Down
21 changes: 5 additions & 16 deletions src/cfnlint/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,19 @@ def update_documentation(rules):

# Add the rules
new_file.write(
'The following **{}** rules are applied by this linter:\n'.format(len(sorted_rules)))
'(_This documentation is generated by running `cfn-lint --update-documentation`, do not alter this manually_)\n\n')
new_file.write(
'(_This documentation is generated from the Rules, do not alter this manually_)\n\n')
'The following **{}** rules are applied by this linter:\n\n'.format(len(sorted_rules) + 3))
PatMyron marked this conversation as resolved.
Show resolved Hide resolved
new_file.write(
'| Rule ID | Title | Description | Config<br />(Name:Type:Default) | Source | Tags |\n')
new_file.write('| -------- | ----- | ----------- | ---------- | ------ | ---- |\n')

rule_output = '| {0}<a name="{0}"></a> | {1} | {2} | {3} | [Source]({4}) | {5} |\n'

# Add system Errors (hardcoded)
parseerror = cfnlint.rules.ParseError()
tags = ','.join('`{0}`'.format(tag) for tag in parseerror.tags)
new_file.write(rule_output.format(
parseerror.id, parseerror.shortdesc, parseerror.description, '', '', tags))

transformerror = cfnlint.rules.TransformError()
tags = ','.join('`{0}`'.format(tag) for tag in transformerror.tags)
new_file.write(rule_output.format(
transformerror.id, transformerror.shortdesc, transformerror.description, '', '', tags))

ruleerror = cfnlint.rules.RuleError()
tags = ','.join('`{0}`'.format(tag) for tag in ruleerror.tags)
new_file.write(
rule_output.format(ruleerror.id, ruleerror.shortdesc, ruleerror.description, '', '', tags))
for error in [cfnlint.rules.ParseError(), cfnlint.rules.TransformError(), cfnlint.rules.RuleError()]:
tags = ','.join('`{0}`'.format(tag) for tag in error.tags)
new_file.write(rule_output.format(error.id, error.shortdesc, error.description, '', '', tags))

# Seprate the experimental rules
experimental_rules = []
Expand Down
5 changes: 2 additions & 3 deletions test/unit/module/maintenance/test_update_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ class TestRuleWarning(CloudFormationLintRule):
call('\n'),
call('Regular Text\n'),
call('## Rules\n'),
call('The following **{}** rules are applied by this linter:\n'.format(
len(collection))),
call('(_This documentation is generated from the Rules, do not alter this manually_)\n\n'),
call('(_This documentation is generated by running `cfn-lint --update-documentation`, do not alter this manually_)\n\n'),
call('The following **{}** rules are applied by this linter:\n\n'.format(len(collection) + 3)),
PatMyron marked this conversation as resolved.
Show resolved Hide resolved
call('| Rule ID | Title | Description | Config<br />(Name:Type:Default) | Source | Tags |\n'),
call('| -------- | ----- | ----------- | ---------- | ------ | ---- |\n'),
call(
Expand Down