`--working-directory` has no effect since 0.65.0

Aperta Adatta ai principianti
#6,907 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@haruna-miyamoto ci sta già lavorando.

Dal 14/9/2026.

  • #6908 di @haruna-miyamoto — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
swift
Ambito
cli, tooling

Direzione di ricerca

Inizia da LintOrAnalyzeCommand.run(_:) e riproduci il problema con il comando SwiftLint e la configurazione forniti. Verifica quando la directory di lavoro viene ripristinata rispetto al linting, quindi verifica che --working-directory trovi ~/a/.swiftlint.yml e sopprima la violazione di identifier_name senza modificare il comportamento quando l’opzione è assente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

New Issue Checklist
Bug Description

--working-directory no longer takes effect. The configuration file is still looked up in the directory SwiftLint was started from, so it is not found and SwiftLint silently falls back to the default configuration.

mkdir -p ~/a/b
printf 'disabled_rules:\n  - identifier_name\n' > ~/a/.swiftlint.yml
printf 'enum Size {\n    case m\n}\n' > ~/a/b/Bad.swift

cd ~/a/b
swiftlint lint --working-directory ~/a --no-cache --quiet ~/a/b/Bad.swift

~/a/.swiftlint.yml disables identifier_name, so 0.64.1 and earlier report nothing. 0.65.0, 0.65.1 and main report:

~/a/b/Bad.swift:2:10: error: Identifier Name Violation: Enum element name 'm' should be between 3 and 40 characters long (identifier_name)

The defer restoring the directory in LintOrAnalyzeCommand.run(_:) is scoped to the if let workingDirectory block, so it fires at that block's closing brace, before linting starts. It was added in #6048. Moving it to the function's scope, with the restore target held in an optional so that the directory is only restored when the option actually moved it, would fix it without changing anything when the option is not passed. I'm happy to open a PR.

This mainly hurts the SwiftPM plugins, which run from the package directory and need the option to reach a .swiftlint.yml above it.

Environment
  • SwiftLint version 0.65.1 (0.65.0 and main are also affected, 0.64.1 and earlier are not)
  • Xcode 26.5
  • Installation method used: official SwiftLintBinary.artifactbundle release
  • Configuration file:
disabled_rules:
  - identifier_name

No nested configurations.

Lingua principale
Swift
Stelle
19.8k
Fork
2.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di realm/SwiftLint

Tutte le issue di realm/SwiftLint

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.