Skip to content

Commit 9e5a526

Browse files
authored
Enable unneeded_throws_rethrows rule (#6335)
1 parent 8989753 commit 9e5a526

20 files changed

Lines changed: 31 additions & 34 deletions

.swiftlint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ disabled_rules:
4646
- todo
4747
- trailing_closure
4848
- type_contents_order
49-
- unneeded_throws_rethrows
5049
- vertical_whitespace_between_cases
5150

5251
# Configurations

Plugins/SwiftLintCommandPlugin/CommandContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ extension XcodePluginContext: CommandContext {
7979
"target"
8080
}
8181

82-
func targets(named names: [String]) throws -> [(paths: [String], name: String)] {
82+
func targets(named names: [String]) -> [(paths: [String], name: String)] {
8383
if names.isEmpty {
8484
return [(paths: [xcodeProject.directory.string], name: xcodeProject.displayName)]
8585
}

Source/SwiftLintBuiltInRules/Rules/RuleConfigurations/MultilineParametersConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct MultilineParametersConfiguration: SeverityBasedRuleConfiguration {
1111
@ConfigurationElement(key: "max_number_of_single_line_parameters")
1212
private(set) var maxNumberOfSingleLineParameters: Int?
1313

14+
// swiftlint:disable:next unneeded_throws_rethrows
1415
func validate() throws(Issue) {
1516
guard let maxNumberOfSingleLineParameters else {
1617
return

Source/SwiftLintCore/Protocols/RuleConfiguration.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public extension SeverityBasedRuleConfiguration {
3535
public extension RuleConfiguration {
3636
var parameterDescription: RuleConfigurationDescription? { nil }
3737

38+
// swiftlint:disable:next unneeded_throws_rethrows
3839
func validate() throws(Issue) {
3940
// Do nothing by default.
4041
}

Source/SwiftLintCoreMacros/TemporaryDirectory.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ private let pathPrefix = ""
99
#endif
1010

1111
enum TemporaryDirectory: BodyMacro {
12-
static func expansion(
13-
of _: AttributeSyntax,
14-
providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax,
15-
in context: some MacroExpansionContext
16-
) throws -> [CodeBlockItemSyntax] {
12+
static func expansion(of _: AttributeSyntax,
13+
providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax,
14+
in context: some MacroExpansionContext) -> [CodeBlockItemSyntax] {
1715
guard let body = declaration.body else {
1816
context.diagnose(SwiftLintCoreMacroError.noBody.diagnose(at: declaration))
1917
return []

Source/SwiftLintCoreMacros/WorkingDirectory.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import SwiftSyntaxBuilder
33
import SwiftSyntaxMacros
44

55
enum WorkingDirectory: BodyMacro {
6-
static func expansion(
7-
of attributes: AttributeSyntax,
8-
providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax,
9-
in context: some MacroExpansionContext
10-
) throws -> [CodeBlockItemSyntax] {
6+
static func expansion(of attributes: AttributeSyntax,
7+
providingBodyFor declaration: some DeclSyntaxProtocol & WithOptionalCodeBlockSyntax,
8+
in context: some MacroExpansionContext) -> [CodeBlockItemSyntax] {
119
guard let body = declaration.body else {
1210
context.diagnose(SwiftLintCoreMacroError.noBody.diagnose(at: declaration))
1311
return []

Source/swiftlint/Commands/Baseline.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extension SwiftLint {
3838

3939
func run() throws {
4040
let savedBaseline = try SwiftLintCore.Baseline(fromPath: options.baseline)
41-
try report(savedBaseline.violations, using: reportingOptions.reporter, to: reportingOptions.output)
41+
report(savedBaseline.violations, using: reportingOptions.reporter, to: reportingOptions.output)
4242
}
4343
}
4444

@@ -63,12 +63,12 @@ extension SwiftLint {
6363
func run() throws {
6464
let baseline = try SwiftLintCore.Baseline(fromPath: options.baseline)
6565
let otherBaseline = try SwiftLintCore.Baseline(fromPath: otherBaseline)
66-
try report(baseline.compare(otherBaseline), using: reportingOptions.reporter, to: reportingOptions.output)
66+
report(baseline.compare(otherBaseline), using: reportingOptions.reporter, to: reportingOptions.output)
6767
}
6868
}
6969
}
7070

71-
private func report(_ violations: [StyleViolation], using reporterIdentifier: String?, to output: String?) throws {
71+
private func report(_ violations: [StyleViolation], using reporterIdentifier: String?, to output: String?) {
7272
let reporter = reporterFrom(identifier: reporterIdentifier)
7373
let report = reporter.generateReport(violations)
7474
if report.isNotEmpty {

Source/swiftlint/Commands/Docs.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension SwiftLint {
1111
@Argument(help: "The identifier of the rule to open the documentation for")
1212
var ruleID: String?
1313

14-
func run() throws {
14+
func run() {
1515
var subPage = ""
1616
if let ruleID {
1717
if RuleRegistry.shared.rule(forID: ruleID) == nil {

Source/swiftlint/Commands/Reporters.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extension SwiftLint {
66
struct Reporters: ParsableCommand {
77
static let configuration = CommandConfiguration(abstract: "Display the list of reporters and their identifiers")
88

9-
func run() throws {
9+
func run() {
1010
print(TextTable(reporters: reportersList).render())
1111
}
1212
}

Tests/BuiltInRulesTests/ExpiringTodoRuleTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ final class ExpiringTodoRuleTests: SwiftLintTestCase {
123123
XCTAssertEqual(violations[0].location.line, 2)
124124
}
125125

126-
func testBadExpiryTodoFormat() throws {
126+
func testBadExpiryTodoFormat() {
127127
let ruleConfig = ExpiringTodoConfiguration(
128128
dateFormat: "dd/yyyy/MM"
129129
)

0 commit comments

Comments
 (0)