Skip to content

Commit

Permalink
change: name and description
Browse files Browse the repository at this point in the history
  • Loading branch information
u-abyss committed Feb 11, 2024
1 parent 2f86326 commit dfbec83
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@

* Make `empty_count` auto-correctable.
[KS1019](https://github.com/KS1019/)
* Add new `functions_arguments_spacing` rule to remove the space before the first function argument
and after the last argument.
* Add new `no_unnecessary_spaces` rule that No space before the first and after the last argument and exactly one space after every comma.
[u-abyss](https://github.com/u-abyss)
[#5259](https://github.com/realm/SwiftLint/issues/5224)

Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintBuiltInRules/Models/BuiltInRules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public let builtInRules: [any Rule.Type] = [
ForceCastRule.self,
ForceTryRule.self,
ForceUnwrappingRule.self,
FunctionArgumentsSpacingRule.self,
FunctionBodyLengthRule.self,
FunctionDefaultParameterAtEndRule.self,
FunctionParameterCountRule.self,
Expand Down Expand Up @@ -135,6 +134,7 @@ public let builtInRules: [any Rule.Type] = [
NonOptionalStringDataConversionRule.self,
NonOverridableClassDeclarationRule.self,
NotificationCenterDetachmentRule.self,
NoUnnecessarySpacesRule.self,
NumberSeparatorRule.self,
ObjectLiteralRule.self,
OneDelarationPerFileRule.self,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import SwiftSyntax

@SwiftSyntaxRule
struct FunctionArgumentsSpacingRule: Rule {
struct NoUnnecessarySpacesRule: Rule {
var configuration = SeverityConfiguration<Self>(.warning)

static let description = RuleDescription(
identifier: "functions_arguments_spacing",
name: "Function Arguments Spacing",
description: "Remove the space before the first function argument and after the last argument",
identifier: "no_unnecessary_spaces",
name: "no Unnecessary Spaces",
description: "No space before the first and after the last argument and exactly one space after every comma",
kind: .lint,
nonTriggeringExamples: [
Example("f()"),
Expand Down Expand Up @@ -75,7 +75,7 @@ private extension TriviaPiece {
}
}

private extension FunctionArgumentsSpacingRule {
private extension NoUnnecessarySpacesRule {
final class Visitor: ViolationsSyntaxVisitor<ConfigurationType> {
override func visitPost(_ node: FunctionCallExprSyntax) {
guard let leftParen = node.leftParen else { return }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct VerticalWhitespaceRule: CorrectableRule {
Example("let b = 0\n\n\nclass AAA {}\n"): Example("let b = 0\n\nclass AAA {}\n"),
Example("let c = 0\n\n\nlet num = 1\n"): Example("let c = 0\n\nlet num = 1\n"),
Example("// bca \n\n\n"): Example("// bca \n\n")
]// End of line autocorrections are handled by Trailing Newline Rule.
] // End of line autocorrections are handled by Trailing Newline Rule.
)

private var configuredDescriptionReason: String {
Expand Down
12 changes: 6 additions & 6 deletions Tests/GeneratedTests/GeneratedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,6 @@ class ForceUnwrappingRuleGeneratedTests: SwiftLintTestCase {
}
}

class FunctionArgumentsSpacingRuleGeneratedTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
verifyRule(FunctionArgumentsSpacingRule.description)
}
}

class FunctionBodyLengthRuleGeneratedTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
verifyRule(FunctionBodyLengthRule.description)
Expand Down Expand Up @@ -800,6 +794,12 @@ class NotificationCenterDetachmentRuleGeneratedTests: SwiftLintTestCase {
}
}

class NoUnnecessarySpacesRuleGeneratedTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
verifyRule(NoUnnecessarySpacesRule.description)
}
}

class NumberSeparatorRuleGeneratedTests: SwiftLintTestCase {
func testWithDefaultConfiguration() {
verifyRule(NumberSeparatorRule.description)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@testable import SwiftLintBuiltInRules

class NoUnnecessarySpacesRuleTests: SwiftLintTestCase {
func testNoUnnecessarySpacesRule() {
let description = NoUnnecessarySpacesRule.description
verifyRule(description)
}
}

0 comments on commit dfbec83

Please sign in to comment.