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};
27
28/// Swift language entry.
29pub static SWIFT: LanguageSupport = LanguageSupport {
30    name: "swift",
31    display_name: "Swift",
32    extensions: &[".swift"],
33    filenames: &[],
34    filename_prefixes: &[],
35    tools: &[&SWIFTLINT],
36    conventions: &[
37        "Force unwraps and force tries on values that can be nil or throw",
38        "Retain cycles from closures capturing self strongly",
39        "Unowned references that outlive their target",
40        "Main-actor isolation violated from a synchronous context",
41    ],
42    vendored_dirs: &[".build", "Pods", "DerivedData"],
43};
44
45/// The family's entries in registration order. See `ALL_LANGUAGES`.
46pub(crate) static FAMILY: &[&LanguageSupport] = &[&SWIFT];