Skip to content

swiftlint_run

Run SwiftLint on your Swift source files to identify code style violations and potential issues. This tool performs a read-only analysis and reports warnings and errors based on your project’s SwiftLint configuration. It does not modify any files — use swiftlint_fix to auto-correct fixable violations.

ParameterTypeRequiredDefaultDescription
pathstringNoCurrent directoryAbsolute path to the file or directory to lint
configstringNoAuto-detected .swiftlint.ymlAbsolute path to a custom SwiftLint configuration file

“Run SwiftLint on my FitnessTracker project”

{
"path": "/Users/dev/Projects/FitnessTracker"
}

“Check the WorkoutViewModel for lint issues”

{
"path": "/Users/dev/Projects/FitnessTracker/FitnessTracker/ViewModels/WorkoutViewModel.swift"
}

“Run SwiftLint with our team’s strict config on the Sources directory”

{
"path": "/Users/dev/Projects/FitnessTracker/Sources",
"config": "/Users/dev/Projects/FitnessTracker/.swiftlint-strict.yml"
}

“Run SwiftLint in the current directory”

{}
Running SwiftLint...
/Users/dev/Projects/FitnessTracker/FitnessTracker/ViewModels/WorkoutViewModel.swift:12:1:
warning: Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
/Users/dev/Projects/FitnessTracker/FitnessTracker/Views/WorkoutDetailView.swift:34:5:
warning: Force Cast Violation: Force casts should be avoided (force_cast)
/Users/dev/Projects/FitnessTracker/FitnessTracker/Services/APIClient.swift:67:1:
warning: File Length Violation: File should contain 400 lines or less: currently contains 423 (file_length)
/Users/dev/Projects/FitnessTracker/FitnessTracker/Services/APIClient.swift:89:45:
error: Force Try Violation: Force tries should be avoided (force_try)
/Users/dev/Projects/FitnessTracker/FitnessTracker/Models/Workout.swift:8:5:
warning: Identifier Name Violation: Variable name 'x' should be between 2 and 40 characters long (identifier_name)
Summary: 4 warnings, 1 error (5 total violations in 4 files)

When no violations are found:

Running SwiftLint...
No violations found. All files pass SwiftLint checks.
  • swiftlint_fix — Auto-fix violations that SwiftLint can correct automatically
  • swift_format_run — Run swift-format for additional formatting checks
  • build_warnings — Check for compiler warnings in addition to lint violations