Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/actor-credentials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

jobs:
configure:
if: false
runs-on: ubuntu-slim
outputs:
name: ${{ steps.configure_git_author.outputs.name }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
bazel_linux:
if: false
name: Bazel, Linux, Swift 6.2 # pre-installed
runs-on: ubuntu-24.04
steps:
Expand All @@ -22,6 +23,7 @@ jobs:
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}

plugins_linux:
if: false
name: SPM plugins, Linux, Swift ${{ matrix.version }}
runs-on: ubuntu-24.04
strategy:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
if: false
name: Perform
runs-on: ubuntu-24.04
# Swift containers don't work with Copilot
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:

jobs:
set-context:
if: false
name: Set Context
runs-on: ubuntu-slim
permissions: {}
Expand Down Expand Up @@ -50,6 +51,7 @@ jobs:
INPUTS_TAG: ${{ inputs.tag }}

build-amd64:
if: false
name: Build AMD64 Image
runs-on: ubuntu-24.04
permissions:
Expand All @@ -72,6 +74,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

build-arm64:
if: false
name: Build ARM64 Image
runs-on: ubuntu-24.04-arm
permissions:
Expand All @@ -94,6 +97,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}

merge:
if: false
name: Create Multi-Platform Image
runs-on: ubuntu-24.04
permissions:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
create-docs:
if: false
name: Create
runs-on: ubuntu-24.04
permissions:
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
name: Deploy
runs-on: ubuntu-slim
needs: create-docs
if: github.event_name == 'push'
if: false # github.event_name == 'push'
permissions:
pages: write
id-token: write
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ permissions:

jobs:
lint-swift:
if: false
name: Swift
runs-on: ubuntu-24.04 # "Noble Numbat"
steps:
Expand All @@ -22,6 +23,7 @@ jobs:
- name: Lint
run: ./bazel-bin/swiftlint lint --reporter github-actions-logging --strict 2> /dev/null
lint-markdown:
if: false
name: Markdown
runs-on: ubuntu-slim
steps:
Expand All @@ -36,6 +38,7 @@ jobs:
CONTRIBUTING.md
README.md
lint-actions:
if: false
name: Actions
runs-on: ubuntu-24.04
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/plugins-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:

jobs:
sync:
if: false
name: Sync Plugins Folder
runs-on: ubuntu-slim
steps:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
setup-credentials:
if: false
name: Setup Actor Credentials
uses: ./.github/workflows/actor-credentials.yml
with:
Expand All @@ -15,6 +16,7 @@ jobs:
secrets: inherit

merge-into-main:
if: false
name: Merge into main
needs: setup-credentials
runs-on: ubuntu-slim
Expand All @@ -40,6 +42,7 @@ jobs:
TAG_NAME: ${{ github.event.release.tag_name }}

publish-pod:
if: false
name: Publish Pod
needs:
- merge-into-main
Expand All @@ -59,6 +62,7 @@ jobs:
COCOAPODS_TRUNK_TOKEN: ${{ secrets[format('COCOAPODS_TRUNK_TOKEN_{0}', needs.setup-credentials.outputs.author_uppercase)] }}

dispatch-plugins:
if: false
name: Dispatch Plugins Repository
needs: merge-into-main
runs-on: ubuntu-slim
Expand Down Expand Up @@ -87,6 +91,7 @@ jobs:
}

bump-homebrew:
if: false
name: Bump Homebrew Formula
needs:
- merge-into-main
Expand All @@ -110,6 +115,7 @@ jobs:
formulae: swiftlint

build-docker:
if: false
name: Build Docker Images
needs: merge-into-main
uses: ./.github/workflows/docker.yml
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:

jobs:
setup-credentials:
if: false
name: Setup Actor Credentials
uses: ./.github/workflows/actor-credentials.yml
with:
Expand All @@ -28,6 +29,7 @@ jobs:
secrets: inherit

prepare-release:
if: false
name: Prepare Release
runs-on: ubuntu-slim
needs: setup-credentials
Expand Down Expand Up @@ -64,6 +66,7 @@ jobs:
git push origin HEAD

verify-podspec:
if: false
name: Verify Podspec
runs-on: macOS-14
permissions:
Expand All @@ -88,6 +91,7 @@ jobs:
make pod_lint

build-linux:
if: false
name: Build Linux ${{ matrix.arch }} Binary
needs: prepare-release
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -119,6 +123,7 @@ jobs:
path: .build/release/swiftlint

build-static-linux:
if: false
name: Build Static Linux ${{ matrix.arch }} Binary
needs: prepare-release
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -182,6 +187,7 @@ jobs:
LICENSE.mimalloc

build-macos:
if: false
name: Build macOS Binaries
needs: prepare-release
runs-on: macOS-26
Expand All @@ -206,6 +212,7 @@ jobs:
if-no-files-found: error

create-release:
if: false
name: Create Release
needs:
- setup-credentials
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ permissions:

jobs:
close-stale-issues:
if: false
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:

jobs:
spm_linux:
if: false
name: SPM, Linux, Swift 6.2
runs-on: ubuntu-24.04
container: swift:6.2-noble
Expand All @@ -34,6 +35,7 @@ jobs:
rule: spm_test

