@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,119 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("process");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- fn command_output<'a>(stdout: &'a str, stderr: &'a str) -> &'a str {
15
- if stderr.is_empty() { stdout } else { stderr }
16
- }
17
-
18
- #[test]
19
- fn unix_type_reports_crlf() {
20
- let dir = tempdir().unwrap();
21
- let file = dir.path().join("crlf.yaml");
22
- fs::write(&file, "key: value\r\n").unwrap();
23
- let config = dir.path().join("config.yml");
24
- fs::write(
25
- &config,
26
- "rules:\n document-start: disable\n new-lines:\n type: unix\n",
27
- )
28
- .unwrap();
29
-
30
- let exe = env!("CARGO_BIN_EXE_ryl");
31
- let (code, stdout, stderr) =
32
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
33
- assert_eq!(code, 1, "expected failure: stdout={stdout} stderr={stderr}");
34
- let output = command_output(&stdout, &stderr);
35
- assert!(
36
- output.contains("wrong new line character: expected \\n"),
37
- "missing expected message: {output}"
38
- );
39
- assert!(output.contains("new-lines"), "rule id missing: {output}");
40
- assert!(output.contains("1:11"), "incorrect column: {output}");
41
- }
42
-
43
- #[test]
44
- fn dos_type_reports_lf() {
45
- let dir = tempdir().unwrap();
46
- let file = dir.path().join("lf.yaml");
47
- fs::write(&file, "key: value\n").unwrap();
48
- let config = dir.path().join("config.yml");
49
- fs::write(
50
- &config,
51
- "rules:\n document-start: disable\n new-lines:\n type: dos\n",
52
- )
53
- .unwrap();
54
-
55
- let exe = env!("CARGO_BIN_EXE_ryl");
56
- let (code, stdout, stderr) =
57
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
58
- assert_eq!(code, 1, "expected failure: stdout={stdout} stderr={stderr}");
59
- let output = command_output(&stdout, &stderr);
60
- assert!(
61
- output.contains("wrong new line character: expected \\r\\n"),
62
- "missing expected message: {output}"
63
- );
64
- assert!(output.contains("new-lines"), "rule id missing: {output}");
65
- }
66
-
67
- #[test]
68
- fn dos_type_accepts_crlf() {
69
- let dir = tempdir().unwrap();
70
- let file = dir.path().join("ok.yaml");
71
- fs::write(&file, "key: value\r\n").unwrap();
72
- let config = dir.path().join("config.yml");
73
- fs::write(
74
- &config,
75
- "rules:\n document-start: disable\n new-lines:\n type: dos\n",
76
- )
77
- .unwrap();
78
-
79
- let exe = env!("CARGO_BIN_EXE_ryl");
80
- let (code, stdout, stderr) =
81
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
82
- assert_eq!(code, 0, "expected success: stdout={stdout} stderr={stderr}");
83
- }
84
-
85
- #[test]
86
- fn platform_type_uses_detected_newline() {
87
- let dir = tempdir().unwrap();
88
- let file = dir.path().join("platform.yaml");
89
- let mismatch = if cfg!(windows) {
90
- "key: value\n"
91
- } else {
92
- "key: value\r\n"
93
- };
94
- fs::write(&file, mismatch).unwrap();
95
- let config = dir.path().join("config.yml");
96
- fs::write(
97
- &config,
98
- "rules:\n document-start: disable\n new-lines:\n type: platform\n",
99
- )
100
- .unwrap();
101
-
102
- let exe = env!("CARGO_BIN_EXE_ryl");
103
- let (code, stdout, stderr) =
104
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
105
- assert_eq!(code, 1, "expected failure: stdout={stdout} stderr={stderr}");
106
- let output = command_output(&stdout, &stderr);
107
- if cfg!(windows) {
108
- assert!(
109
- output.contains("wrong new line character: expected \\r\\n"),
110
- "windows platform expectation mismatch: {output}"
111
- );
112
- } else {
113
- assert!(
114
- output.contains("wrong new line character: expected \\n"),
115
- "unix platform expectation mismatch: {output}"
116
- );
117
- }
118
- assert!(output.contains("new-lines"), "rule id missing: {output}");
119
- }
@@ -1,60 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("process");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- fn command_output<'a>(stdout: &'a str, stderr: &'a str) -> &'a str {
15
- if stderr.is_empty() { stdout } else { stderr }
16
- }
17
-
18
- #[test]
19
- fn octal_rule_reports_plain_values() {
20
- let dir = tempdir().unwrap();
21
- let file = dir.path().join("values.yaml");
22
- fs::write(&file, "foo: 010\nbar: 0o10\n").unwrap();
23
-
24
- let config = dir.path().join("config.yaml");
25
- fs::write(
26
- &config,
27
- "rules:\n document-start: disable\n octal-values: enable\n",
28
- )
29
- .unwrap();
30
-
31
- let exe = env!("CARGO_BIN_EXE_ryl");
32
- let (code, stdout, stderr) =
33
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
34
- assert_eq!(
35
- code, 1,
36
- "expected lint failure: stdout={stdout} stderr={stderr}"
37
- );
38
-
39
- let output = command_output(&stdout, &stderr);
40
- assert!(
41
- output.contains("forbidden implicit octal value \"010\""),
42
- "missing implicit message: {output}"
43
- );
44
- assert!(
45
- output.contains("forbidden explicit octal value \"0o10\""),
46
- "missing explicit message: {output}"
47
- );
48
- assert!(
49
- output.contains("octal-values"),
50
- "rule label missing: {output}"
51
- );
52
- assert!(
53
- output.contains("1:9"),
54
- "expected implicit octal position: {output}"
55
- );
56
- assert!(
57
- output.contains("2:10"),
58
- "expected explicit octal position: {output}"
59
- );
60
- }
@@ -1,47 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("process");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- fn command_output<'a>(stdout: &'a str, stderr: &'a str) -> &'a str {
15
- if stderr.is_empty() { stdout } else { stderr }
16
- }
17
-
18
- #[test]
19
- fn quoted_strings_reports_redundant_quotes() {
20
- let dir = tempdir().unwrap();
21
- let file = dir.path().join("data.yaml");
22
- fs::write(&file, "foo: \"bar\"\n").unwrap();
23
-
24
- let config = dir.path().join("config.yaml");
25
- fs::write(
26
- &config,
27
- "rules:\n document-start: disable\n quoted-strings:\n required: only-when-needed\n",
28
- )
29
- .unwrap();
30
-
31
- let exe = env!("CARGO_BIN_EXE_ryl");
32
- let (code, stdout, stderr) =
33
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
34
- assert_eq!(
35
- code, 1,
36
- "expected lint failure: stdout={stdout} stderr={stderr}"
37
- );
38
- let output = command_output(&stdout, &stderr);
39
- assert!(
40
- output.contains("string value is redundantly quoted with any quotes"),
41
- "missing redundant quote message: {output}"
42
- );
43
- assert!(
44
- output.contains("quoted-strings"),
45
- "rule label missing: {output}"
46
- );
47
- }
@@ -1,119 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("failed to run ryl");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- #[test]
15
- fn project_toml_overrides_yaml_and_emits_single_warning() {
16
- let td = tempdir().unwrap();
17
- let root = td.path();
18
- fs::create_dir_all(root.join("dir")).unwrap();
19
- fs::write(root.join("dir/a.yaml"), "a: 1\n").unwrap();
20
- fs::write(root.join("dir/b.yaml"), "b: 2\n").unwrap();
21
- fs::write(
22
- root.join(".ryl.toml"),
23
- "yaml-files = ['**/a.yaml', '**/b.yaml']\n[rules]\nanchors = 'disable'\n",
24
- )
25
- .unwrap();
26
- fs::write(root.join(".yamllint"), "yaml-files: ['**/a.yaml']\n").unwrap();
27
-
28
- let exe = env!("CARGO_BIN_EXE_ryl");
29
- let (code, stdout, stderr) = run(Command::new(exe).arg("--list-files").arg(root));
30
- assert_eq!(code, 0, "expected success: stdout={stdout} stderr={stderr}");
31
- assert!(stdout.contains("a.yaml"));
32
- assert!(stdout.contains("b.yaml"));
33
- let warning_count = stderr
34
- .matches("warning: ignoring legacy YAML config discovery because TOML config")
35
- .count();
36
- assert_eq!(warning_count, 1, "stderr={stderr}");
37
- }
38
-
39
- #[test]
40
- fn explicit_pyproject_without_tool_ryl_errors() {
41
- let td = tempdir().unwrap();
42
- let root = td.path();
43
- let pyproject = root.join("pyproject.toml");
44
- fs::write(
45
- &pyproject,
46
- "[project]\nname = 'demo'\nversion = '0.1.0'\nrequires-python = '>=3.10'\n",
47
- )
48
- .unwrap();
49
- fs::write(root.join("a.yaml"), "a: 1\n").unwrap();
50
-
51
- let exe = env!("CARGO_BIN_EXE_ryl");
52
- let (code, _stdout, stderr) = run(Command::new(exe)
53
- .arg("--list-files")
54
- .arg("-c")
55
- .arg(&pyproject)
56
- .arg(root.join("a.yaml")));
57
- assert_eq!(code, 2);
58
- assert!(stderr.contains("missing [tool.ryl] section"));
59
- }
60
-
61
- #[test]
62
- fn global_config_notice_is_emitted_when_env_var_triggers_global_discovery() {
63
- let td = tempdir().unwrap();
64
- let root = td.path();
65
- fs::write(root.join("a.yaml"), "a: 1\n").unwrap();
66
- fs::write(root.join(".ryl.toml"), "[rules]\nanchors = 'disable'\n").unwrap();
67
- fs::write(root.join(".yamllint"), "rules: {}\n").unwrap();
68
-
69
- let exe = env!("CARGO_BIN_EXE_ryl");
70
- let (code, _stdout, stderr) = run(Command::new(exe)
71
- .env("YAMLLINT_CONFIG_FILE", "/does/not/exist.yml")
72
- .arg("--list-files")
73
- .arg(root.join("a.yaml")));
74
- assert_eq!(code, 0, "stderr={stderr}");
75
- assert!(stderr.contains(
76
- "warning: ignoring legacy YAML config discovery because TOML config"
77
- ));
78
- }
79
-
80
- #[test]
81
- fn explicit_file_discovery_emits_notice() {
82
- let td = tempdir().unwrap();
83
- let root = td.path();
84
- fs::write(root.join("a.yaml"), "a: 1\n").unwrap();
85
- fs::write(root.join(".ryl.toml"), "[rules]\nanchors = 'disable'\n").unwrap();
86
- fs::write(root.join(".yamllint"), "rules: {}\n").unwrap();
87
-
88
- let exe = env!("CARGO_BIN_EXE_ryl");
89
- let (code, _stdout, stderr) = run(Command::new(exe)
90
- .arg("--list-files")
91
- .arg(root.join("a.yaml")));
92
- assert_eq!(code, 0, "stderr={stderr}");
93
- assert!(stderr.contains(
94
- "warning: ignoring legacy YAML config discovery because TOML config"
95
- ));
96
- }
97
-
98
- #[test]
99
- fn explicit_notice_is_deduplicated_after_directory_notice() {
100
- let td = tempdir().unwrap();
101
- let root = td.path();
102
- fs::create_dir_all(root.join("one")).unwrap();
103
- fs::create_dir_all(root.join("two")).unwrap();
104
- fs::write(root.join("one/from_dir.yaml"), "a: 1\n").unwrap();
105
- fs::write(root.join("two/from_file.yaml"), "b: 2\n").unwrap();
106
- fs::write(root.join(".ryl.toml"), "[rules]\nanchors = 'disable'\n").unwrap();
107
- fs::write(root.join(".yamllint"), "rules: {}\n").unwrap();
108
-
109
- let exe = env!("CARGO_BIN_EXE_ryl");
110
- let (code, _stdout, stderr) = run(Command::new(exe)
111
- .arg("--list-files")
112
- .arg(root.join("one"))
113
- .arg(root.join("two/from_file.yaml")));
114
- assert_eq!(code, 0, "stderr={stderr}");
115
- let warning_count = stderr
116
- .matches("warning: ignoring legacy YAML config discovery because TOML config")
117
- .count();
118
- assert_eq!(warning_count, 1, "stderr={stderr}");
119
- }
@@ -1,77 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("process");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- #[test]
15
- fn trailing_spaces_reports_error() {
16
- let dir = tempdir().unwrap();
17
- let file = dir.path().join("bad.yaml");
18
- fs::write(&file, "key: value \n").unwrap();
19
-
20
- let exe = env!("CARGO_BIN_EXE_ryl");
21
- let (code, stdout, stderr) = run(Command::new(exe).arg(&file));
22
- assert_eq!(code, 1, "expected failure: stdout={stdout} stderr={stderr}");
23
- let output = if stderr.is_empty() { &stdout } else { &stderr };
24
- assert!(
25
- output.contains("trailing spaces"),
26
- "missing message: {output}"
27
- );
28
- assert!(
29
- output.contains("trailing-spaces"),
30
- "rule id missing from output: {output}"
31
- );
32
- }
33
-
34
- #[test]
35
- fn warning_level_does_not_fail() {
36
- let dir = tempdir().unwrap();
37
- let file = dir.path().join("warn.yaml");
38
- fs::write(&file, "key: value \n").unwrap();
39
- let config = dir.path().join("config.yml");
40
- fs::write(&config, "rules:\n trailing-spaces:\n level: warning\n").unwrap();
41
-
42
- let exe = env!("CARGO_BIN_EXE_ryl");
43
- let (code, stdout, stderr) =
44
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
45
- assert_eq!(
46
- code, 0,
47
- "warnings should not fail: stdout={stdout} stderr={stderr}"
48
- );
49
- let output = if stderr.is_empty() { &stdout } else { &stderr };
50
- assert!(
51
- output.contains("warning"),
52
- "expected warning output: {output}"
53
- );
54
- }
55
-
56
- #[test]
57
- fn rule_ignore_skips_file() {
58
- let dir = tempdir().unwrap();
59
- let file = dir.path().join("ignored.yaml");
60
- fs::write(&file, "key: value \n").unwrap();
61
- let config = dir.path().join("config.yml");
62
- fs::write(
63
- &config,
64
- "rules:\n trailing-spaces:\n ignore:\n - ignored.yaml\n",
65
- )
66
- .unwrap();
67
-
68
- let exe = env!("CARGO_BIN_EXE_ryl");
69
- let (code, stdout, stderr) =
70
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
71
- assert_eq!(
72
- code, 0,
73
- "ignored file should pass: stdout={stdout} stderr={stderr}"
74
- );
75
- assert!(stdout.trim().is_empty(), "expected no stdout: {stdout}");
76
- assert!(stderr.trim().is_empty(), "expected no stderr: {stderr}");
77
- }
@@ -1,83 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("process");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- fn command_output<'a>(stdout: &'a str, stderr: &'a str) -> &'a str {
15
- if stderr.is_empty() { stdout } else { stderr }
16
- }
17
-
18
- #[test]
19
- fn truthy_rule_reports_plain_truthy_values() {
20
- let dir = tempdir().unwrap();
21
- let file = dir.path().join("values.yaml");
22
- fs::write(&file, "foo: True\nbar: yes\n").unwrap();
23
-
24
- let config = dir.path().join("config.yaml");
25
- fs::write(
26
- &config,
27
- "rules:\n document-start: disable\n truthy: enable\n",
28
- )
29
- .unwrap();
30
-
31
- let exe = env!("CARGO_BIN_EXE_ryl");
32
- let (code, stdout, stderr) =
33
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
34
- assert_eq!(
35
- code, 1,
36
- "expected lint failure: stdout={stdout} stderr={stderr}"
37
- );
38
- let output = command_output(&stdout, &stderr);
39
- assert!(
40
- output.contains("truthy value should be one of [false, true]"),
41
- "missing truthy message: {output}"
42
- );
43
- assert!(output.contains("truthy"), "rule label missing: {output}");
44
- assert!(
45
- output.contains("1:6"),
46
- "expected position for value 'True': {output}"
47
- );
48
- assert!(
49
- output.contains("2:6"),
50
- "expected position for value 'yes': {output}"
51
- );
52
- }
53
-
54
- #[test]
55
- fn truthy_rule_respects_check_keys_false() {
56
- let dir = tempdir().unwrap();
57
- let file = dir.path().join("keys.yaml");
58
- fs::write(&file, "True: yes\nvalue: True\n").unwrap();
59
-
60
- let config = dir.path().join("config.yaml");
61
- fs::write(
62
- &config,
63
- "rules:\n document-start: disable\n truthy:\n allowed-values: []\n check-keys: false\n",
64
- )
65
- .unwrap();
66
-
67
- let exe = env!("CARGO_BIN_EXE_ryl");
68
- let (code, stdout, stderr) =
69
- run(Command::new(exe).arg("-c").arg(&config).arg(&file));
70
- assert_eq!(
71
- code, 1,
72
- "expected lint failure: stdout={stdout} stderr={stderr}"
73
- );
74
- let output = command_output(&stdout, &stderr);
75
- assert!(
76
- output.contains("2:8"),
77
- "value position should be reported when keys are skipped: {output}"
78
- );
79
- assert!(
80
- !output.contains("1:1"),
81
- "keys should be ignored when disabled: {output}"
82
- );
83
- }
@@ -1,45 +0,0 @@
1
- use std::fs;
2
- use std::process::Command;
3
-
4
- use tempfile::tempdir;
5
-
6
- fn run(cmd: &mut Command) -> (i32, String, String) {
7
- let out = cmd.output().expect("failed to run command");
8
- let code = out.status.code().unwrap_or(-1);
9
- let stdout = String::from_utf8_lossy(&out.stdout).into_owned();
10
- let stderr = String::from_utf8_lossy(&out.stderr).into_owned();
11
- (code, stdout, stderr)
12
- }
13
-
14
- #[test]
15
- fn yaml_files_negation_excludes_files_via_cli() {
16
- let dir = tempdir().unwrap();
17
- let root = dir.path();
18
- let cfg_path = root.join("config.yml");
19
-
20
- fs::write(
21
- &cfg_path,
22
- "rules:\n truthy: enable\nyaml-files: ['*.yaml', '!skip.yaml']\n",
23
- )
24
- .unwrap();
25
- fs::write(root.join("keep.yaml"), "value: Yes\n").unwrap();
26
- fs::write(root.join("skip.yaml"), "value: Yes\n").unwrap();
27
-
28
- let exe = env!("CARGO_BIN_EXE_ryl");
29
- let (code, stdout, stderr) =
30
- run(Command::new(exe).arg("-c").arg(&cfg_path).arg(root));
31
-
32
- assert_eq!(
33
- code, 1,
34
- "expected lint failure: stdout={stdout} stderr={stderr}"
35
- );
36
- let output = if stderr.is_empty() { stdout } else { stderr };
37
- assert!(
38
- output.contains("keep.yaml"),
39
- "expected keep.yaml diagnostics, got:\n{output}"
40
- );
41
- assert!(
42
- !output.contains("skip.yaml"),
43
- "unexpected diagnostics for skip.yaml:\n{output}"
44
- );
45
- }