tldr-core 0.1.6

Core analysis engine for TLDR code analysis tool
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
//! Tool execution and detection module.
//!
//! This module handles:
//! - Detecting which diagnostic tools are available on PATH
//! - Running tools with timeout handling
//! - Parallel execution of multiple tools
//! - Capturing stdout/stderr and exit codes

use std::io::Read;
use std::path::Path;
use std::process::{Command, Stdio};
use std::time::{Duration, Instant};

use crate::diagnostics::parsers::*;
use crate::diagnostics::{
    Diagnostic, DiagnosticsReport, ToolConfig, ToolResult,
};
use crate::error::TldrError;
use crate::types::Language;

// =============================================================================
// Tool Detection
// =============================================================================

/// Check if a tool binary is available on PATH.
///
/// Uses `which` on Unix and `where` on Windows to check availability.
pub fn is_tool_available(binary: &str) -> bool {
    #[cfg(unix)]
    {
        Command::new("which")
            .arg(binary)
            .stdout(Stdio::null())
            .stderr(Stdio::null())
            .status()
            .map(|s| s.success())
            .unwrap_or(false)
    }

    #[cfg(windows)]
    {
        Command::new("where")
            .arg(binary)
            .stdout(Stdio::null())
            .stderr(Stdio::null())
            .status()
            .map(|s| s.success())
            .unwrap_or(false)
    }
}

/// Get the version string of a tool, if available.
pub fn get_tool_version(binary: &str) -> Option<String> {
    let output = Command::new(binary).arg("--version").output().ok()?;

    if output.status.success() {
        let version = String::from_utf8_lossy(&output.stdout);
        // Extract first line and trim
        version.lines().next().map(|s| s.trim().to_string())
    } else {
        None
    }
}

