When there are multiple sonarpedia.json files for the same language, the rules
picked up for the next sonarpedia.json file will override the ones picked up
previously. With this fix, the rules are not overwritten but all are collected,
so one repository can have multiple sonarpedia.json files for the same language.
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
There was already a check for section duplication, but only in "How to
fix it". This changes the test to cover all sections.
And fixing the rules that this new validation fails on.
Also making test_modify_rule.py run on Windows.
---------
Co-authored-by: Christophe Zürn <36889251+christophe-zurn-sonarsource@users.noreply.github.com>
Triggered by the deployment failure that was caused by an invisible Unicode character in a rule's metadata.json.
This PR implements three conceptual changes:
- make the deployment parse error more informative
- prohibit the use of non-ASCII characters in the metadata.json files
- remove the existing non-ASCII characters from the existing rules
This removes the dependency on online repositories (on GitHub)
and speeds up the test by stripping the number of versions and files to a minimum.
Prepare the ground for RULEAPI-753.
The main changes are:
* Split RuleCreator: move some of its content to RspecRepo and to
RuleEditor in new modules.
* Refactor tests accordingly.
Other less important changes:
* Sort and remove unnecessary imports
* Remove unimplemented functions and unnecessary classes
* Make some functions private
* Move pushd from utils to tests where it is only used
* Reduce code duplication here and there
* Remove unnecessary Mock in some tests
* Improve coverage for add_language_to_rule
* Generate description and metadata for rules with no language, so that they get indexed.
* Index rules with different types in language specializations.
* Improve validation to reject new rules with no language specialization (i.e. only a predefined set of such rules is allowed because they were imported from Jira and kept for historical purposes).
* Write smaller JSON files, reduce their size by 30%.
* Improve test coverage of CLI application.