@owenlamont/ryl 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +13 -0
  2. package/bin/ryl.js +195 -1
  3. package/package.json +35 -13
  4. package/.github/CODEOWNERS +0 -1
  5. package/.github/dependabot.yml +0 -13
  6. package/.github/workflows/ci.yml +0 -107
  7. package/.github/workflows/release.yml +0 -613
  8. package/.github/workflows/update_dependencies.yml +0 -61
  9. package/.github/workflows/update_linters.yml +0 -56
  10. package/.pre-commit-config.yaml +0 -87
  11. package/.yamllint +0 -4
  12. package/AGENTS.md +0 -200
  13. package/Cargo.lock +0 -908
  14. package/Cargo.toml +0 -32
  15. package/clippy.toml +0 -1
  16. package/docs/config-presets.md +0 -100
  17. package/img/benchmark-5x5-5runs.svg +0 -2176
  18. package/pyproject.toml +0 -42
  19. package/ruff.toml +0 -107
  20. package/rumdl.toml +0 -20
  21. package/rust-toolchain.toml +0 -3
  22. package/rustfmt.toml +0 -3
  23. package/scripts/benchmark_perf_vs_yamllint.py +0 -400
  24. package/scripts/coverage-missing.ps1 +0 -80
  25. package/scripts/coverage-missing.sh +0 -60
  26. package/src/bin/discover_config_bin.rs +0 -24
  27. package/src/cli_support.rs +0 -33
  28. package/src/conf/mod.rs +0 -85
  29. package/src/config.rs +0 -2099
  30. package/src/decoder.rs +0 -326
  31. package/src/discover.rs +0 -31
  32. package/src/lib.rs +0 -19
  33. package/src/lint.rs +0 -558
  34. package/src/main.rs +0 -535
  35. package/src/migrate.rs +0 -233
  36. package/src/rules/anchors.rs +0 -517
  37. package/src/rules/braces.rs +0 -77
  38. package/src/rules/brackets.rs +0 -77
  39. package/src/rules/colons.rs +0 -475
  40. package/src/rules/commas.rs +0 -372
  41. package/src/rules/comments.rs +0 -299
  42. package/src/rules/comments_indentation.rs +0 -243
  43. package/src/rules/document_end.rs +0 -175
  44. package/src/rules/document_start.rs +0 -84
  45. package/src/rules/empty_lines.rs +0 -152
  46. package/src/rules/empty_values.rs +0 -255
  47. package/src/rules/float_values.rs +0 -259
  48. package/src/rules/flow_collection.rs +0 -562
  49. package/src/rules/hyphens.rs +0 -104
  50. package/src/rules/indentation.rs +0 -803
  51. package/src/rules/key_duplicates.rs +0 -218
  52. package/src/rules/key_ordering.rs +0 -303
  53. package/src/rules/line_length.rs +0 -326
  54. package/src/rules/mod.rs +0 -25
  55. package/src/rules/new_line_at_end_of_file.rs +0 -23
  56. package/src/rules/new_lines.rs +0 -95
  57. package/src/rules/octal_values.rs +0 -121
  58. package/src/rules/quoted_strings.rs +0 -577
  59. package/src/rules/span_utils.rs +0 -37
  60. package/src/rules/trailing_spaces.rs +0 -65
  61. package/src/rules/truthy.rs +0 -420
  62. package/tests/brackets_carriage_return.rs +0 -114
  63. package/tests/build_global_cfg_error.rs +0 -23
  64. package/tests/cli_anchors_rule.rs +0 -143
  65. package/tests/cli_braces_rule.rs +0 -104
  66. package/tests/cli_brackets_rule.rs +0 -104
  67. package/tests/cli_colons_rule.rs +0 -65
  68. package/tests/cli_commas_rule.rs +0 -104
  69. package/tests/cli_comments_indentation_rule.rs +0 -61
  70. package/tests/cli_comments_rule.rs +0 -67
  71. package/tests/cli_config_data_error.rs +0 -30
  72. package/tests/cli_config_flags.rs +0 -66
  73. package/tests/cli_config_migrate.rs +0 -229
  74. package/tests/cli_document_end_rule.rs +0 -92
  75. package/tests/cli_document_start_rule.rs +0 -92
  76. package/tests/cli_empty_lines_rule.rs +0 -87
  77. package/tests/cli_empty_values_rule.rs +0 -68
  78. package/tests/cli_env_config.rs +0 -34
  79. package/tests/cli_exit_and_errors.rs +0 -41
  80. package/tests/cli_file_encoding.rs +0 -203
  81. package/tests/cli_float_values_rule.rs +0 -64
  82. package/tests/cli_format_options.rs +0 -316
  83. package/tests/cli_global_cfg_relaxed.rs +0 -20
  84. package/tests/cli_hyphens_rule.rs +0 -104
  85. package/tests/cli_indentation_rule.rs +0 -65
  86. package/tests/cli_invalid_project_config.rs +0 -39
  87. package/tests/cli_key_duplicates_rule.rs +0 -104
  88. package/tests/cli_key_ordering_rule.rs +0 -59
  89. package/tests/cli_line_length_rule.rs +0 -85
  90. package/tests/cli_list_files.rs +0 -29
  91. package/tests/cli_new_line_rule.rs +0 -141
  92. package/tests/cli_new_lines_rule.rs +0 -119
  93. package/tests/cli_octal_values_rule.rs +0 -60
  94. package/tests/cli_quoted_strings_rule.rs +0 -47
  95. package/tests/cli_toml_config.rs +0 -119
  96. package/tests/cli_trailing_spaces_rule.rs +0 -77
  97. package/tests/cli_truthy_rule.rs +0 -83
  98. package/tests/cli_yaml_files_negation.rs +0 -45
  99. package/tests/colons_rule.rs +0 -303
  100. package/tests/common/compat.rs +0 -114
  101. package/tests/common/fake_env.rs +0 -93
  102. package/tests/common/mod.rs +0 -1
  103. package/tests/conf_builtin.rs +0 -9
  104. package/tests/config_anchors.rs +0 -84
  105. package/tests/config_braces.rs +0 -121
  106. package/tests/config_brackets.rs +0 -127
  107. package/tests/config_commas.rs +0 -79
  108. package/tests/config_comments.rs +0 -65
  109. package/tests/config_comments_indentation.rs +0 -20
  110. package/tests/config_deep_merge_nonstring_key.rs +0 -24
  111. package/tests/config_document_end.rs +0 -54
  112. package/tests/config_document_start.rs +0 -55
  113. package/tests/config_empty_lines.rs +0 -48
  114. package/tests/config_empty_values.rs +0 -35
  115. package/tests/config_env_errors.rs +0 -23
  116. package/tests/config_env_invalid_inline.rs +0 -15
  117. package/tests/config_env_missing.rs +0 -63
  118. package/tests/config_env_shim.rs +0 -301
  119. package/tests/config_explicit_file_parse_error.rs +0 -55
  120. package/tests/config_extended_features.rs +0 -225
  121. package/tests/config_extends_inline.rs +0 -185
  122. package/tests/config_extends_sequence.rs +0 -18
  123. package/tests/config_find_project_home_boundary.rs +0 -54
  124. package/tests/config_find_project_two_files_in_cwd.rs +0 -47
  125. package/tests/config_float_values.rs +0 -34
  126. package/tests/config_from_yaml_paths.rs +0 -32
  127. package/tests/config_hyphens.rs +0 -51
  128. package/tests/config_ignore_errors.rs +0 -243
  129. package/tests/config_ignore_overrides.rs +0 -83
  130. package/tests/config_indentation.rs +0 -65
  131. package/tests/config_invalid_globs.rs +0 -16
  132. package/tests/config_invalid_types.rs +0 -19
  133. package/tests/config_key_duplicates.rs +0 -34
  134. package/tests/config_key_ordering.rs +0 -70
  135. package/tests/config_line_length.rs +0 -65
  136. package/tests/config_locale.rs +0 -111
  137. package/tests/config_merge.rs +0 -26
  138. package/tests/config_new_lines.rs +0 -89
  139. package/tests/config_octal_values.rs +0 -33
  140. package/tests/config_quoted_strings.rs +0 -195
  141. package/tests/config_rule_level.rs +0 -147
  142. package/tests/config_rules_non_string_keys.rs +0 -23
  143. package/tests/config_scalar_overrides.rs +0 -27
  144. package/tests/config_to_toml.rs +0 -110
  145. package/tests/config_toml_coverage.rs +0 -80
  146. package/tests/config_toml_discovery.rs +0 -304
  147. package/tests/config_trailing_spaces.rs +0 -152
  148. package/tests/config_truthy.rs +0 -77
  149. package/tests/config_yaml_files.rs +0 -62
  150. package/tests/config_yaml_files_all_non_string.rs +0 -15
  151. package/tests/config_yaml_files_empty.rs +0 -30
  152. package/tests/coverage_commas.rs +0 -46
  153. package/tests/decoder_decode.rs +0 -338
  154. package/tests/discover_config_bin_all.rs +0 -66
  155. package/tests/discover_config_bin_env_invalid_yaml.rs +0 -26
  156. package/tests/discover_config_bin_project_config_parse_error.rs +0 -24
  157. package/tests/discover_config_bin_user_global_error.rs +0 -26
  158. package/tests/discover_module.rs +0 -30
  159. package/tests/discover_per_file_dir.rs +0 -10
  160. package/tests/discover_per_file_project_config_error.rs +0 -21
  161. package/tests/float_values.rs +0 -43
  162. package/tests/lint_multi_errors.rs +0 -32
  163. package/tests/main_yaml_ok_filtering.rs +0 -30
  164. package/tests/migrate_module.rs +0 -259
  165. package/tests/resolve_ctx_empty_parent.rs +0 -16
  166. package/tests/rule_anchors.rs +0 -442
  167. package/tests/rule_braces.rs +0 -258
  168. package/tests/rule_brackets.rs +0 -217
  169. package/tests/rule_commas.rs +0 -205
  170. package/tests/rule_comments.rs +0 -197
  171. package/tests/rule_comments_indentation.rs +0 -127
  172. package/tests/rule_document_end.rs +0 -118
  173. package/tests/rule_document_start.rs +0 -60
  174. package/tests/rule_empty_lines.rs +0 -96
  175. package/tests/rule_empty_values.rs +0 -102
  176. package/tests/rule_float_values.rs +0 -109
  177. package/tests/rule_hyphens.rs +0 -65
  178. package/tests/rule_indentation.rs +0 -455
  179. package/tests/rule_key_duplicates.rs +0 -76
  180. package/tests/rule_key_ordering.rs +0 -207
  181. package/tests/rule_line_length.rs +0 -200
  182. package/tests/rule_new_lines.rs +0 -51
  183. package/tests/rule_octal_values.rs +0 -53
  184. package/tests/rule_quoted_strings.rs +0 -290
  185. package/tests/rule_trailing_spaces.rs +0 -41
  186. package/tests/rule_truthy.rs +0 -236
  187. package/tests/user_global_invalid_yaml.rs +0 -32
  188. package/tests/yamllint_compat_anchors.rs +0 -280
  189. package/tests/yamllint_compat_braces.rs +0 -411
  190. package/tests/yamllint_compat_brackets.rs +0 -364
  191. package/tests/yamllint_compat_colons.rs +0 -298
  192. package/tests/yamllint_compat_colors.rs +0 -80
  193. package/tests/yamllint_compat_commas.rs +0 -375
  194. package/tests/yamllint_compat_comments.rs +0 -167
  195. package/tests/yamllint_compat_comments_indentation.rs +0 -281
  196. package/tests/yamllint_compat_config.rs +0 -170
  197. package/tests/yamllint_compat_document_end.rs +0 -243
  198. package/tests/yamllint_compat_document_start.rs +0 -136
  199. package/tests/yamllint_compat_empty_lines.rs +0 -117
  200. package/tests/yamllint_compat_empty_values.rs +0 -179
  201. package/tests/yamllint_compat_float_values.rs +0 -216
  202. package/tests/yamllint_compat_hyphens.rs +0 -223
  203. package/tests/yamllint_compat_indentation.rs +0 -398
  204. package/tests/yamllint_compat_key_duplicates.rs +0 -139
  205. package/tests/yamllint_compat_key_ordering.rs +0 -170
  206. package/tests/yamllint_compat_line_length.rs +0 -375
  207. package/tests/yamllint_compat_list.rs +0 -127
  208. package/tests/yamllint_compat_new_line.rs +0 -133
  209. package/tests/yamllint_compat_newline_types.rs +0 -185
  210. package/tests/yamllint_compat_octal_values.rs +0 -172
  211. package/tests/yamllint_compat_quoted_strings.rs +0 -154
  212. package/tests/yamllint_compat_syntax.rs +0 -200
  213. package/tests/yamllint_compat_trailing_spaces.rs +0 -162
  214. package/tests/yamllint_compat_truthy.rs +0 -130
  215. package/tests/yamllint_compat_yaml_files.rs +0 -81
  216. package/typos.toml +0 -2
