RULEAPI-598 Provide a way to name a language subdirectory correctly (when specializing a rule)

This commit is contained in:
Amélie Renard 2021-05-03 21:31:58 +02:00 committed by GitHub
parent 97cd183fc2
commit a3a9dd10a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -17,7 +17,9 @@ WARNING: **Beta status**: This repository is not used yet in production. The cur
** `rules/Sxxxx`: contains every specification for rule `Sxxxx`.
*** `rules/Sxxxx/*.adoc`: Asciidoc files which can be reused by multiple language-specific descriptions.
*** `rules/Sxxxx/metadata.json`: rule metadata shared between language-specific RSPECs. Each language can override fields in its own `metadata.json` file.
*** `rules/Sxxxx/[LANGUAGE]`: contains the language-specific RSPEC. For every rule, there must be at least one `[LANGUAGE]` subdirectory. `[LANGUAGE]` can be `java`, `cfamily`, `python`...
*** `rules/Sxxxx/[LANGUAGE]`: contains the language-specific RSPEC. For every rule, there must be at least one `[LANGUAGE]` subdirectory. +
`[LANGUAGE]` can be any of the following:
include::supported_languages.adoc[]
**** `rules/Sxxxx/[LANGUAGE]/rule.adoc`: asciidoc file used to generate the `Sxxxx` rule description for programming language `[LANGUAGE]`. It can include parts from `*.adoc` files located in the parent directory.
**** `rules/Sxxxx/[LANGUAGE]/metadata.json`: metadatas for the specific language. Each key at the top will completely override the key of the `metadata.json` file of the parent directory.
@ -38,7 +40,9 @@ However, one of the reasons we are migrating to a git repository is that we want
==== For a new rule
1. go to the https://github.com/SonarSource/rspec/actions/workflows/create_new_rspec.yml[Create new RSPEC] GitHub action
2. click on the grey _Run wokflow_ button (on the right).
3. in the field _"Comma-separated list of targeted languages"_ write the list of languages you want to specify this rule for.
3. in the field _"Comma-separated list of targeted languages"_ write the list of languages you want to specify this rule for. +
They can be any of the following:
include::supported_languages.adoc[]
4. click on the green _Run workflow_ button.
image::img/new-rule-workflow.png[]

1
supported_languages.adoc Normal file
View File

@ -0,0 +1 @@
`abap`, `apex`, `cfamily`, `cobol`, `csharp`, `css`, `flex`, `go`, `html`, `java`, `javascript`, `kotlin`, `php`, `pli`, `plsql`, `python`, `rpg`, `ruby`, `rust`, `scala`, `solidity`, `swift`, `tsql`, `vb6`, `vbnet`, or `xml`

View File

@ -17,10 +17,15 @@ do
fi
else
#validate asciidoc
for language in $dir/*/
supportedLanguages=$(sed 's/ or//' supported_languages.adoc | tr -d '`,')
for language in $dir/*/
do
language=${language%*/}
echo ${language##*/}
if [[ ! "${supportedLanguages[@]}" =~ "${language##*/}" ]]; then
echo "ERROR: ${language##*/} is not a supported language"
exit_code=1
fi
RULE="$language/rule.adoc"
if test -f $RULE; then
echo "$RULE exists."
@ -42,4 +47,4 @@ do
fi
done
exit $exit_code
exit $exit_code