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