@@ -1,127 +0,0 @@
1
- use ryl::rules::comments_indentation::{self, Config, Violation};
2
-
3
- fn run(input: &str) -> Vec<Violation> {
4
- comments_indentation::check(input, &Config)
5
- }
6
-
7
- #[test]
8
- fn empty_input_returns_no_hits() {
9
- let hits = run("");
10
- assert!(hits.is_empty());
11
- }
12
-
13
- #[test]
14
- fn accepts_aligned_comment_inside_mapping() {
15
- let input = "obj:\n # ok\n value: 1\n";
16
- let hits = run(input);
17
- assert!(hits.is_empty());
18
- }
19
-
20
- #[test]
21
- fn rejects_comment_with_extra_indent() {
22
- let input = "obj:\n # wrong\n value: 1\n";
23
- let hits = run(input);
24
- assert_eq!(hits, vec![Violation { line: 2, column: 2 }]);
25
- }
26
-
27
- #[test]
28
- fn rejects_comment_after_comment_block_reset() {
29
- let input = "obj1:\n a: 1\n# heading\n # misplaced\nobj2: no\n";
30
- let hits = run(input);
31
- assert_eq!(hits, vec![Violation { line: 4, column: 3 }]);
32
- }
33
-
34
- #[test]
35
- fn rejects_comment_after_inline_comment() {
36
- let input = "- a # inline\n # wrong\n";
37
- let hits = run(input);
38
- assert_eq!(hits, vec![Violation { line: 2, column: 2 }]);
39
- }
40
-
41
- #[test]
42
- fn blank_line_keeps_comment_alignment() {
43
- let input = "# top\n\n # wrong\nvalue: 1\n";
44
- let hits = run(input);
45
- assert_eq!(hits, vec![Violation { line: 3, column: 3 }]);
46
- }
47
-
48
- #[test]
49
- fn allows_comment_inside_block_scalar_body() {
50
- let input = "rule:\n - pattern: |\n body\n # example\n - other: value\n";
51
- let hits = run(input);
52
- assert!(
53
- hits.is_empty(),
54
- "block scalar comment should be ignored: {hits:?}"
55
- );
56
- }
57
-
58
- #[test]
59
- fn allows_comment_dedented_to_indicator_indent() {
60
- let input = "rule:\n - pattern: |\n body\n # metadata\n - other: value\n";
61
- let hits = run(input);
62
- assert!(
63
- hits.is_empty(),
64
- "comment aligned with indicator should pass: {hits:?}"
65
- );
66
- }
67
-
68
- #[test]
69
- fn indicator_with_trailing_comment_is_supported() {
70
- let input = "job:\n run: | # trailing comment\n step one\n next: value\n";
71
- let hits = run(input);
72
- assert!(
73
- hits.is_empty(),
74
- "inline comment on indicator should be ignored: {hits:?}"
75
- );
76
- }
77
-
78
- #[test]
79
- fn block_scalar_allows_blank_line() {
80
- let input = "rule:\n - pattern: |\n alpha\n\n omega\n - other: value\n";
81
- let hits = run(input);
82
- assert!(
83
- hits.is_empty(),
84
- "blank lines inside block scalars should pass: {hits:?}"
85
- );
86
- }
87
-
88
- #[test]
89
- fn inline_quotes_and_escapes_before_comment_are_handled() {
90
- let with_single = "value: 'quoted # fragment' # note\n # aligned\n";
91
- let hits = run(with_single);
92
- assert_eq!(hits, vec![Violation { line: 2, column: 3 }]);
93
-
94
- let with_escape = "path: \"dir\\#name\" # note\n # aligned\n";
95
- let hits = run(with_escape);
96
- assert_eq!(hits, vec![Violation { line: 2, column: 3 }]);
97
- }
98
-
99
- #[test]
100
- fn block_scalar_followed_by_mapping_is_handled() {
101
- let input = "value: |\n text\nnext: 1\n";
102
- let hits = run(input);
103
- assert!(
104
- hits.is_empty(),
105
- "block scalar should reset tracker before next mapping: {hits:?}"
106
- );
107
- }
108
-
109
- #[test]
110
- fn folded_block_scalar_with_chomping_is_detected() {
111
- let input = "rule:\n value: >-\n body\n # metadata\n next: value\n";
112
- let hits = run(input);
113
- assert!(
114
- hits.is_empty(),
115
- "folded block scalar with chomping should not flag comments: {hits:?}"
116
- );
117
- }
118
-
119
- #[test]
120
- fn empty_block_scalar_resets_state() {
121
- let input = "value: |\nnext: item\n";
122
- let hits = run(input);
123
- assert!(
124
- hits.is_empty(),
125
- "empty block scalars should not cause diagnostics: {hits:?}"
126
- );
127
- }
@@ -1,118 +0,0 @@
1
- use ryl::rules::document_end::{
2
- self, Config, FORBIDDEN_MESSAGE, MISSING_MESSAGE,
3
- classify_document_end_marker_bytes,
4
- };
5
-
6
- #[test]
7
- fn reports_missing_marker_at_stream_end() {
8
- let cfg = Config::new_for_tests(true);
9
- let input = "---\nwithout:\n document: end\n";
10
- let hits = document_end::check(input, &cfg);
11
- assert_eq!(hits.len(), 1, "expected a violation: {hits:?}");
12
- let hit = &hits[0];
13
- assert_eq!(hit.line, 3);
14
- assert_eq!(hit.column, 1);
15
- assert_eq!(hit.message, MISSING_MESSAGE);
16
- }
17
-
18
- #[test]
19
- fn reports_missing_marker_between_documents() {
20
- let cfg = Config::new_for_tests(true);
21
- let input = "---\nfirst: document\n---\nsecond: document\n";
22
- let hits = document_end::check(input, &cfg);
23
- assert_eq!(hits.len(), 2, "expected two violations: {hits:?}");
24
- assert_eq!(hits[0].line, 3);
25
- assert_eq!(hits[0].column, 1);
26
- assert_eq!(hits[0].message, MISSING_MESSAGE);
27
- assert_eq!(hits[1].line, 4);
28
- assert_eq!(hits[1].column, 1);
29
- assert_eq!(hits[1].message, MISSING_MESSAGE);
30
- }
31
-
32
- #[test]
33
- fn explicit_marker_satisfies_requirement() {
34
- let cfg = Config::new_for_tests(true);
35
- let input = "---\nwith:\n document: end\n...\n";
36
- let hits = document_end::check(input, &cfg);
37
- assert!(hits.is_empty(), "explicit marker should pass: {hits:?}");
38
- }
39
-
40
- #[test]
41
- fn forbidding_marker_flags_explicit_marker() {
42
- let cfg = Config::new_for_tests(false);
43
- let input = "---\nwith:\n document: end\n...\n";
44
- let hits = document_end::check(input, &cfg);
45
- assert_eq!(hits.len(), 1, "expected a violation: {hits:?}");
46
- let hit = &hits[0];
47
- assert_eq!(hit.line, 4);
48
- assert_eq!(hit.column, 1);
49
- assert_eq!(hit.message, FORBIDDEN_MESSAGE);
50
- }
51
-
52
- #[test]
53
- fn forbidding_marker_allows_absent_marker() {
54
- let cfg = Config::new_for_tests(false);
55
- let input = "---\nwith:\n document: end\n";
56
- let hits = document_end::check(input, &cfg);
57
- assert!(
58
- hits.is_empty(),
59
- "missing marker allowed when forbidden: {hits:?}"
60
- );
61
- }
62
-
63
- #[test]
64
- fn empty_stream_has_no_diagnostics() {
65
- let cfg = Config::new_for_tests(true);
66
- let hits = document_end::check("", &cfg);
67
- assert!(hits.is_empty(), "empty stream should not warn: {hits:?}");
68
- }
69
-
70
- #[test]
71
- fn explicit_marker_with_trailing_spaces_is_still_detected() {
72
- let cfg = Config::new_for_tests(false);
73
- let input = "---\nwith:\n document: end\n... \n";
74
- let hits = document_end::check(input, &cfg);
75
- assert_eq!(
76
- hits.len(),
77
- 1,
78
- "expected forbidden marker violation: {hits:?}"
79
- );
80
- let hit = &hits[0];
81
- assert_eq!(hit.line, 4);
82
- assert_eq!(hit.column, 1);
83
- assert_eq!(hit.message, FORBIDDEN_MESSAGE);
84
- }
85
-
86
- #[test]
87
- fn marker_with_leading_indent_is_allowed() {
88
- let cfg = Config::new_for_tests(true);
89
- let input = "---\nwith:\n document: end\n ...\n";
90
- let hits = document_end::check(input, &cfg);
91
- assert!(
92
- hits.is_empty(),
93
- "indented marker should satisfy requirement: {hits:?}"
94
- );
95
- }
96
-
97
- #[test]
98
- fn marker_with_inline_comment_is_allowed() {
99
- let cfg = Config::new_for_tests(true);
100
- let input = "---\nwith:\n document: end\n... # done\n";
101
- let hits = document_end::check(input, &cfg);
102
- assert!(
103
- hits.is_empty(),
104
- "marker followed by comment should satisfy requirement: {hits:?}"
105
- );
106
- }
107
-
108
- #[test]
109
- fn classify_marker_bytes_trims_whitespace() {
110
- assert_eq!(classify_document_end_marker_bytes(b" ... "), Some("..."));
111
- assert_eq!(classify_document_end_marker_bytes(b"\t---\r"), Some("---"));
112
- }
113
-
114
- #[test]
115
- fn classify_marker_bytes_rejects_comments_and_empty() {
116
- assert!(classify_document_end_marker_bytes(b"... # done").is_none());
117
- assert!(classify_document_end_marker_bytes(b"").is_none());
118
- }
@@ -1,60 +0,0 @@
1
- use ryl::rules::document_start::{self, Config, FORBIDDEN_MESSAGE, MISSING_MESSAGE};
2
-
3
- #[test]
4
- fn reports_missing_marker_at_start_of_file() {
5
- let cfg = Config::new_for_tests(true);
6
- let input = "foo: bar\n";
7
- let hits = document_start::check(input, &cfg);
8
- assert_eq!(hits.len(), 1, "expected a violation: {hits:?}");
9
- let hit = &hits[0];
10
- assert_eq!(hit.line, 1);
11
- assert_eq!(hit.column, 1);
12
- assert_eq!(hit.message, MISSING_MESSAGE);
13
- }
14
-
15
- #[test]
16
- fn reports_missing_marker_after_comment_block() {
17
- let cfg = Config::new_for_tests(true);
18
- let input = "# header\nfoo: bar\n";
19
- let hits = document_start::check(input, &cfg);
20
- assert_eq!(hits.len(), 1, "expected a violation: {hits:?}");
21
- let hit = &hits[0];
22
- assert_eq!(hit.line, 2);
23
- assert_eq!(hit.column, 1);
24
- assert_eq!(hit.message, MISSING_MESSAGE);
25
- }
26
-
27
- #[test]
28
- fn explicit_marker_satisfies_requirement() {
29
- let cfg = Config::new_for_tests(true);
30
- let input = "---\nfoo: bar\n";
31
- let hits = document_start::check(input, &cfg);
32
- assert!(hits.is_empty(), "explicit marker should pass: {hits:?}");
33
- }
34
-
35
- #[test]
36
- fn forbidding_marker_flags_explicit_documents() {
37
- let cfg = Config::new_for_tests(false);
38
- let input = "---\nfoo: bar\n";
39
- let hits = document_start::check(input, &cfg);
40
- assert_eq!(hits.len(), 1, "expected a violation: {hits:?}");
41
- let hit = &hits[0];
42
- assert_eq!(hit.line, 1);
43
- assert_eq!(hit.column, 1);
44
- assert_eq!(hit.message, FORBIDDEN_MESSAGE);
45
- }
46
-
47
- #[test]
48
- fn implicit_documents_respected_when_forbidden() {
49
- let cfg = Config::new_for_tests(false);
50
- let input = "foo: bar\n";
51
- let hits = document_start::check(input, &cfg);
52
- assert!(hits.is_empty(), "implicit document start allowed: {hits:?}");
53
- }
54
-
55
- #[test]
56
- fn empty_stream_has_no_diagnostics() {
57
- let cfg = Config::new_for_tests(true);
58
- let hits = document_start::check("", &cfg);
59
- assert!(hits.is_empty(), "empty stream should not warn: {hits:?}");
60
- }
@@ -1,96 +0,0 @@
1
- use ryl::config::YamlLintConfig;
2
- use ryl::rules::empty_lines::{self, Config};
3
-
4
- fn resolve(contents: &str) -> Config {
5
- let cfg = YamlLintConfig::from_yaml_str(contents).expect("config parses");
6
- Config::resolve(&cfg)
7
- }
8
-
9
- #[test]
10
- fn default_allows_two_blank_lines() {
11
- let cfg = resolve("rules:\n empty-lines: enable\n");
12
- let ok = "key: value\n\n\nnext: item\n";
13
- let violations = empty_lines::check(ok, &cfg);
14
- assert!(
15
- violations.is_empty(),
16
- "unexpected diagnostics: {violations:?}"
17
- );
18
-
19
- let bad = "key: value\n\n\n\nnext: item\n";
20
- let hits = empty_lines::check(bad, &cfg);
21
- assert_eq!(hits.len(), 1);
22
- let hit = &hits[0];
23
- assert_eq!(hit.line, 4);
24
- assert_eq!(hit.column, 1);
25
- assert_eq!(hit.message, "too many blank lines (3 > 2)");
26
- }
27
-
28
- #[test]
29
- fn exceeds_max_reports_violation() {
30
- let cfg = resolve(
31
- "rules:\n empty-lines:\n max: 0\n max-start: 0\n max-end: 0\n",
32
- );
33
- let input = "---\nvalue: 1\n\nother: 2\n";
34
- let hits = empty_lines::check(input, &cfg);
35
- assert_eq!(hits.len(), 1);
36
- let hit = &hits[0];
37
- assert_eq!(hit.line, 3);
38
- assert_eq!(hit.message, "too many blank lines (1 > 0)");
39
- }
40
-
41
- #[test]
42
- fn start_limit_applied_before_general_max() {
43
- let cfg = resolve(
44
- "rules:\n empty-lines:\n max: 5\n max-start: 1\n max-end: 0\n",
45
- );
46
- let input = "\n\nkey: value\n";
47
- let hits = empty_lines::check(input, &cfg);
48
- assert_eq!(hits.len(), 1);
49
- let hit = &hits[0];
50
- assert_eq!(hit.line, 2);
51
- assert_eq!(hit.message, "too many blank lines (2 > 1)");
52
- }
53
-
54
- #[test]
55
- fn end_limit_overrides_general_max() {
56
- let cfg = resolve(
57
- "rules:\n empty-lines:\n max: 5\n max-start: 0\n max-end: 1\n",
58
- );
59
- let input = "key: value\n\n\n";
60
- let hits = empty_lines::check(input, &cfg);
61
- assert_eq!(hits.len(), 1);
62
- let hit = &hits[0];
63
- assert_eq!(hit.line, 3);
64
- assert_eq!(hit.message, "too many blank lines (2 > 1)");
65
- }
66
-
67
- #[test]
68
- fn single_newline_file_is_ignored() {
69
- let cfg = resolve(
70
- "rules:\n empty-lines:\n max: 0\n max-start: 0\n max-end: 0\n",
71
- );
72
- let hits = empty_lines::check("\n", &cfg);
73
- assert!(
74
- hits.is_empty(),
75
- "single newline should not produce violations"
76
- );
77
-
78
- let crlf_hits = empty_lines::check("\r\n", &cfg);
79
- assert!(
80
- crlf_hits.is_empty(),
81
- "single CRLF newline should not produce violations"
82
- );
83
- }
84
-
85
- #[test]
86
- fn space_only_lines_are_not_blank() {
87
- let cfg = resolve(
88
- "rules:\n empty-lines:\n max: 0\n max-start: 0\n max-end: 0\n",
89
- );
90
- let input = "---\nintro\n \nend\n";
91
- let hits = empty_lines::check(input, &cfg);
92
- assert!(
93
- hits.is_empty(),
94
- "space-only lines should not be treated as blank"
95
- );
96
- }
@@ -1,102 +0,0 @@
1
- use ryl::config::YamlLintConfig;
2
- use ryl::rules::empty_values::{self, Config, Violation};
3
-
4
- fn resolve_config(data: &str) -> Config {
5
- let cfg = YamlLintConfig::from_yaml_str(data).unwrap();
6
- empty_values::Config::resolve(&cfg)
7
- }
8
-
9
- #[test]
10
- fn reports_block_mapping_empty_value() {
11
- let yaml = "block:\n missing:\n";
12
- let cfg = resolve_config("rules:\n empty-values: enable\n");
13
- let hits = empty_values::check(yaml, &cfg);
14
- assert_eq!(
15
- hits,
16
- vec![Violation {
17
- line: 2,
18
- column: 11,
19
- message: "empty value in block mapping".to_string(),
20
- }]
21
- );
22
- }
23
-
24
- #[test]
25
- fn reports_flow_mapping_empty_value() {
26
- let yaml = "root: { key: }\n";
27
- let cfg = resolve_config("rules:\n empty-values: enable\n");
28
- let hits = empty_values::check(yaml, &cfg);
29
- assert_eq!(
30
- hits,
31
- vec![Violation {
32
- line: 1,
33
- column: 13,
34
- message: "empty value in flow mapping".to_string(),
35
- }]
36
- );
37
- }
38
-
39
- #[test]
40
- fn reports_block_sequence_empty_value() {
41
- let yaml = "-\n";
42
- let cfg = resolve_config("rules:\n empty-values: enable\n");
43
- let hits = empty_values::check(yaml, &cfg);
44
- assert_eq!(
45
- hits,
46
- vec![Violation {
47
- line: 1,
48
- column: 2,
49
- message: "empty value in block sequence".to_string(),
50
- }]
51
- );
52
- }
53
-
54
- #[test]
55
- fn respects_block_sequence_flag() {
56
- let yaml = "-\n";
57
- let cfg = resolve_config(
58
- "rules:\n empty-values:\n forbid-in-block-sequences: false\n",
59
- );
60
- let hits = empty_values::check(yaml, &cfg);
61
- assert!(hits.is_empty());
62
- }
63
-
64
- #[test]
65
- fn respects_flow_mapping_flag() {
66
- let yaml = "root: { key: }\n";
67
- let cfg =
68
- resolve_config("rules:\n empty-values:\n forbid-in-flow-mappings: false\n");
69
- let hits = empty_values::check(yaml, &cfg);
70
- assert!(hits.is_empty());
71
- }
72
-
73
- #[test]
74
- fn respects_block_mapping_flag() {
75
- let yaml = "key:\n";
76
- let cfg = resolve_config(
77
- "rules:\n empty-values:\n forbid-in-block-mappings: false\n",
78
- );
79
- let hits = empty_values::check(yaml, &cfg);
80
- assert!(hits.is_empty());
81
- }
82
-
83
- #[test]
84
- fn ignores_flow_sequences() {
85
- let yaml = "seq: [ value ]\n";
86
- let cfg = resolve_config("rules:\n empty-values: enable\n");
87
- let hits = empty_values::check(yaml, &cfg);
88
- assert!(hits.is_empty());
89
- }
90
-
91
- #[test]
92
- fn handles_alias_nodes() {
93
- let yaml = "anchors:\n value: &id 1\nusage:\n alias: *id\n";
94
- let cfg = resolve_config("rules:\n empty-values: enable\n");
95
- let hits = empty_values::check(yaml, &cfg);
96
- assert!(hits.is_empty());
97
- }
98
-
99
- #[test]
100
- fn covers_nothing_event_branch() {
101
- empty_values::coverage_touch_nothing_branch();
102
- }
@@ -1,109 +0,0 @@
1
- use ryl::config::YamlLintConfig;
2
- use ryl::rules::float_values::{self, Config};
3
-
4
- fn build_config(yaml: &str) -> Config {
5
- let cfg = YamlLintConfig::from_yaml_str(yaml).expect("config parses");
6
- Config::resolve(&cfg)
7
- }
8
-
9
- #[test]
10
- fn flags_forbidden_float_variants() {
11
- let resolved = build_config(
12
- "rules:\n float-values:\n require-numeral-before-decimal: true\n forbid-scientific-notation: true\n forbid-nan: true\n forbid-inf: true\n",
13
- );
14
-
15
- let hits = float_values::check("a: .5\nb: 1e2\nc: .nan\nd: .inf\n", &resolved);
16
-
17
- assert_eq!(hits.len(), 4, "all variants should be flagged");
18
- assert_eq!(hits[0].line, 1);
19
- assert_eq!(hits[0].column, 4);
20
- assert_eq!(hits[0].message, "forbidden decimal missing 0 prefix \".5\"");
21
-
22
- assert_eq!(hits[1].line, 2);
23
- assert_eq!(hits[1].column, 4);
24
- assert_eq!(hits[1].message, "forbidden scientific notation \"1e2\"");
25
-
26
- assert_eq!(hits[2].line, 3);
27
- assert_eq!(hits[2].column, 4);
28
- assert_eq!(hits[2].message, "forbidden not a number value \".nan\"");
29
-
30
- assert_eq!(hits[3].line, 4);
31
- assert_eq!(hits[3].column, 4);
32
- assert_eq!(hits[3].message, "forbidden infinite value \".inf\"");
33
- }
34
-
35
- #[test]
36
- fn skips_quoted_and_tagged_values() {
37
- let resolved = build_config(
38
- "rules:\n float-values:\n require-numeral-before-decimal: true\n",
39
- );
40
- let hits =
41
- float_values::check("quoted: '.5'\ntagged: !!float .5\nplain: .5\n", &resolved);
42
-
43
- assert_eq!(
44
- hits.len(),
45
- 1,
46
- "only plain scalar without tag should be flagged"
47
- );
48
- assert_eq!(hits[0].line, 3);
49
- assert_eq!(hits[0].column, 8);
50
- assert_eq!(hits[0].message, "forbidden decimal missing 0 prefix \".5\"");
51
- }
52
-
53
- #[test]
54
- fn scientific_notation_edge_cases() {
55
- let resolved = build_config(
56
- "rules:\n float-values:\n forbid-scientific-notation: true\n require-numeral-before-decimal: true\n",
57
- );
58
-
59
- let buffer = "\
60
- scientific_lower: .5e+2
61
- scientific_upper: -.5E-2
62
- missing_mantissa: e3
63
- invalid_mantissa: a.e2
64
- invalid_fraction: 1.ae2
65
- missing_digits_after_dot: .e2
66
- bare_decimal: .
67
- missing_exponent: .5e
68
- signed_without_digits: .5e+
69
- invalid_exponent_chars: 1e+Q
70
- ";
71
- let hits = float_values::check(buffer, &resolved);
72
- let messages: Vec<_> = hits.iter().map(|d| d.message.as_str()).collect();
73
-
74
- assert_eq!(
75
- hits.len(),
76
- 4,
77
- "expected two diagnostics per scientific value"
78
- );
79
- assert!(
80
- messages.contains(&"forbidden scientific notation \".5e+2\""),
81
- "messages: {messages:?}"
82
- );
83
- assert!(
84
- messages.contains(&"forbidden decimal missing 0 prefix \".5e+2\""),
85
- "messages: {messages:?}"
86
- );
87
- assert!(
88
- messages.contains(&"forbidden scientific notation \"-.5E-2\""),
89
- "messages: {messages:?}"
90
- );
91
- assert!(
92
- messages.contains(&"forbidden decimal missing 0 prefix \"-.5E-2\""),
93
- "messages: {messages:?}"
94
- );
95
- let forbidden = [
96
- "\"a.e2\"",
97
- "\"1.ae2\"",
98
- "\".e2\"",
99
- "\".5e\"",
100
- "\".5e+\"",
101
- "\"1e+Q\"",
102
- ];
103
- assert!(
104
- messages
105
- .iter()
106
- .all(|m| forbidden.iter().all(|value| !m.contains(value))),
107
- "unexpected diagnostics: {messages:?}"
108
- );
109
- }
@@ -1,65 +0,0 @@
1
- use ryl::rules::hyphens::{self, Config, Violation};
2
-
3
- #[test]
4
- fn allows_single_space_after_hyphen() {
5
- let cfg = Config::new_for_tests(1);
6
- let diagnostics = hyphens::check("- item\n", &cfg);
7
- assert!(
8
- diagnostics.is_empty(),
9
- "unexpected diagnostics: {diagnostics:?}"
10
- );
11
- }
12
-
13
- #[test]
14
- fn reports_too_many_spaces_in_root_sequence() {
15
- let cfg = Config::new_for_tests(1);
16
- let diagnostics = hyphens::check("- item\n", &cfg);
17
- assert_eq!(diagnostics, vec![Violation { line: 1, column: 3 }]);
18
- }
19
-
20
- #[test]
21
- fn reports_too_many_spaces_with_indentation() {
22
- let cfg = Config::new_for_tests(1);
23
- let diagnostics = hyphens::check(" - item\n", &cfg);
24
- assert_eq!(diagnostics, vec![Violation { line: 1, column: 5 }]);
25
- }
26
-
27
- #[test]
28
- fn respects_configured_max_spaces() {
29
- let cfg = Config::new_for_tests(3);
30
- let diagnostics = hyphens::check("- item\n", &cfg);
31
- assert_eq!(diagnostics, vec![Violation { line: 1, column: 5 }]);
32
-
33
- let ok = hyphens::check("- item\n", &cfg);
34
- assert!(ok.is_empty(), "unexpected diagnostics: {ok:?}");
35
- }
36
-
37
- #[test]
38
- fn ignores_entries_with_comments_only() {
39
- let cfg = Config::new_for_tests(1);
40
- let diagnostics = hyphens::check("- # comment\n", &cfg);
41
- assert!(
42
- diagnostics.is_empty(),
43
- "unexpected diagnostics: {diagnostics:?}"
44
- );
45
- }
46
-
47
- #[test]
48
- fn ignores_blank_lines() {
49
- let cfg = Config::new_for_tests(1);
50
- let diagnostics = hyphens::check("\n- item\n", &cfg);
51
- assert!(
52
- diagnostics.is_empty(),
53
- "unexpected diagnostics: {diagnostics:?}"
54
- );
55
- }
56
-
57
- #[test]
58
- fn ignores_entries_without_inline_values() {
59
- let cfg = Config::new_for_tests(1);
60
- let diagnostics = hyphens::check("-\n key: value\n", &cfg);
61
- assert!(
62
- diagnostics.is_empty(),
63
- "unexpected diagnostics: {diagnostics:?}"
64
- );
65
- }