spm_macos:
if: false
name: SPM, macOS ${{ matrix.macOS }}, Xcode ${{ matrix.xcode }}
runs-on: macos-${{ matrix.macOS }}
strategy:
Expand All @@ -60,6 +62,7 @@ jobs:
run: make spm_test

spm_windows:
if: false
name: SPM, Windows ${{ matrix.windows-display-name }}
runs-on: windows-${{ matrix.windows-version }}
env:
Expand Down
4 changes: 2 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ file_name:
- SwiftSyntax+SwiftLint.swift
- TestHelpers.swift
excluded_paths:
- Tests/GeneratedTests/GeneratedTests_\d\d\.swift
- Tests/FileSystemAccessTests/.+\.swift
- Tests[\\/]GeneratedTests[\\/]GeneratedTests_\d\d\.swift
- Tests[\\/]FileSystemAccessTests[\\/].+\.swift
final_test_case: *unit_test_configuration
function_body_length: 60
identifier_name:
Expand Down
4 changes: 3 additions & 1 deletion Source/SwiftLintCore/Models/Baseline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ private extension StyleViolation {
var withAbsolutePath: StyleViolation {
let absolutePath: String? =
if let relativePath = location.file {
FileManager.default.currentDirectoryPath + "/" + relativePath
URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
.appendingPathComponent(relativePath)
.filepath
} else {
nil
}
Expand Down
11 changes: 10 additions & 1 deletion Source/SwiftLintCore/Models/Location.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ public struct Location: CustomStringConvertible, Comparable, Codable, Sendable {

/// The file path for this location relative to the current working directory.
public var relativeFile: String? {
file?.replacingOccurrences(of: FileManager.default.currentDirectoryPath + "/", with: "")
guard let file else { return nil }
let fileComponents = URL(fileURLWithPath: file).pathComponents
let baseComponents = URL(fileURLWithPath: FileManager.default.currentDirectoryPath, isDirectory: true)
.pathComponents

guard fileComponents.starts(with: baseComponents) else {
return file
}

return fileComponents.dropFirst(baseComponents.count).joined(separator: "/")
}

/// Creates a `Location` by specifying its properties directly.
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Configuration+CommandLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension Configuration {
pathComponents.removeFirst()
}

return pathComponents.joined(separator: "/")
return pathComponents.reduce(URL(fileURLWithPath: "/")) { $0.appendingPathComponent($1) }.filepath
}

private func linters(for filesPerConfiguration: [Configuration: [SwiftLintFile]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ extension Configuration {
#endif
}

let versionedDirectory = [
"SwiftLint",
Version.current.value,
ExecutableInfo.buildID,
].compactMap(\.self).joined(separator: "/")

let folder = baseURL.appendingPathComponent(versionedDirectory)
var folder = baseURL
.appendingPathComponent("SwiftLint")
.appendingPathComponent(Version.current.value)
if let buildID = ExecutableInfo.buildID {
folder = folder.appendingPathComponent(buildID)
}

do {
try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true, attributes: nil)
Expand Down
4 changes: 4 additions & 0 deletions Source/swiftlint/Commands/Docs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ private func open(_ url: URL) {
let command = "xdg-open"
process.arguments = [command, url.absoluteString]
try? process.run()
#elseif os(Windows)
process.executableURL = URL(fileURLWithPath: "cmd", isDirectory: false)
process.arguments = ["/C", "start", url.absoluteString]
try? process.run()
#else
process.launchPath = "/usr/bin/env"
let command = "open"
Expand Down
11 changes: 6 additions & 5 deletions Tests/BuiltInRulesTests/FileNameRuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import TestHelpers
import XCTest

private let fixturesDirectory = "\(TestResources.path())/FileNameRuleFixtures"
private let fixturesDirectory =
URL(fileURLWithPath: TestResources.path()).appendingPathComponent("FileNameRuleFixtures").filepath

final class FileNameRuleTests: SwiftLintTestCase {
private func validate(fileName: String,
Expand Down Expand Up @@ -165,7 +166,7 @@ final class FileNameRuleTests: SwiftLintTestCase {
try validate(
fileName: "main.swift",
excluded: [],
excludedPaths: [".*/FileNameRuleFixtures/.*"]
excludedPaths: [#".*[\\/]FileNameRuleFixtures[\\/].*"#]
).isEmpty
)
}
Expand All @@ -175,7 +176,7 @@ final class FileNameRuleTests: SwiftLintTestCase {
try validate(
fileName: "main.swift",
excluded: [],
excludedPaths: [".*/OtherFolder/.*", "MAIN\\.swift"]
excludedPaths: [#".*[\\/]OtherFolder[\\/].*"#, "MAIN\\.swift"]
).isNotEmpty
)
}
Expand All @@ -197,15 +198,15 @@ final class FileNameRuleTests: SwiftLintTestCase {
try validate(
fileName: "main.swift",
excluded: [],
excludedPaths: ["/FileNameRuleFixtures/.*", "("]
excludedPaths: [#"[\\/]FileNameRuleFixtures[\\/].*"#, "("]
)
)

XCTAssertThrowsError(
try validate(
fileName: "main.swift",
excluded: [],
excludedPaths: ["/FileNameRuleFixtures/.*", "(", ".*.swift"]
excludedPaths: [#"[\\/]FileNameRuleFixtures[\\/].*"#, "(", ".*.swift"]
)
)
}
Expand Down
Loading