Skip to content

Commit a041b3a

Browse files
authored
Merge branch 'main' into jgrubb-redundant-type-interfaces
2 parents e8b3990 + 3344fc6 commit a041b3a

File tree

57 files changed

+249
-118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+249
-118
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424
* The `redundant_type_annotation` rule gains a new option,
2525
`ignore_properties`, that skips enforcement on members in a
2626
type declaration (like a `struct`). This helps the rule coexist with
27-
the `explicit_type_interface` rule that requires such redundancy.
27+
the `explicit_type_interface` rule that requires such redundancy.
2828
[jaredgrubb](https://github.com/jaredgrubb)
2929
[#3750](https://github.com/realm/SwiftLint/issues/3750)
3030

31+
* Adds a `lenient` configuration file setting, equivalent to the `--lenient`
32+
command line option.
33+
[Martin Redington](https://github.com/mildm8nnered)
34+
[#5801](https://github.com/realm/SwiftLint/issues/5801)
35+
3136
#### Bug Fixes
3237

3338
* Run command plugin in whole package if no targets are defined in the
@@ -46,6 +51,11 @@
4651
[SimplyDanny](https://github.com/SimplyDanny)
4752
[#5167](https://github.com/realm/SwiftLint/issues/5167)
4853

54+
* Only pass cache path and directory paths to commands that accept these arguments
55+
in the command plugin.
56+
[SimplyDanny](https://github.com/SimplyDanny)
57+
[#5848](https://github.com/realm/SwiftLint/issues/5848)
58+
4959
* Do not throw deprecation warning if deprecated property is not
5060
presented in configuration.
5161
[chipp](https://github.com/chipp)

Gemfile.lock

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ GEM
122122
public_suffix (4.0.7)
123123
rchardet (1.8.0)
124124
redcarpet (3.6.0)
125-
rexml (3.3.6)
126-
strscan
125+
rexml (3.3.9)
127126
rouge (4.3.0)
128127
ruby-macho (2.5.1)
129128
ruby2_keywords (0.0.5)
@@ -134,7 +133,6 @@ GEM
134133
faraday (>= 0.17.3, < 3)
135134
sqlite3 (1.7.3-arm64-darwin)
136135
sqlite3 (1.7.3-x86_64-linux)
137-
strscan (3.1.0)
138136
terminal-table (3.0.2)
139137
unicode-display_width (>= 1.1.1, < 3)
140138
typhoeus (1.4.0)

Plugins/SwiftLintCommandPlugin/SwiftLintCommandPlugin.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import Foundation
22
import PackagePlugin
33

4+
private let commandsNotExpectingPaths: Set<String> = [
5+
"docs",
6+
"generate-docs",
7+
"baseline",
8+
"reporters",
9+
"rules",
10+
"version",
11+
]
12+
13+
private let commandsWithoutCachPathOption: Set<String> = commandsNotExpectingPaths.union([
14+
"analyze",
15+
])
16+
417
@main
518
struct SwiftLintCommandPlugin: CommandPlugin {
619
func performCommand(context: PluginContext, arguments: [String]) throws {
@@ -13,7 +26,7 @@ struct SwiftLintCommandPlugin: CommandPlugin {
1326
let targets = targetNames.isEmpty
1427
? context.package.targets
1528
: try context.package.targets(named: targetNames)
16-
guard !targets.isEmpty else {
29+
if targets.isEmpty || !commandsNotExpectingPaths.isDisjoint(with: arguments) {
1730
try run(with: context, arguments: arguments)
1831
return
1932
}
@@ -34,11 +47,12 @@ struct SwiftLintCommandPlugin: CommandPlugin {
3447
process.currentDirectoryURL = URL(fileURLWithPath: context.package.directory.string)
3548
process.executableURL = URL(fileURLWithPath: try context.tool(named: "swiftlint").path.string)
3649
process.arguments = arguments
37-
if !arguments.contains("analyze") {
38-
// The analyze command does not support the `--cache-path` argument.
50+
if commandsWithoutCachPathOption.isDisjoint(with: arguments) {
3951
process.arguments! += ["--cache-path", "\(context.pluginWorkDirectory.string)"]
4052
}
41-
process.arguments! += [directory]
53+
if commandsNotExpectingPaths.isDisjoint(with: arguments) {
54+
process.arguments! += [directory]
55+
}
4256

4357
try process.run()
4458
process.waitUntilExit()

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ allow_zero_lintable_files: false
723723
# If true, SwiftLint will treat all warnings as errors.
724724
strict: false
725725

726+
# If true, SwiftLint will treat all errors as warnings.
727+
lenient: false
728+
726729
# The path to a baseline file, which will be used to filter out detected violations.
727730
baseline: Baseline.json
728731

Source/SwiftLintBuiltInRules/Rules/Lint/CaptureVariableRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private extension SwiftLintFile {
264264
let path = self.path,
265265
let response = try? Request.index(file: path, arguments: compilerArguments).sendIfNotDisabled()
266266
else {
267-
Issue.indexingError(path: path, ruleID: CaptureVariableRule.description.identifier).print()
267+
Issue.indexingError(path: path, ruleID: CaptureVariableRule.identifier).print()
268268
return nil
269269
}
270270

Source/SwiftLintBuiltInRules/Rules/Lint/InertDeferRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftSyntax
22

33
// TODO: [12/23/2024] Remove deprecation warning after ~2 years.
44
private let warnDeprecatedOnceImpl: Void = {
5-
Issue.ruleDeprecated(ruleID: InertDeferRule.description.identifier).print()
5+
Issue.ruleDeprecated(ruleID: InertDeferRule.identifier).print()
66
}()
77

88
private func warnDeprecatedOnce() {

Source/SwiftLintBuiltInRules/Rules/Lint/TypesafeArrayInitRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct TypesafeArrayInitRule: AnalyzerRule {
6767
return []
6868
}
6969
guard compilerArguments.isNotEmpty else {
70-
Issue.missingCompilerArguments(path: file.path, ruleID: Self.description.identifier).print()
70+
Issue.missingCompilerArguments(path: file.path, ruleID: Self.identifier).print()
7171
return []
7272
}
7373
return Self.parentRule.validate(file: file)

Source/SwiftLintBuiltInRules/Rules/Lint/UnusedCaptureListRule.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftSyntax
22

33
// TODO: [12/22/2024] Remove deprecation warning after ~2 years.
44
private let warnDeprecatedOnceImpl: Void = {
5-
Issue.ruleDeprecated(ruleID: UnusedCaptureListRule.description.identifier).print()
5+
Issue.ruleDeprecated(ruleID: UnusedCaptureListRule.identifier).print()
66
}()
77

88
private func warnDeprecatedOnce() {

Source/SwiftLintBuiltInRules/Rules/Lint/UnusedDeclarationRule.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ struct UnusedDeclarationRule: AnalyzerRule, CollectingRule {
3030

3131
func collectInfo(for file: SwiftLintFile, compilerArguments: [String]) -> Self.FileUSRs {
3232
guard compilerArguments.isNotEmpty else {
33-
Issue.missingCompilerArguments(path: file.path, ruleID: Self.description.identifier).print()
33+
Issue.missingCompilerArguments(path: file.path, ruleID: Self.identifier).print()
3434
return .empty
3535
}
3636

3737
guard let index = file.index(compilerArguments: compilerArguments), index.value.isNotEmpty else {
38-
Issue.indexingError(path: file.path, ruleID: Self.description.identifier).print()
38+
Issue.indexingError(path: file.path, ruleID: Self.identifier).print()
3939
return .empty
4040
}
4141

4242
guard let editorOpen = (try? Request.editorOpen(file: file.file).sendIfNotDisabled())
4343
.map(SourceKittenDictionary.init) else {
44-
Issue.fileNotReadable(path: file.path, ruleID: Self.description.identifier).print()
44+
Issue.fileNotReadable(path: file.path, ruleID: Self.identifier).print()
4545
return .empty
4646
}
4747

Source/SwiftLintBuiltInRules/Rules/Lint/UnusedImportRule.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct UnusedImportRule: CorrectableRule, AnalyzerRule {
8484

8585
private func importUsage(in file: SwiftLintFile, compilerArguments: [String]) -> [ImportUsage] {
8686
guard compilerArguments.isNotEmpty else {
87-
Issue.missingCompilerArguments(path: file.path, ruleID: Self.description.identifier).print()
87+
Issue.missingCompilerArguments(path: file.path, ruleID: Self.identifier).print()
8888
return []
8989
}
9090

@@ -178,7 +178,7 @@ private extension SwiftLintFile {
178178
file: path!, offset: token.offset, arguments: compilerArguments
179179
)
180180
guard let cursorInfo = (try? cursorInfoRequest.sendIfNotDisabled()).map(SourceKittenDictionary.init) else {
181-
Issue.missingCursorInfo(path: path, ruleID: UnusedImportRule.description.identifier).print()
181+
Issue.missingCursorInfo(path: path, ruleID: UnusedImportRule.identifier).print()
182182
continue
183183
}
184184
if nextIsModuleImport {
@@ -213,7 +213,7 @@ private extension SwiftLintFile {
213213
func operatorImports(arguments: [String], processedTokenOffsets: Set<ByteCount>) -> Set<String> {
214214
guard let index = (try? Request.index(file: path!, arguments: arguments).sendIfNotDisabled())
215215
.map(SourceKittenDictionary.init) else {
216-
Issue.indexingError(path: path, ruleID: UnusedImportRule.description.identifier).print()
216+
Issue.indexingError(path: path, ruleID: UnusedImportRule.identifier).print()
217217
return []
218218
}
219219

@@ -236,7 +236,7 @@ private extension SwiftLintFile {
236236
)
237237
guard let cursorInfo = (try? cursorInfoRequest.sendIfNotDisabled())
238238
.map(SourceKittenDictionary.init) else {
239-
Issue.missingCursorInfo(path: path, ruleID: UnusedImportRule.description.identifier).print()
239+
Issue.missingCursorInfo(path: path, ruleID: UnusedImportRule.identifier).print()
240240
continue
241241
}
242242

0 commit comments

Comments
 (0)