Skip to main content

drep/languages/definitions/
swift.rs

1//! Swift: SwiftLint over `.swift`.
2
3use crate::languages::spec::{
4    DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolArguments,
5    ToolSpec,
6};
7
8/// Swift deterministic checker.
9///
10/// `--quiet` suppresses the "Linting Swift files" banner so stdout is the
11/// SARIF document alone. SwiftLint's SARIF `uri` is repo-relative, verified
12/// against the real binary, so it needs none of the `file:` URI handling
13/// checkstyle's does.
14pub static SWIFTLINT: ToolSpec = ToolSpec {
15    name: "swiftlint",
16    command: &["swiftlint", "lint", "--reporter", "sarif", "--quiet"],
17    local_paths: &[],
18    config_files: &[".swiftlint.yml"],
19    config_flag: None,
20    output_format: OutputFormat::Sarif,
21    diagnostics_stream: DiagnosticsStream::Stdout,
22    timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
23    timeout_context: None,
24    establishes_compilation: false,
25    serial_in_repository: false,
26    arguments: ToolArguments::Files,
27    reads_other_sources: true,
28};
29
30/// Swift language entry.
31pub static SWIFT: LanguageSupport = LanguageSupport {
32    name: "swift",
33    display_name: "Swift",
34    extensions: &[".swift"],
35    filenames: &[],
36    filename_prefixes: &[],
37    tools: &[&SWIFTLINT],
38    conventions: &[
39        "Force unwraps and force tries on values that can be nil or throw",
40        "Retain cycles from closures capturing self strongly",
41        "Unowned references that outlive their target",
42        "Main-actor isolation violated from a synchronous context",
43    ],
44    vendored_dirs: &[".build", "Pods", "DerivedData"],
45};
46
47/// The family's entries in registration order. See `ALL_LANGUAGES`.
48pub(crate) static FAMILY: &[&LanguageSupport] = &[&SWIFT];