diff --git a/ci/asciidoc_validation/validate_environment.py b/ci/asciidoc_validation/validate_environment.py new file mode 100644 index 0000000000..4e451ca3b5 --- /dev/null +++ b/ci/asciidoc_validation/validate_environment.py @@ -0,0 +1,105 @@ +# Validate the asciidoc environment directives in the given file(s). +# Errors are printed to the standard output stream. +# +# "ifdef" commands has to start the line without any leading spaces, +# as per asciidoc format. +# +# Only one form is allowed: +# ifdef::env-github,rspecator-view[] +# +# The closing command is: +# endif::env-github,rspecator-view[] +# +# It must be in the same file. +# Only one such environment is allowed per file. + +from pathlib import Path +import sys + + +VALID_IFDEF = "ifdef::env-github,rspecator-view[]" +VALID_ENDIF = "endif::env-github,rspecator-view[]" + + +class Checker: + def __init__(self, file: Path): + assert file.exists() + assert file.is_file() + + self._file = file + self._is_env_open = False + self._has_env = False + self._is_valid = True + + def process(self) -> bool: + content = self._file.read_text(encoding="utf-8") + lines = content.splitlines(keepends=False) + for line_index, line in enumerate(lines): + line_number = line_index + 1 + if line.startswith("ifdef::"): + self._process_open(line_number, line) + if line.startswith("endif::"): + self._process_close(line_number, line) + + if self._is_env_open: + self._on_error(len(lines), "The ifdef command is not closed.") + + return self._is_valid + + def _process_open(self, line_number: int, line: str): + if self._has_env: + self._on_error(line_number, "Only one ifdef command is allowed per file.") + + if self._is_env_open: + self._on_error(line_number, "The previous ifdef command was not closed.") + + self._has_env = True + self._is_env_open = True + + # IDEs should be configured to properly display the description, + # not the other way around. + # "env-vscode" was used in the passed. Instead, user should be able to + # toggle the rspecator view based on their needs. Help these users migrate. + if "vscode" in line: + self._on_error( + line_number, + "Configure VS Code to display rspecator-view by setting the asciidoctor attribute.", + ) + + if line != VALID_IFDEF: + self._on_error( + line_number, + f'Incorrect asciidoc environment. "{VALID_IFDEF}" should be used instead.', + ) + + def _process_close(self, line_number: int, line: str): + if not self._is_env_open: + self._on_error(line_number, "Unexpected endif command.") + + self._is_env_open = False + + if line != VALID_ENDIF: + self._on_error( + line_number, + f'Incorrect endif command. "{VALID_ENDIF}" should be used instead.', + ) + + def _on_error(self, line_number: int, message: str): + print(f"{self._file}:{line_number} {message}") + self._is_valid = False + + +def main(): + files = sys.argv[1:] + if not files: + sys.exit("Missing input files") + + valid = True + for file in files: + if not Checker(Path(file)).process(): + valid = False + if not valid: + sys.exit(1) + +if __name__ == "__main__": + main() diff --git a/ci/validate_asciidoc.sh b/ci/validate_asciidoc.sh index 96ac40814f..fda29ad643 100755 --- a/ci/validate_asciidoc.sh +++ b/ci/validate_asciidoc.sh @@ -43,6 +43,7 @@ fi # * Only valid languages can be used as subdirectories in rule directories, # with the exception of ALLOWED_RULE_SUB_FOLDERS. # * Asciidoc files are free or errors and warnings. +# * ifdef/endif are used appropriatedly. # # [properties validated always on all rules] # * Rule descriptions can include other asciidoc files from the same rule @@ -85,6 +86,17 @@ do fi rm -f stuck + # Validate modified files' ifdef/endif commands. + find "${dir}" -name '*.adoc' \ + -exec python3 "./ci/asciidoc_validation/validate_environment.py" '{}' '+' \ + >validate_env_commands 2>&1 + if [ -s validate_env_commands ]; then + echo "ERROR: Some ifdef/endif commands are misused." + cat validate_env_commands + exit_code=1 + fi + rm -f validate_env_commands + for language in "${dir}"/*/ do language=${language%*/} diff --git a/rules/S1048/rspecator-dotnet.adoc b/rules/S1048/rspecator-dotnet.adoc index 0b37a8c2a5..33196bad9a 100644 --- a/rules/S1048/rspecator-dotnet.adoc +++ b/rules/S1048/rspecator-dotnet.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -21,4 +21,4 @@ The 'throw' statement. === on 1 Mar 2018, 17:03:27 Valeri Hristov wrote: Throwing in IDisposable.Dispose is covered in RSPEC-3877 -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S1128/python/rule.adoc b/rules/S1128/python/rule.adoc index 2e76ab5d71..0510d39c73 100644 --- a/rules/S1128/python/rule.adoc +++ b/rules/S1128/python/rule.adoc @@ -34,4 +34,6 @@ ifdef::env-github,rspecator-view[] include::../message.adoc[] -''' \ No newline at end of file +''' + +endif::env-github,rspecator-view[] diff --git a/rules/S1155/vbnet/rule.adoc b/rules/S1155/vbnet/rule.adoc index 9bb792eac8..87b41f48f6 100644 --- a/rules/S1155/vbnet/rule.adoc +++ b/rules/S1155/vbnet/rule.adoc @@ -49,4 +49,4 @@ ifdef::env-github,rspecator-view[] Use ".Any()" to test whether this "IEnumerable(Of XXX)" is empty or not. - +endif::env-github,rspecator-view[] diff --git a/rules/S1199/cfamily/rule.adoc b/rules/S1199/cfamily/rule.adoc index 64c90cca34..448fb24e07 100644 --- a/rules/S1199/cfamily/rule.adoc +++ b/rules/S1199/cfamily/rule.adoc @@ -90,4 +90,6 @@ include::../message.adoc[] == Comments And Links (visible only on this page) -include::../comments-and-links.adoc[] \ No newline at end of file +include::../comments-and-links.adoc[] + +endif::env-github,rspecator-view[] diff --git a/rules/S1199/csharp/rule.adoc b/rules/S1199/csharp/rule.adoc index 45b288cb61..9fec605d18 100644 --- a/rules/S1199/csharp/rule.adoc +++ b/rules/S1199/csharp/rule.adoc @@ -66,4 +66,6 @@ include::../message.adoc[] == Comments And Links (visible only on this page) -include::../comments-and-links.adoc[] \ No newline at end of file +include::../comments-and-links.adoc[] + +endif::env-github,rspecator-view[] diff --git a/rules/S1206/csharp/rule.adoc b/rules/S1206/csharp/rule.adoc index d3c0049159..efba7739cc 100644 --- a/rules/S1206/csharp/rule.adoc +++ b/rules/S1206/csharp/rule.adoc @@ -52,7 +52,7 @@ class MyClass * https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2[Dictionary Class] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -74,4 +74,4 @@ The [class|struct] name. include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S1479/rspecator-dotnet.adoc b/rules/S1479/rspecator-dotnet.adoc index 956558c9a2..7642ce2fca 100644 --- a/rules/S1479/rspecator-dotnet.adoc +++ b/rules/S1479/rspecator-dotnet.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -16,4 +16,4 @@ include::parameters.adoc[] include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S1656/csharp/rule.adoc b/rules/S1656/csharp/rule.adoc index eb27be401d..e9a253d587 100644 --- a/rules/S1656/csharp/rule.adoc +++ b/rules/S1656/csharp/rule.adoc @@ -43,7 +43,7 @@ public class Choice { * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs1717[Compiler Warning (level 3) CS1717] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -57,4 +57,4 @@ include::../message.adoc[] include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S1751/rspecator-dotnet.adoc b/rules/S1751/rspecator-dotnet.adoc index 6dda22bfa5..e611705656 100644 --- a/rules/S1751/rspecator-dotnet.adoc +++ b/rules/S1751/rspecator-dotnet.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -17,4 +17,4 @@ include::highlighting.adoc[] include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S1862/csharp/rule.adoc b/rules/S1862/csharp/rule.adoc index 12f7e5f37d..360db09ae1 100644 --- a/rules/S1862/csharp/rule.adoc +++ b/rules/S1862/csharp/rule.adoc @@ -52,7 +52,7 @@ else if (param == 3) * https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements#the-if-statement[The if statement] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -76,4 +76,4 @@ include::../highlighting.adoc[] include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S1862/vbnet/rule.adoc b/rules/S1862/vbnet/rule.adoc index b62790a2e6..b1afdbc0fd 100644 --- a/rules/S1862/vbnet/rule.adoc +++ b/rules/S1862/vbnet/rule.adoc @@ -41,7 +41,7 @@ End If * https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/if-then-else-statement[If...Then...Else Statement] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -59,4 +59,4 @@ include::../highlighting.adoc[] include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2076/csharp/rule.adoc b/rules/S2076/csharp/rule.adoc index 2b0be736ab..c1118ed49f 100644 --- a/rules/S2076/csharp/rule.adoc +++ b/rules/S2076/csharp/rule.adoc @@ -28,4 +28,4 @@ include::../message.adoc[] include::../comments-and-links.adoc[] -gndif::env-github,rspecator-view[] +endif::env-github,rspecator-view[] diff --git a/rules/S2076/javascript/rule.adoc b/rules/S2076/javascript/rule.adoc index 4801814575..e4c283b7b0 100644 --- a/rules/S2076/javascript/rule.adoc +++ b/rules/S2076/javascript/rule.adoc @@ -31,4 +31,4 @@ include::../message.adoc[] include::../comments-and-links.adoc[] -gndif::env-github,rspecator-view[] +endif::env-github,rspecator-view[] diff --git a/rules/S2076/php/rule.adoc b/rules/S2076/php/rule.adoc index 767ea213f1..cbf8935fc1 100644 --- a/rules/S2076/php/rule.adoc +++ b/rules/S2076/php/rule.adoc @@ -30,4 +30,4 @@ include::../message.adoc[] include::../comments-and-links.adoc[] -gndif::env-github,rspecator-view[] +endif::env-github,rspecator-view[] diff --git a/rules/S2076/python/rule.adoc b/rules/S2076/python/rule.adoc index d0d837971d..bc22725c2c 100644 --- a/rules/S2076/python/rule.adoc +++ b/rules/S2076/python/rule.adoc @@ -32,4 +32,4 @@ include::../message.adoc[] include::../comments-and-links.adoc[] -gndif::env-github,rspecator-view[] +endif::env-github,rspecator-view[] diff --git a/rules/S2183/rspecator.adoc b/rules/S2183/rspecator.adoc index 9d3043d6c9..6624690544 100644 --- a/rules/S2183/rspecator.adoc +++ b/rules/S2183/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -18,4 +18,4 @@ Remove this useless shift (multiple of 32/64). include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2190/csharp/rule.adoc b/rules/S2190/csharp/rule.adoc index 1f0841200c..909be80bfc 100644 --- a/rules/S2190/csharp/rule.adoc +++ b/rules/S2190/csharp/rule.adoc @@ -173,7 +173,7 @@ int Pow(int num, int exponent) * Edsger Dijkstra - https://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD215.html[A Case against the GO TO Statement] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -189,5 +189,5 @@ Add a way to break out of this \[[method|property|property accessor]'s recursion include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2225/rspecator.adoc b/rules/S2225/rspecator.adoc index 89402cf5be..cd3ab2417b 100644 --- a/rules/S2225/rspecator.adoc +++ b/rules/S2225/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -12,4 +12,4 @@ include::message.adoc[] include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2251/rspecator.adoc b/rules/S2251/rspecator.adoc index 669104ceb6..b12d21e3ba 100644 --- a/rules/S2251/rspecator.adoc +++ b/rules/S2251/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -19,4 +19,4 @@ In fact, it's not an infinite loop because of integer overflow. On my computer, In JavaScript, moving the counter in the wrong direction causes an infinite loop because there is no integer type. All numbers are 64 bit floating point numbers. -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2252/rspecator.adoc b/rules/S2252/rspecator.adoc index f27b41b9e9..0a2c0bfef5 100644 --- a/rules/S2252/rspecator.adoc +++ b/rules/S2252/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -24,4 +24,4 @@ To me the 2 title versions are six-of-one-half-dozen-of-the-other. But given tha === on 2 Dec 2014, 15:02:37 Pierre-Yves Nicolas wrote: No, I don't care much. -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S2259/rspecator-dotnet.adoc b/rules/S2259/rspecator-dotnet.adoc index 90bb843dd7..1275e430a8 100644 --- a/rules/S2259/rspecator-dotnet.adoc +++ b/rules/S2259/rspecator-dotnet.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -14,4 +14,4 @@ include::./highlighting.adoc[] include::./comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S2291/rspecator.adoc b/rules/S2291/rspecator.adoc index d56c2d4aa1..f31b41de52 100644 --- a/rules/S2291/rspecator.adoc +++ b/rules/S2291/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -28,4 +28,4 @@ Double-check my edits please [~tamas.vajk] === on 6 Jul 2015, 09:33:41 Tamas Vajk wrote: \[~ann.campbell.2] Looks good. -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2318/python/rule.adoc b/rules/S2318/python/rule.adoc index 286827dba8..4112a6e5b8 100644 --- a/rules/S2318/python/rule.adoc +++ b/rules/S2318/python/rule.adoc @@ -41,4 +41,4 @@ ifdef::env-github,rspecator-view[] Use "!=" instead. -endif::env-github,rspecator-view[] +endif::env-github,rspecator-view[] diff --git a/rules/S2551/rspecator.adoc b/rules/S2551/rspecator.adoc index 0260ce2a65..b1736a3f0b 100644 --- a/rules/S2551/rspecator.adoc +++ b/rules/S2551/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -12,4 +12,4 @@ include::message.adoc[] include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S2688/csharp/rule.adoc b/rules/S2688/csharp/rule.adoc index ccec69a042..f029925ba4 100644 --- a/rules/S2688/csharp/rule.adoc +++ b/rules/S2688/csharp/rule.adoc @@ -43,7 +43,7 @@ if (!double.IsNaN(a)) ---- -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -60,4 +60,4 @@ Use [double|float].IsNaN() instead. include::../comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2934/csharp/rule.adoc b/rules/S2934/csharp/rule.adoc index e2c579ff3b..26c6ee35f4 100644 --- a/rules/S2934/csharp/rule.adoc +++ b/rules/S2934/csharp/rule.adoc @@ -85,7 +85,7 @@ class PointManager * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct[Structure types (C# reference)] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -118,4 +118,4 @@ Looks good, I adjusted some wording in the first sentence of the description === on 22 May 2015, 12:10:14 Ann Campbell wrote: Thanks [~tamas.vajk]. Looks good -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S2995/csharp/rule.adoc b/rules/S2995/csharp/rule.adoc index 6153807026..31aa72e342 100644 --- a/rules/S2995/csharp/rule.adoc +++ b/rules/S2995/csharp/rule.adoc @@ -83,7 +83,7 @@ static class MyClass * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/struct[Structure types (C# reference)] * S3898 - Value types should implement "IEquatable" -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -103,4 +103,4 @@ Use a different kind of comparison for these value types. === on 8 Jun 2015, 09:32:21 Tamas Vajk wrote: LGTM, I've changed the `object` to `Object` just to conform to the title, but there is no difference, because `object` is just an alias for `System.Object` -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3168/csharp/rule.adoc b/rules/S3168/csharp/rule.adoc index 83b9d3fd4c..c26b0c7816 100644 --- a/rules/S3168/csharp/rule.adoc +++ b/rules/S3168/csharp/rule.adoc @@ -98,7 +98,7 @@ public void Method() * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/api/system.eventhandler[`EventHandler` Delegate] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -134,4 +134,4 @@ A method with `async` keyword returning a `Task` is like a non `async` method wi === on 1 Jul 2015, 11:59:39 Ann Campbell wrote: Okay, thanks [~tamas.vajk] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3244/rspecator.adoc b/rules/S3244/rspecator.adoc index 5b55c63da3..6db623f4cb 100644 --- a/rules/S3244/rspecator.adoc +++ b/rules/S3244/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -27,4 +27,4 @@ updated. See what you think [~tamas.vajk] === on 20 Jul 2015, 11:44:56 Tamas Vajk wrote: \[~ann.campbell.2] Looks good. -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3343/csharp/rule.adoc b/rules/S3343/csharp/rule.adoc index b7af04f12b..4f21572115 100644 --- a/rules/S3343/csharp/rule.adoc +++ b/rules/S3343/csharp/rule.adoc @@ -52,7 +52,7 @@ void TraceMessage(string message = null, * https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerargumentexpressionattribute[CallerArgumentExpressionAttribute Class] * https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments#optional-arguments[Named and Optional Arguments] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -76,4 +76,4 @@ And also modified the last sentence. It is possible to not specify all parameter === on 18 Nov 2015, 19:55:28 Ann Campbell wrote: Okay, thanks [~tamas.vajk] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3453/rspecator.adoc b/rules/S3453/rspecator.adoc index b30d0ed42c..be2498f36e 100644 --- a/rules/S3453/rspecator.adoc +++ b/rules/S3453/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -23,4 +23,4 @@ class name done [~tamas.vajk] -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S3466/rspecator.adoc b/rules/S3466/rspecator.adoc index 5915957457..c6fd2dac12 100644 --- a/rules/S3466/rspecator.adoc +++ b/rules/S3466/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -14,4 +14,4 @@ include::highlighting.adoc[] include::comments-and-links.adoc[] -endif::env-github,rspecator-view,env-vscode[] \ No newline at end of file +endif::env-github,rspecator-view[] \ No newline at end of file diff --git a/rules/S3598/csharp/rule.adoc b/rules/S3598/csharp/rule.adoc index 145369d87d..7b9f6fd434 100644 --- a/rules/S3598/csharp/rule.adoc +++ b/rules/S3598/csharp/rule.adoc @@ -32,7 +32,7 @@ interface IMyService include::../resources.adoc[] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -42,4 +42,4 @@ include::../message.adoc[] include::../highlighting.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3598/vbnet/rule.adoc b/rules/S3598/vbnet/rule.adoc index 3cc2067be0..3ecca68daf 100644 --- a/rules/S3598/vbnet/rule.adoc +++ b/rules/S3598/vbnet/rule.adoc @@ -30,7 +30,7 @@ End Interface include::../resources.adoc[] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -40,4 +40,4 @@ include::../message.adoc[] include::../highlighting.adoc[] -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3610/csharp/rule.adoc b/rules/S3610/csharp/rule.adoc index 1202e66c7a..7d258ffb27 100644 --- a/rules/S3610/csharp/rule.adoc +++ b/rules/S3610/csharp/rule.adoc @@ -45,7 +45,7 @@ void DoChecks(Nullable value) where T : struct * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/api/system.nullreferenceexception[NullReferenceException Class] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -103,4 +103,4 @@ ____ But if C#ers will understand, I'm good with it. -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3904/rspecator.adoc b/rules/S3904/rspecator.adoc index 5c08de42dc..f46bbcc110 100644 --- a/rules/S3904/rspecator.adoc +++ b/rules/S3904/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -12,4 +12,4 @@ Provide an 'AssemblyVersion' attribute for assembly 'xxx'. Assembly declaration -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S3925/csharp/rule.adoc b/rules/S3925/csharp/rule.adoc index 4a165f4847..c94444d08a 100644 --- a/rules/S3925/csharp/rule.adoc +++ b/rules/S3925/csharp/rule.adoc @@ -191,7 +191,7 @@ public class UnsealedFoo : Foo * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable.getobjectdata[`ISerializable.GetObjectData` Method] * Microsoft Learn - https://learn.microsoft.com/en-us/dotnet/api/system.exception[`Exception` Class] -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -228,4 +228,4 @@ The following check is not implemented because it is difficult to know exactly w We find mostly classes that derive from Exception in the projects we test and that's why they might not be a good source for checking issues and false positives (statistically). -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S4015/rspecator.adoc b/rules/S4015/rspecator.adoc index 03bc27ece8..ed3f871897 100644 --- a/rules/S4015/rspecator.adoc +++ b/rules/S4015/rspecator.adoc @@ -1,4 +1,4 @@ -ifdef::env-github,rspecator-view,env-vscode[] +ifdef::env-github,rspecator-view[] ''' == Implementation Specification @@ -29,4 +29,4 @@ member declaration === on 22 May 2017, 15:10:29 Ann Campbell wrote: Okay, then RSPEC-3434 is the related RSpec, altho it's scope is different. I've added it as 'related' -endif::env-github,rspecator-view,env-vscode[] +endif::env-github,rspecator-view[] diff --git a/rules/S4487/python/rule.adoc b/rules/S4487/python/rule.adoc index dc7e71c2cb..5f843947a9 100644 --- a/rules/S4487/python/rule.adoc +++ b/rules/S4487/python/rule.adoc @@ -85,3 +85,5 @@ False Enable issues on unread attributes with a single underscore prefix **** + +endif::env-github,rspecator-view[] diff --git a/rules/S6321/azureresourcemanager/rule.adoc b/rules/S6321/azureresourcemanager/rule.adoc index 1ae6ba076e..706f52f7f0 100644 --- a/rules/S6321/azureresourcemanager/rule.adoc +++ b/rules/S6321/azureresourcemanager/rule.adoc @@ -106,3 +106,5 @@ ifdef::env-github,rspecator-view[] (visible only on this page) ''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6321/cloudformation/rule.adoc b/rules/S6321/cloudformation/rule.adoc index 76fe84117a..9fe670f774 100644 --- a/rules/S6321/cloudformation/rule.adoc +++ b/rules/S6321/cloudformation/rule.adoc @@ -64,3 +64,5 @@ ifdef::env-github,rspecator-view[] (visible only on this page) ''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6321/javascript/rule.adoc b/rules/S6321/javascript/rule.adoc index 9a8bab6f32..9d0b33441d 100644 --- a/rules/S6321/javascript/rule.adoc +++ b/rules/S6321/javascript/rule.adoc @@ -204,3 +204,5 @@ In any other case, when a dangerous peer definition is identified: ''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6321/python/rule.adoc b/rules/S6321/python/rule.adoc index 15a401562b..fee9da42b2 100644 --- a/rules/S6321/python/rule.adoc +++ b/rules/S6321/python/rule.adoc @@ -250,3 +250,5 @@ In any other case, when a dangerous peer definition is identified: ''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6321/terraform/rule.adoc b/rules/S6321/terraform/rule.adoc index dd24c80069..2bcf5f7829 100644 --- a/rules/S6321/terraform/rule.adoc +++ b/rules/S6321/terraform/rule.adoc @@ -135,3 +135,5 @@ ifdef::env-github,rspecator-view[] (visible only on this page) ''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6422/csharp/rule.adoc b/rules/S6422/csharp/rule.adoc index 3e1f6218ba..8392dedf38 100644 --- a/rules/S6422/csharp/rule.adoc +++ b/rules/S6422/csharp/rule.adoc @@ -63,3 +63,5 @@ ifdef::env-github,rspecator-view[] (visible only on this page) The implementation should be common with S4462. When implementing, should make sure S4462 will ignore Azure Functions. + +endif::env-github,rspecator-view[] diff --git a/rules/S6506/docker/rule.adoc b/rules/S6506/docker/rule.adoc index 7ea58c8fe5..124339c430 100644 --- a/rules/S6506/docker/rule.adoc +++ b/rules/S6506/docker/rule.adoc @@ -119,3 +119,4 @@ For `wget`: * Highlight the `wget` command and the URL. +endif::env-github,rspecator-view[] diff --git a/rules/S6511/kotlin/rule.adoc b/rules/S6511/kotlin/rule.adoc index 439e0c123a..6b1774aba0 100644 --- a/rules/S6511/kotlin/rule.adoc +++ b/rules/S6511/kotlin/rule.adoc @@ -82,6 +82,18 @@ fun compare(a: Int, b: Int): Int { } ---- +== Resources + +=== Documentation + +* https://kotlinlang.org/docs/control-flow.html#when-expression[Kotlin Docs, When expression] + +=== Articles & blog posts + +* https://www.baeldung.com/kotlin/when[Baeldung, Guide to the “when{}” Block in Kotlin] +* https://superkotlin.com/kotlin-when-statement[Kotlin when: A switch with Superpowers] +* https://www.sonarsource.com/resources/cognitive-complexity[G. Ann Campbell, Cognitive Complexity] + ifdef::env-github,rspecator-view[] == Implementation Specification @@ -99,16 +111,4 @@ ifdef::env-github,rspecator-view[] Number of "if" after which the chain should be replaced by a "when" statement. **** -endif::[] - -== Resources - -=== Documentation - -* https://kotlinlang.org/docs/control-flow.html#when-expression[Kotlin Docs, When expression] - -=== Articles & blog posts - -* https://www.baeldung.com/kotlin/when[Baeldung, Guide to the “when{}” Block in Kotlin] -* https://superkotlin.com/kotlin-when-statement[Kotlin when: A switch with Superpowers] -* https://www.sonarsource.com/resources/cognitive-complexity[G. Ann Campbell, Cognitive Complexity] +endif::env-github,rspecator-view[] diff --git a/rules/S6639/csharp/rule.adoc b/rules/S6639/csharp/rule.adoc index c617a53e4e..b1c3cf69c8 100644 --- a/rules/S6639/csharp/rule.adoc +++ b/rules/S6639/csharp/rule.adoc @@ -36,4 +36,6 @@ ifdef::env-github,rspecator-view[] include::../common/message.adoc[] -''' \ No newline at end of file +''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6639/python/rule.adoc b/rules/S6639/python/rule.adoc index b3712fd986..5fed1a05c5 100644 --- a/rules/S6639/python/rule.adoc +++ b/rules/S6639/python/rule.adoc @@ -61,4 +61,6 @@ ifdef::env-github,rspecator-view[] include::../common/message.adoc[] -''' \ No newline at end of file +''' + +endif::env-github,rspecator-view[] diff --git a/rules/S6641/csharp/rule.adoc b/rules/S6641/csharp/rule.adoc index 491080a136..21ca88effb 100644 --- a/rules/S6641/csharp/rule.adoc +++ b/rules/S6641/csharp/rule.adoc @@ -40,3 +40,5 @@ include::../common/message.adoc[] include::../common/highlighting.adoc[] ''' + +endif::env-github,rspecator-view[]