/// Get all diagnostic tools configured for a language.
pub fn tools_for_language(lang: Language) -> Vec<ToolConfig> {
    match lang {
        Language::Python => vec![
            ToolConfig {
                name: "pyright",
                binary: "pyright",
                args: vec!["--outputjson".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "ruff",
                binary: "ruff",
                args: vec![
                    "check".to_string(),
                    "--output-format".to_string(),
                    "json".to_string(),
                ],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::TypeScript | Language::JavaScript => vec![
            ToolConfig {
                name: "tsc",
                binary: "tsc",
                args: vec![
                    "--noEmit".to_string(),
                    "--pretty".to_string(),
                    "false".to_string(),
                ],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "eslint",
                binary: "eslint",
                args: vec!["-f".to_string(), "json".to_string()],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Go => vec![
            ToolConfig {
                name: "go vet",
                binary: "go",
                args: vec!["vet".to_string(), "-json".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "golangci-lint",
                binary: "golangci-lint",
                args: vec![
                    "run".to_string(),
                    "--out-format".to_string(),
                    "json".to_string(),
                ],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Rust => vec![
            ToolConfig {
                name: "cargo check",
                binary: "cargo",
                args: vec!["check".to_string(), "--message-format=json".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "clippy",
                binary: "cargo",
                args: vec!["clippy".to_string(), "--message-format=json".to_string()],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Kotlin => vec![
            ToolConfig {
                name: "kotlinc",
                binary: "kotlinc",
                args: vec!["-language-version".to_string(), "1.9".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "detekt",
                binary: "detekt-cli",
                args: vec!["--report".to_string(), "txt:stdout".to_string()],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Swift => vec![
            ToolConfig {
                name: "swiftc",
                binary: "swiftc",
                args: vec!["-typecheck".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "swiftlint",
                binary: "swiftlint",
                args: vec![
                    "lint".to_string(),
                    "--reporter".to_string(),
                    "json".to_string(),
                    "--quiet".to_string(),
                ],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::CSharp => vec![ToolConfig {
            name: "dotnet build",
            binary: "dotnet",
            args: vec![
                "build".to_string(),
                "--no-restore".to_string(),
                "--verbosity".to_string(),
                "quiet".to_string(),
            ],
            is_type_checker: true,
            is_linter: true, // Roslyn analyzers are built in
        }],
        Language::Scala => vec![ToolConfig {
            name: "scalac",
            binary: "scalac",
            args: vec![],
            is_type_checker: true,
            is_linter: false,
        }],
        Language::Elixir => vec![
            ToolConfig {
                name: "mix compile",
                binary: "mix",
                args: vec!["compile".to_string(), "--warnings-as-errors".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "credo",
                binary: "mix",
                args: vec![
                    "credo".to_string(),
                    "--format".to_string(),
                    "json".to_string(),
                ],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Lua => vec![ToolConfig {
            name: "luacheck",
            binary: "luacheck",
            args: vec![
                "--formatter".to_string(),
                "plain".to_string(),
                "--no-color".to_string(),
            ],
            is_type_checker: false,
            is_linter: true,
        }],
        Language::Java => vec![
            ToolConfig {
                name: "javac",
                binary: "javac",
                args: vec!["-Xlint:all".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "checkstyle",
                binary: "checkstyle",
                args: vec!["-f".to_string(), "plain".to_string()],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::C | Language::Cpp => vec![
            ToolConfig {
                name: "clang",
                binary: "clang",
                args: vec!["-fsyntax-only".to_string(), "-Wall".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "clang-tidy",
                binary: "clang-tidy",
                args: vec![],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        Language::Ruby => vec![ToolConfig {
            name: "rubocop",
            binary: "rubocop",
            args: vec!["--format".to_string(), "json".to_string()],
            is_type_checker: false,
            is_linter: true,
        }],
        Language::Php => vec![
            ToolConfig {
                name: "php",
                binary: "php",
                args: vec!["-l".to_string()],
                is_type_checker: true,
                is_linter: false,
            },
            ToolConfig {
                name: "phpstan",
                binary: "phpstan",
                args: vec![
                    "analyse".to_string(),
                    "--error-format=json".to_string(),
                    "--no-progress".to_string(),
                ],
                is_type_checker: false,
                is_linter: true,
            },
        ],
        _ => vec![],
    }
}

/// Detect which tools are available for a given language.
/// Only returns tools that are actually installed.
pub fn detect_available_tools(lang: Language) -> Vec<ToolConfig> {
    tools_for_language(lang)
        .into_iter()
        .filter(|t| is_tool_available(t.binary))
        .collect()
}

// =============================================================================
// Tool Execution
// =============================================================================

/// Run a single diagnostic tool and parse its output.
///
/// # Arguments
/// * `tool` - The tool configuration
/// * `path` - The path to analyze
/// * `timeout_secs` - Timeout in seconds
///
/// # Returns
/// A tuple of (ToolResult, Vec<Diagnostic>)
pub fn run_tool(
    tool: &ToolConfig,
    path: &Path,
    timeout_secs: u64,
) -> (ToolResult, Vec<Diagnostic>) {
    let start = Instant::now();

    // Build the command
    let mut cmd = Command::new(tool.binary);
    cmd.args(&tool.args);
    cmd.arg(path);
    cmd.stdout(Stdio::piped());
    cmd.stderr(Stdio::piped());

    // Spawn the process
    let mut child = match cmd.spawn() {
        Ok(c) => c,
        Err(e) => {
            return (
                ToolResult {
                    name: tool.name.to_string(),
                    version: None,
                    success: false,
                    duration_ms: start.elapsed().as_millis() as u64,
                    diagnostic_count: 0,
                    error: Some(format!("Failed to start {}: {}", tool.name, e)),
                },
                Vec::new(),
            );
        }
    };

    // Wait with timeout
    let timeout = Duration::from_secs(timeout_secs);
    let status = loop {
        match child.try_wait() {
            Ok(Some(status)) => break Ok(status),
            Ok(None) => {
                if start.elapsed() > timeout {
                    let _ = child.kill();
                    break Err("Timeout");
                }
                std::thread::sleep(Duration::from_millis(100));
            }
            Err(e) => break Err(Box::leak(format!("{}", e).into_boxed_str()) as &str),
        }
    };

    let duration_ms = start.elapsed().as_millis() as u64;

    // Handle timeout or error
    let _exit_status = match status {
        Ok(s) => s,
        Err(e) => {
            return (
                ToolResult {
                    name: tool.name.to_string(),
                    version: get_tool_version(tool.binary),
                    success: false,
                    duration_ms,
                    diagnostic_count: 0,
                    error: Some(e.to_string()),
                },
                Vec::new(),
            );
        }
    };

    // Read stdout and stderr
    let mut stdout = String::new();
    let mut stderr = String::new();

    if let Some(mut out) = child.stdout.take() {
        let _ = out.read_to_string(&mut stdout);
    }
    if let Some(mut err) = child.stderr.take() {
        let _ = err.read_to_string(&mut stderr);
    }

    // Parse the output based on tool type
    let parse_result = parse_tool_output(tool.name, &stdout, &stderr);

    let (diagnostics, error) = match parse_result {
        Ok(diags) => (diags, None),
        Err(e) => {
            // Some tools exit non-zero when they find issues, which is OK
            // Only treat it as an error if we couldn't parse the output
            if !stdout.is_empty() || !stderr.is_empty() {
                // Try to parse anyway for tools that might output to stderr
                let fallback = parse_tool_output(tool.name, &stderr, &stdout);
                match fallback {
                    Ok(diags) => (diags, None),
                    Err(_) => (Vec::new(), Some(format!("Parse error: {}", e))),
                }
            } else {
                (Vec::new(), Some(format!("Parse error: {}", e)))
            }
        }
    };

    let diagnostic_count = diagnostics.len();

    // Tool is successful if it ran and we could parse output (even if it found issues)
    let success = error.is_none();

    (
        ToolResult {
            name: tool.name.to_string(),
            version: get_tool_version(tool.binary),
            success,
            duration_ms,
            diagnostic_count,
            error,
        },
        diagnostics,
    )
}

/// Parse output based on tool name.
fn parse_tool_output(
    tool_name: &str,
    stdout: &str,
    _stderr: &str,
) -> Result<Vec<Diagnostic>, TldrError> {
    match tool_name {
        "pyright" => parse_pyright_output(stdout),
        "ruff" => parse_ruff_output(stdout),
        "tsc" => parse_tsc_text(stdout),
        "eslint" => parse_eslint_output(stdout),
        "cargo check" | "clippy" => parse_cargo_output(stdout),
        "go vet" => parse_go_vet_output(stdout),
        "golangci-lint" => parse_golangci_lint_output(stdout),
        "kotlinc" => parse_kotlinc_output(stdout),
        "detekt" => parse_detekt_output(stdout),
        "swiftc" => parse_swiftc_output(stdout),
        "swiftlint" => parse_swiftlint_output(stdout),
        "dotnet build" => parse_dotnet_build_output(stdout),
        "scalac" => parse_scalac_output(stdout),
        "mix compile" => parse_mix_compile_output(stdout),
        "credo" => parse_credo_output(stdout),
        "luacheck" => parse_luacheck_output(stdout),
        "javac" => parse_javac_output(stdout),
        "checkstyle" => parse_checkstyle_output(stdout),
        "clang" => parse_clang_output(stdout, "clang"),
        "clang-tidy" => parse_clang_output(stdout, "clang-tidy"),
        "rubocop" => parse_rubocop_output(stdout),
        "php" => parse_php_lint_output(stdout),
        "phpstan" => parse_phpstan_output(stdout),
        _ => Err(TldrError::ParseError {
            file: std::path::PathBuf::from(format!("<{}-output>", tool_name)),
            line: None,
            message: format!("Unknown tool: {}", tool_name),
        }),
    }
}

/// Run multiple tools in parallel (or sequentially on single-core systems).
///
/// # Arguments
/// * `tools` - The tools to run
/// * `path` - The path to analyze
/// * `timeout_secs` - Timeout per tool in seconds
///
/// # Returns
/// A DiagnosticsReport with results from all tools.
pub fn run_tools_parallel(
    tools: &[ToolConfig],
    path: &Path,
    timeout_secs: u64,
) -> Result<DiagnosticsReport, TldrError> {
    use std::sync::mpsc;
    use std::thread;

    if tools.is_empty() {
        return Err(TldrError::ParseError {
            file: std::path::PathBuf::from("<diagnostics>"),
            line: None,
            message: "No tools provided".to_string(),
        });
    }

    // Check core count - run sequentially if single core
    let num_cpus = thread::available_parallelism()
        .map(|n| n.get())
        .unwrap_or(1);

    let mut all_diagnostics = Vec::new();
    let mut all_results = Vec::new();

    if num_cpus <= 1 || tools.len() == 1 {
        // Sequential execution
        for tool in tools {
            let (result, diags) = run_tool(tool, path, timeout_secs);
            all_results.push(result);
            all_diagnostics.extend(diags);
        }
    } else {
        // Parallel execution
        let (tx, rx) = mpsc::channel();
        let path = path.to_path_buf();

        let handles: Vec<_> = tools
            .iter()
            .map(|tool| {
                let tx = tx.clone();
                let tool = tool.clone();
                let path = path.clone();

                thread::spawn(move || {
                    let (result, diags) = run_tool(&tool, &path, timeout_secs);
                    let _ = tx.send((result, diags));
                })
            })
            .collect();

        // Drop the original sender so rx.iter() terminates
        drop(tx);

        // Collect results
        for (result, diags) in rx.iter() {
            all_results.push(result);
            all_diagnostics.extend(diags);
        }

        // Wait for all threads
        for handle in handles {
            let _ = handle.join();
        }
    }

    // Compute summary
    let summary = crate::diagnostics::compute_summary(&all_diagnostics);

    Ok(DiagnosticsReport {
        diagnostics: all_diagnostics,
        summary,
        tools_run: all_results,
        files_analyzed: 1, // This would need proper counting
    })
}

/// Get install suggestions for missing tools.
pub fn get_install_suggestion(tool_name: &str) -> &'static str {
    match tool_name {
        "pyright" => "pip install pyright",
        "ruff" => "pip install ruff",
        "tsc" => "npm install -g typescript",
        "eslint" => "npm install -g eslint",
        "golangci-lint" => "go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest",
        "cargo" | "clippy" => "rustup component add clippy",
        "kotlinc" => "Install Kotlin: https://kotlinlang.org/docs/command-line.html",
        "detekt" | "detekt-cli" => "Install detekt: https://detekt.dev/docs/gettingstarted/cli",
        "swiftc" => "Install Xcode or Swift toolchain: https://swift.org/download/",
        "swiftlint" => "brew install swiftlint",
        "dotnet" => "Install .NET SDK: https://dotnet.microsoft.com/download",
        "scalac" => "Install Scala: https://www.scala-lang.org/download/",
        "mix" => "Install Elixir: https://elixir-lang.org/install.html",
        "luacheck" => "luarocks install luacheck",
        "javac" => "Install JDK: https://adoptium.net/",
        "checkstyle" => "Install Checkstyle: https://checkstyle.org/",
        "clang" => "Install LLVM/Clang: https://releases.llvm.org/ or brew install llvm",
        "clang-tidy" => "Install LLVM/Clang: https://releases.llvm.org/ or brew install llvm",
        "rubocop" => "gem install rubocop",
        "php" => "Install PHP: https://www.php.net/downloads",
        "phpstan" => "composer require --dev phpstan/phpstan",
        _ => "Check tool documentation",
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_is_tool_available_which() {
        // 'which' should be available on Unix systems
        #[cfg(unix)]
        assert!(is_tool_available("which"));
    }

    #[test]
    fn test_is_tool_unavailable() {
        assert!(!is_tool_available("nonexistent_tool_xyz_12345"));
    }

    #[test]
    fn test_tools_for_python() {
        let tools = tools_for_language(Language::Python);
        assert!(tools.iter().any(|t| t.name == "pyright"));
        assert!(tools.iter().any(|t| t.name == "ruff"));
    }

    #[test]
    fn test_tools_for_typescript() {
        let tools = tools_for_language(Language::TypeScript);
        assert!(tools.iter().any(|t| t.name == "tsc"));
        assert!(tools.iter().any(|t| t.name == "eslint"));
    }

    #[test]
    fn test_tools_for_rust() {
        let tools = tools_for_language(Language::Rust);
        assert!(tools.iter().any(|t| t.name == "cargo check"));
        assert!(tools.iter().any(|t| t.name == "clippy"));
    }

    #[test]
    fn test_tools_for_go() {
        let tools = tools_for_language(Language::Go);
        assert!(tools.iter().any(|t| t.name == "go vet"));
        assert!(tools.iter().any(|t| t.name == "golangci-lint"));
    }

    #[test]
    fn test_tools_for_kotlin() {
        let tools = tools_for_language(Language::Kotlin);
        assert!(tools.iter().any(|t| t.name == "kotlinc"));
        assert!(tools.iter().any(|t| t.name == "detekt"));
    }

    #[test]
    fn test_tools_for_swift() {
        let tools = tools_for_language(Language::Swift);
        assert!(tools.iter().any(|t| t.name == "swiftc"));
        assert!(tools.iter().any(|t| t.name == "swiftlint"));
    }

    #[test]
    fn test_tools_for_csharp() {
        let tools = tools_for_language(Language::CSharp);
        assert!(tools.iter().any(|t| t.name == "dotnet build"));
    }

    #[test]
    fn test_tools_for_scala() {
        let tools = tools_for_language(Language::Scala);
        assert!(tools.iter().any(|t| t.name == "scalac"));
    }

    #[test]
    fn test_tools_for_elixir() {
        let tools = tools_for_language(Language::Elixir);
        assert!(tools.iter().any(|t| t.name == "mix compile"));
        assert!(tools.iter().any(|t| t.name == "credo"));
    }

    #[test]
    fn test_tools_for_lua() {
        let tools = tools_for_language(Language::Lua);
        assert!(tools.iter().any(|t| t.name == "luacheck"));
    }

    #[test]
    fn test_install_suggestions() {
        assert!(get_install_suggestion("pyright").contains("pip"));
        assert!(get_install_suggestion("eslint").contains("npm"));
    }

    #[test]
    fn test_install_suggestions_new_languages() {
        assert!(get_install_suggestion("kotlinc").contains("kotlin"));
        assert!(get_install_suggestion("swiftlint").contains("brew"));
        assert!(get_install_suggestion("dotnet").contains(".NET"));
        assert!(get_install_suggestion("scalac").contains("scala"));
        assert!(
            get_install_suggestion("mix").contains("elixir")
                || get_install_suggestion("mix").contains("Elixir")
        );
        assert!(get_install_suggestion("luacheck").contains("luarocks"));
    }

    #[test]
    fn test_tools_for_java() {
        let tools = tools_for_language(Language::Java);
        assert!(tools.iter().any(|t| t.name == "javac"));
        assert!(tools.iter().any(|t| t.name == "checkstyle"));
    }

    #[test]
    fn test_tools_for_c() {
        let tools = tools_for_language(Language::C);
        assert!(tools.iter().any(|t| t.name == "clang"));
        assert!(tools.iter().any(|t| t.name == "clang-tidy"));
    }

    #[test]
    fn test_tools_for_cpp() {
        let tools = tools_for_language(Language::Cpp);
        assert!(tools.iter().any(|t| t.name == "clang"));
        assert!(tools.iter().any(|t| t.name == "clang-tidy"));
    }

    #[test]
    fn test_tools_for_ruby() {
        let tools = tools_for_language(Language::Ruby);
        assert!(tools.iter().any(|t| t.name == "rubocop"));
    }

    #[test]
    fn test_tools_for_php() {
        let tools = tools_for_language(Language::Php);
        assert!(tools.iter().any(|t| t.name == "php"));
        assert!(tools.iter().any(|t| t.name == "phpstan"));
    }

    #[test]
    fn test_install_suggestions_java_c_ruby_php() {
        assert!(get_install_suggestion("javac").contains("JDK"));
        assert!(get_install_suggestion("checkstyle").contains("Checkstyle"));
        assert!(
            get_install_suggestion("clang").contains("LLVM")
                || get_install_suggestion("clang").contains("llvm")
        );
        assert!(
            get_install_suggestion("clang-tidy").contains("LLVM")
                || get_install_suggestion("clang-tidy").contains("llvm")
        );
        assert!(get_install_suggestion("rubocop").contains("gem"));
        assert!(
            get_install_suggestion("php").contains("PHP")
                || get_install_suggestion("php").contains("php")
        );
        assert!(get_install_suggestion("phpstan").contains("composer"));
    }
}