22 Commits

Author SHA1 Message Date
Fred Tingaud
d3cfe19d7e
Fix broken or dangerous backquotes
Co-authored-by: Marco Borgeaud <89914223+marco-antognini-sonarsource@users.noreply.github.com>
2023-10-30 10:33:56 +01:00
Marco Borgeaud
cd424756a0
Validate asciidoc ifdef/endif (#3311)
Fix kotlin:S6511
2023-10-18 09:43:40 +00:00
Marco Borgeaud
6398acacd9
Add CI task to test CI tests (#2768)
Extract the bits using the custom asciidoctor to a dedicated file.
This new script uses `set -e` to catch unexpected errors.
It is also covered with integration tests that get executed on the CI.

This serves as the groundwork to integrate more advanced validation
tests.
2023-08-03 17:21:40 +02:00
Marco Borgeaud
8c7e94cd08
Run include and cross-references validation on all files (#2685)
The previous validation code was taking about 3 minutes when running on
all rules, which is the case when modifying anything outside rules/,
including shared_content/.

The runtime was marginal when only the content specific to one rule was
modified, e.g. only rules/S100/cfamily/rule.adoc is modified.

The new validation code always takes about 30 seconds on the CI. This is
a slight increase for small PR but a large reduction for PR affecting
the whole system.

Furthermore, the new approach validates includes and cross-references
properly. An issue is now raised when:
 * The last include to shared_content/lang/foo.adoc is removed.
 * A shared_content doc includes a file from another rule, e.g.
   rules/S100/lang/rule.adoc includes shared_content/lang/foo.adoc,
   which includes rules/S200/bar.adoc.

This is achieved with proper Asciidoc extensions written in Ruby.
See https://docs.asciidoctor.org/asciidoctor/latest/extensions/
2023-08-02 09:21:56 +02:00
Marco Borgeaud
02dae8e652
Clean ci/validate_asciidoc.sh
* Regroup read-only variable declaration. `declare -xr` is used for
an exported read-only variable.
 * Use more accurate log messages.
 * Use consistent indentation of 2 spaces.
 * Fail fast if dependencies cannot be installed.
 * Regroup HTML generation & its validation.
 * Document the main validation points.
 * Simplify some commands and address some ShellCheck warnings.
2023-07-31 15:37:06 +02:00
Marco Borgeaud
f6a887100c
Revert "Clean ci/validate_asciidoc.sh (09a2902fe3b86)"
This reverts commit 09a2902fe3b8688ca6bc818c7c6055e2307e6235. It
introduced some regressions.
2023-07-31 13:11:14 +00:00
Marco Borgeaud
09a2902fe3
Clean ci/validate_asciidoc.sh (#2684)
* Regroup readonly variable declaration. `declare -xr` is used for exported readonly variable.
 * Use more accurate log messages.
 * Use consistent indentation of 2 spaces.
 * Fail fast if dependencies cannot be installed.
 * Regroup HTML generation & its validation.
 * Document the main validation points.
 * Simplify some commands and address some ShellCheck warnings.
2023-07-31 14:41:51 +02:00
Fred Tingaud
dc89dd499c
Create a shared_content folder at root 2023-07-20 12:17:32 +02:00
Fred Tingaud
83c54f9795
Handle variables *inside* an include
The point of this branch is the second commit that changes
validate_asciidoc.sh. The first one is taken from another PR and should
not be reviewed.

The previous version of the validation could handle the following case:
```asciidoc
:path: path/to/file.adoc
include::{path}[]
```

This new validation also adds support for the case of a variable inside
a path:
```asciidoc
:language: csharp
include::rules/S1000/{language}/file.adoc[]
```
2023-06-22 11:45:41 +02:00
Fred Tingaud
51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
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.
2023-06-22 10:38:01 +02:00
Fred Tingaud
3c08bcb34b
Support inclusions through variables 2023-06-02 17:10:20 +00:00
Ilia Kebets
c80d7f3b4c
Add checks for education format (#1607) 2023-03-07 17:16:47 +01:00
Roberto Orlandi
dc83422098 SONARSEC-3040 Update checks and documentation to fit new rule format (#1004) 2023-03-02 18:07:54 +01:00
Fred Tingaud
fc959bf040
Fix CI failure when no rule was changed (#791) 2022-02-08 11:00:03 +01:00
Fred Tingaud
f21f23b986
Treat all asciidoc at once to accelerate their validation 2022-02-07 18:22:30 +01:00
Fred Tingaud
b4161466e6
RULEAPI-661: Add syntax coloring 2022-02-04 16:28:24 +00:00
Marco Antognini
0dc00de844
Reduce amount of debug output in validate_asciidoc.sh 2022-02-03 12:21:42 +00:00
Fred Tingaud
7d868d3f35
Use a more readable form to display parameters 2022-02-01 12:25:23 +00:00
Čaba Šagi
6d8404981c
RULEAPI-642: Validate the level of section headers in asciidoc: make sure there are no level-0 2021-09-30 11:52:56 +02:00
Arseniy Zaostrovnykh
1128d6bf84
Fix the asciidoc validation CI check (#377) 2021-09-21 11:30:38 +02:00
Arseniy Zaostrovnykh
2784140e8b
RULEAPI-646: Speed up the "validate_asciidoc" check by validating only the changed rules 2021-06-09 11:15:47 +02:00
Arseniy Zaostrovnykh
16ca5fafaf
RULEAPI-649: Add frontend tests to CI 2021-06-08 15:21:29 +02:00