Get rid of periods finishing rule descriptions

This commit is contained in:
Danny Mösch 2022-12-23 11:10:01 +01:00
parent ea8b17dd9c
commit e64e82d80d
215 changed files with 320 additions and 346 deletions

BIN
.swp Normal file

Binary file not shown.

View File

@ -23,7 +23,7 @@ enum ImportUsage {
case .unused:
return nil
case .missing(let module):
return "Missing import for referenced module '\(module)'."
return "Missing import for referenced module '\(module)'"
}
}
}

View File

@ -8,7 +8,7 @@ struct BlockBasedKVORule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "block_based_kvo",
name: "Block Based KVO",
description: "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later.",
description: "Prefer the new block based KVO API with keypaths when using Swift 3.2 or later",
kind: .idiomatic,
nonTriggeringExamples: [
Example(#"""

View File

@ -9,7 +9,7 @@ struct ConvenienceTypeRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRul
identifier: "convenience_type",
name: "Convenience Type",
description: "Types used for hosting only static members should be implemented as a caseless enum " +
"to avoid instantiation.",
"to avoid instantiation",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -224,9 +224,9 @@ private extension DiscouragedNoneNameRule {
}
private func reason(type: String) -> String {
let reason = "Avoid naming \(type) `none` as the compiler can think you mean `Optional<T>.none`."
let recommendation = "Consider using an Optional value instead."
return "\(reason) \(recommendation)"
let reason = "Avoid naming \(type) `none` as the compiler can think you mean `Optional<T>.none`"
let recommendation = "consider using an Optional value instead"
return "\(reason); \(recommendation)"
}
}
}

View File

@ -8,7 +8,7 @@ struct DiscouragedObjectLiteralRule: SwiftSyntaxRule, OptInRule, ConfigurationPr
static let description = RuleDescription(
identifier: "discouraged_object_literal",
name: "Discouraged Object Literal",
description: "Prefer initializers over object literals.",
description: "Prefer initializers over object literals",
kind: .idiomatic,
nonTriggeringExamples: [
Example("let image = UIImage(named: aVariable)"),

View File

@ -8,7 +8,7 @@ struct DiscouragedOptionalBooleanRule: OptInRule, ConfigurationProviderRule, Swi
static let description = RuleDescription(
identifier: "discouraged_optional_boolean",
name: "Discouraged Optional Boolean",
description: "Prefer non-optional booleans over optional booleans.",
description: "Prefer non-optional booleans over optional booleans",
kind: .idiomatic,
nonTriggeringExamples: DiscouragedOptionalBooleanRuleExamples.nonTriggeringExamples,
triggeringExamples: DiscouragedOptionalBooleanRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct DiscouragedOptionalCollectionRule: ASTRule, OptInRule, ConfigurationProvi
static let description = RuleDescription(
identifier: "discouraged_optional_collection",
name: "Discouraged Optional Collection",
description: "Prefer empty collection over optional collection.",
description: "Prefer empty collection over optional collection",
kind: .idiomatic,
nonTriggeringExamples: DiscouragedOptionalCollectionExamples.nonTriggeringExamples,
triggeringExamples: DiscouragedOptionalCollectionExamples.triggeringExamples

View File

@ -16,7 +16,7 @@ struct DuplicateImportsRule: ConfigurationProviderRule, CorrectableRule {
static let description = RuleDescription(
identifier: "duplicate_imports",
name: "Duplicate Imports",
description: "Imports should be unique.",
description: "Imports should be unique",
kind: .idiomatic,
nonTriggeringExamples: DuplicateImportsRuleExamples.nonTriggeringExamples,
triggeringExamples: DuplicateImportsRuleExamples.triggeringExamples,

View File

@ -11,7 +11,7 @@ struct ExplicitACLRule: OptInRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "explicit_acl",
name: "Explicit ACL",
description: "All declarations should specify Access Control Level keywords explicitly.",
description: "All declarations should specify Access Control Level keywords explicitly",
kind: .idiomatic,
nonTriggeringExamples: [
Example("internal enum A {}\n"),

View File

@ -8,7 +8,7 @@ struct ExplicitEnumRawValueRule: SwiftSyntaxRule, OptInRule, ConfigurationProvid
static let description = RuleDescription(
identifier: "explicit_enum_raw_value",
name: "Explicit Enum Raw Value",
description: "Enums should be explicitly assigned their raw values.",
description: "Enums should be explicitly assigned their raw values",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -9,7 +9,7 @@ struct ExplicitInitRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRule,
static let description = RuleDescription(
identifier: "explicit_init",
name: "Explicit Init",
description: "Explicitly calling .init() should be avoided.",
description: "Explicitly calling .init() should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct ExplicitTopLevelACLRule: SwiftSyntaxRule, OptInRule, ConfigurationProvide
static let description = RuleDescription(
identifier: "explicit_top_level_acl",
name: "Explicit Top Level ACL",
description: "Top-level declarations should specify Access Control Level keywords explicitly.",
description: "Top-level declarations should specify Access Control Level keywords explicitly",
kind: .idiomatic,
nonTriggeringExamples: [
Example("internal enum A {}\n"),

View File

@ -8,7 +8,7 @@ struct FallthroughRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule {
static let description = RuleDescription(
identifier: "fallthrough",
name: "Fallthrough",
description: "Fallthrough should be avoided.",
description: "Fallthrough should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct FatalErrorMessageRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInR
static let description = RuleDescription(
identifier: "fatal_error_message",
name: "Fatal Error Message",
description: "A fatalError call should have a message.",
description: "A fatalError call should have a message",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -12,7 +12,7 @@ struct FileNameNoSpaceRule: ConfigurationProviderRule, OptInRule, SourceKitFreeR
static let description = RuleDescription(
identifier: "file_name_no_space",
name: "File Name no Space",
description: "File name should not contain any whitespace.",
description: "File name should not contain any whitespace",
kind: .idiomatic
)

View File

@ -14,7 +14,7 @@ struct FileNameRule: ConfigurationProviderRule, OptInRule, SourceKitFreeRule {
static let description = RuleDescription(
identifier: "file_name",
name: "File Name",
description: "File name should match a type or extension declared in the file (if any).",
description: "File name should match a type or extension declared in the file (if any)",
kind: .idiomatic
)

View File

@ -8,7 +8,7 @@ struct ForWhereRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "for_where",
name: "Prefer For-Where",
description: "`where` clauses are preferred over a single `if` inside a `for`.",
description: "`where` clauses are preferred over a single `if` inside a `for`",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct ForceCastRule: ConfigurationProviderRule, SwiftSyntaxRule {
static let description = RuleDescription(
identifier: "force_cast",
name: "Force Cast",
description: "Force casts should be avoided.",
description: "Force casts should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("NSNumber() as? Int\n")

View File

@ -8,7 +8,7 @@ struct ForceTryRule: ConfigurationProviderRule, SwiftSyntaxRule {
static let description = RuleDescription(
identifier: "force_try",
name: "Force Try",
description: "Force tries should be avoided.",
description: "Force tries should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct ForceUnwrappingRule: OptInRule, SwiftSyntaxRule, ConfigurationProviderRul
static let description = RuleDescription(
identifier: "force_unwrapping",
name: "Force Unwrapping",
description: "Force unwrapping should be avoided.",
description: "Force unwrapping should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("if let url = NSURL(string: query)"),

View File

@ -8,7 +8,7 @@ struct FunctionDefaultParameterAtEndRule: SwiftSyntaxRule, ConfigurationProvider
static let description = RuleDescription(
identifier: "function_default_parameter_at_end",
name: "Function Default Parameter at End",
description: "Prefer to locate parameters with defaults toward the end of the parameter list.",
description: "Prefer to locate parameters with defaults toward the end of the parameter list",
kind: .idiomatic,
nonTriggeringExamples: [
Example("func foo(baz: String, bar: Int = 0) {}"),

View File

@ -11,7 +11,7 @@ struct ImplicitlyUnwrappedOptionalRule: SwiftSyntaxRule, ConfigurationProviderRu
static let description = RuleDescription(
identifier: "implicitly_unwrapped_optional",
name: "Implicitly Unwrapped Optional",
description: "Implicitly unwrapped optionals should be avoided when possible.",
description: "Implicitly unwrapped optionals should be avoided when possible",
kind: .idiomatic,
nonTriggeringExamples: [
Example("@IBOutlet private var label: UILabel!"),

View File

@ -8,7 +8,7 @@ struct IsDisjointRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "is_disjoint",
name: "Is Disjoint",
description: "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`.",
description: "Prefer using `Set.isDisjoint(with:)` over `Set.intersection(_:).isEmpty`",
kind: .idiomatic,
nonTriggeringExamples: [
Example("_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet)"),

View File

@ -8,7 +8,7 @@ struct JoinedDefaultParameterRule: SwiftSyntaxCorrectableRule, ConfigurationProv
static let description = RuleDescription(
identifier: "joined_default_parameter",
name: "Joined Default Parameter",
description: "Discouraged explicit usage of the default separator.",
description: "Discouraged explicit usage of the default separator",
kind: .idiomatic,
nonTriggeringExamples: [
Example("let foo = bar.joined()"),

View File

@ -9,7 +9,7 @@ struct LegacyConstantRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "legacy_constant",
name: "Legacy Constant",
description: "Struct-scoped constants are preferred over legacy global constants.",
description: "Struct-scoped constants are preferred over legacy global constants",
kind: .idiomatic,
nonTriggeringExamples: LegacyConstantRuleExamples.nonTriggeringExamples,
triggeringExamples: LegacyConstantRuleExamples.triggeringExamples,

View File

@ -8,7 +8,7 @@ struct LegacyConstructorRule: SwiftSyntaxCorrectableRule, ConfigurationProviderR
static let description = RuleDescription(
identifier: "legacy_constructor",
name: "Legacy Constructor",
description: "Swift constructors are preferred over legacy convenience functions.",
description: "Swift constructors are preferred over legacy convenience functions",
kind: .idiomatic,
nonTriggeringExamples: [
Example("CGPoint(x: 10, y: 10)"),

View File

@ -8,7 +8,7 @@ struct LegacyMultipleRule: OptInRule, ConfigurationProviderRule, SwiftSyntaxRule
static let description = RuleDescription(
identifier: "legacy_multiple",
name: "Legacy Multiple",
description: "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`).",
description: "Prefer using the `isMultiple(of:)` function instead of using the remainder operator (`%`)",
kind: .idiomatic,
nonTriggeringExamples: [
Example("cell.contentView.backgroundColor = indexPath.row.isMultiple(of: 2) ? .gray : .white"),

View File

@ -8,7 +8,7 @@ struct LegacyRandomRule: SwiftSyntaxRule, ConfigurationProviderRule {
static var description = RuleDescription(
identifier: "legacy_random",
name: "Legacy Random",
description: "Prefer using `type.random(in:)` over legacy functions.",
description: "Prefer using `type.random(in:)` over legacy functions",
kind: .idiomatic,
nonTriggeringExamples: [
Example("Int.random(in: 0..<10)\n"),

View File

@ -9,7 +9,7 @@ struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, CorrectableRule
static let description = RuleDescription(
identifier: "nimble_operator",
name: "Nimble Operator",
description: "Prefer Nimble operator overloads over free matcher functions.",
description: "Prefer Nimble operator overloads over free matcher functions",
kind: .idiomatic,
nonTriggeringExamples: [
Example("expect(seagull.squawk) != \"Hi!\"\n"),

View File

@ -8,7 +8,7 @@ struct NoFallthroughOnlyRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "no_fallthrough_only",
name: "No Fallthrough only",
description: "Fallthroughs can only be used if the `case` contains at least one other statement.",
description: "Fallthroughs can only be used if the `case` contains at least one other statement",
kind: .idiomatic,
nonTriggeringExamples: NoFallthroughOnlyRuleExamples.nonTriggeringExamples,
triggeringExamples: NoFallthroughOnlyRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct NoGroupingExtensionRule: OptInRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "no_grouping_extension",
name: "No Grouping Extension",
description: "Extensions shouldn't be used to group code within the same source file.",
description: "Extensions shouldn't be used to group code within the same source file",
kind: .idiomatic,
nonTriggeringExamples: [
Example("protocol Food {}\nextension Food {}\n"),

View File

@ -8,7 +8,7 @@ struct NoMagicNumbersRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "no_magic_numbers",
name: "No Magic Numbers",
description: "Magic numbers should be replaced by named constants.",
description: "Magic numbers should be replaced by named constants",
kind: .idiomatic,
nonTriggeringExamples: [
Example("var foo = 123"),

View File

@ -8,7 +8,7 @@ struct ObjectLiteralRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule
static let description = RuleDescription(
identifier: "object_literal",
name: "Object Literal",
description: "Prefer object literals over image and color inits.",
description: "Prefer object literals over image and color inits",
kind: .idiomatic,
nonTriggeringExamples: [
Example("let image = #imageLiteral(resourceName: \"image.jpg\")"),

View File

@ -8,7 +8,7 @@ struct PatternMatchingKeywordsRule: SwiftSyntaxRule, ConfigurationProviderRule,
static let description = RuleDescription(
identifier: "pattern_matching_keywords",
name: "Pattern Matching Keywords",
description: "Combine multiple pattern matching bindings by moving keywords out of tuples.",
description: "Combine multiple pattern matching bindings by moving keywords out of tuples",
kind: .idiomatic,
nonTriggeringExamples: [
Example("default"),

View File

@ -8,7 +8,7 @@ struct PreferNimbleRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "prefer_nimble",
name: "Prefer Nimble",
description: "Prefer Nimble matchers over XCTAssert functions.",
description: "Prefer Nimble matchers over XCTAssert functions",
kind: .idiomatic,
nonTriggeringExamples: [
Example("expect(foo) == 1"),

View File

@ -8,7 +8,7 @@ struct PrivateOverFilePrivateRule: ConfigurationProviderRule, SwiftSyntaxCorrect
static let description = RuleDescription(
identifier: "private_over_fileprivate",
name: "Private over Fileprivate",
description: "Prefer `private` over `fileprivate` declarations.",
description: "Prefer `private` over `fileprivate` declarations",
kind: .idiomatic,
nonTriggeringExamples: [
Example("extension String {}"),

View File

@ -13,7 +13,7 @@ struct RedundantObjcAttributeRule: SwiftSyntaxRule, SubstitutionCorrectableRule,
static let description = RuleDescription(
identifier: "redundant_objc_attribute",
name: "Redundant @objc Attribute",
description: "Objective-C attribute (@objc) is redundant in declaration.",
description: "Objective-C attribute (@objc) is redundant in declaration",
kind: .idiomatic,
nonTriggeringExamples: RedundantObjcAttributeRuleExamples.nonTriggeringExamples,
triggeringExamples: RedundantObjcAttributeRuleExamples.triggeringExamples,

View File

@ -8,7 +8,7 @@ struct RedundantOptionalInitializationRule: SwiftSyntaxCorrectableRule, Configur
static let description = RuleDescription(
identifier: "redundant_optional_initialization",
name: "Redundant Optional Initialization",
description: "Initializing an optional variable with nil is redundant.",
description: "Initializing an optional variable with nil is redundant",
kind: .idiomatic,
nonTriggeringExamples: [
Example("var myVar: Int?\n"),

View File

@ -9,7 +9,7 @@ struct RedundantSetAccessControlRule: ConfigurationProviderRule, SwiftSyntaxRule
identifier: "redundant_set_access_control",
name: "Redundant Access Control for Setter",
description: "Property setter access level shouldn't be explicit if " +
"it's the same as the variable access level.",
"it's the same as the variable access level",
kind: .idiomatic,
nonTriggeringExamples: [
Example("private(set) public var foo: Int"),

View File

@ -8,7 +8,7 @@ struct RedundantStringEnumValueRule: SwiftSyntaxRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "redundant_string_enum_value",
name: "Redundant String Enum Value",
description: "String enum values can be omitted when they are equal to the enumcase name.",
description: "String enum values can be omitted when they are equal to the enumcase name",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -9,7 +9,7 @@ struct RedundantVoidReturnRule: ConfigurationProviderRule, SubstitutionCorrectab
static let description = RuleDescription(
identifier: "redundant_void_return",
name: "Redundant Void Return",
description: "Returning Void in a function declaration is redundant.",
description: "Returning Void in a function declaration is redundant",
kind: .idiomatic,
nonTriggeringExamples: [
Example("func foo() {}\n"),

View File

@ -8,7 +8,7 @@ struct ReturnValueFromVoidFunctionRule: ConfigurationProviderRule, OptInRule, Sw
static let description = RuleDescription(
identifier: "return_value_from_void_function",
name: "Return Value from Void Function",
description: "Returning values from Void functions should be avoided.",
description: "Returning values from Void functions should be avoided",
kind: .idiomatic,
minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: ReturnValueFromVoidFunctionRuleExamples.nonTriggeringExamples,

View File

@ -8,7 +8,7 @@ struct StaticOperatorRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule
static let description = RuleDescription(
identifier: "static_operator",
name: "Static Operator",
description: "Operators should be declared as static functions, not free functions.",
description: "Operators should be declared as static functions, not free functions",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct StrictFilePrivateRule: OptInRule, ConfigurationProviderRule, SwiftSyntaxR
static let description = RuleDescription(
identifier: "strict_fileprivate",
name: "Strict Fileprivate",
description: "`fileprivate` should be avoided.",
description: "`fileprivate` should be avoided",
kind: .idiomatic,
nonTriggeringExamples: [
Example("extension String {}"),

View File

@ -83,7 +83,7 @@ private enum SugaredType: String {
}
var violationReason: String {
"Shorthand syntactic sugar should be used, i.e. \(sugaredExample) instead of \(desugaredExample)."
"Shorthand syntactic sugar should be used, i.e. \(sugaredExample) instead of \(desugaredExample)"
}
}

View File

@ -9,7 +9,7 @@ struct ToggleBoolRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRule, Op
static var description = RuleDescription(
identifier: "toggle_bool",
name: "Toggle Bool",
description: "Prefer `someBool.toggle()` over `someBool = !someBool`.",
description: "Prefer `someBool.toggle()` over `someBool = !someBool`",
kind: .idiomatic,
nonTriggeringExamples: [
Example("isHidden.toggle()\n"),

View File

@ -8,7 +8,7 @@ struct TrailingSemicolonRule: SwiftSyntaxCorrectableRule, ConfigurationProviderR
static let description = RuleDescription(
identifier: "trailing_semicolon",
name: "Trailing Semicolon",
description: "Lines should not have trailing semicolons.",
description: "Lines should not have trailing semicolons",
kind: .idiomatic,
nonTriggeringExamples: [
Example("let a = 0\n"),

View File

@ -119,9 +119,9 @@ private final class UnavailableConditionRuleVisitor: ViolationsSyntaxVisitor {
private func reason(for check: SyntaxProtocol) -> String {
switch check {
case is AvailabilityConditionSyntax:
return "Use #unavailable instead of #available with an empty body."
return "Use #unavailable instead of #available with an empty body"
case is UnavailabilityConditionSyntax:
return "Use #available instead of #unavailable with an empty body."
return "Use #available instead of #unavailable with an empty body"
default:
queuedFatalError("Unknown availability check type.")
}

View File

@ -8,7 +8,7 @@ struct UnavailableFunctionRule: SwiftSyntaxRule, ConfigurationProviderRule, OptI
static let description = RuleDescription(
identifier: "unavailable_function",
name: "Unavailable Function",
description: "Unimplemented functions should be marked as unavailable.",
description: "Unimplemented functions should be marked as unavailable",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -20,7 +20,7 @@ struct UnneededBreakInSwitchRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "unneeded_break_in_switch",
name: "Unneeded Break in Switch",
description: "Avoid using unneeded break statements.",
description: "Avoid using unneeded break statements",
kind: .idiomatic,
nonTriggeringExamples: [
embedInSwitch("break"),

View File

@ -8,7 +8,7 @@ struct UntypedErrorInCatchRule: OptInRule, ConfigurationProviderRule, SwiftSynta
static let description = RuleDescription(
identifier: "untyped_error_in_catch",
name: "Untyped Error in Catch",
description: "Catch statements should not declare error variables without type casting.",
description: "Catch statements should not declare error variables without type casting",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -53,10 +53,10 @@ private extension UnusedEnumeratedRule {
let reason: String
if firstTokenIsUnderscore {
position = firstElement.positionAfterSkippingLeadingTrivia
reason = "When the index is not used, `.enumerated()` can be removed."
reason = "When the index is not used, `.enumerated()` can be removed"
} else {
position = secondElement.positionAfterSkippingLeadingTrivia
reason = "When the item is not used, `.indices` should be used instead of `.enumerated()`."
reason = "When the item is not used, `.indices` should be used instead of `.enumerated()`"
}
violations.append(ReasonedRuleViolation(position: position, reason: reason))

View File

@ -8,7 +8,7 @@ struct VoidFunctionInTernaryConditionRule: ConfigurationProviderRule, SwiftSynta
static let description = RuleDescription(
identifier: "void_function_in_ternary",
name: "Void Function in Ternary",
description: "Using ternary to call Void functions should be avoided.",
description: "Using ternary to call Void functions should be avoided",
kind: .idiomatic,
minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: [

View File

@ -8,7 +8,7 @@ struct XCTFailMessageRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "xctfail_message",
name: "XCTFail Message",
description: "An XCTFail call should include a description of the assertion.",
description: "An XCTFail call should include a description of the assertion",
kind: .idiomatic,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct XCTSpecificMatcherRule: SwiftSyntaxRule, OptInRule, ConfigurationProvider
static let description = RuleDescription(
identifier: "xct_specific_matcher",
name: "XCTest Specific Matcher",
description: "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`",
description: "Prefer specific XCTest matchers over `XCTAssertEqual` and `XCTAssertNotEqual`.",
kind: .idiomatic,
nonTriggeringExamples: XCTSpecificMatcherRuleExamples.nonTriggeringExamples,
triggeringExamples: XCTSpecificMatcherRuleExamples.triggeringExamples
@ -72,7 +72,7 @@ private extension XCTSpecificMatcherRule {
violations.append(ReasonedRuleViolation(
position: node.positionAfterSkippingLeadingTrivia,
reason: "Prefer the specific matcher '\(suggestedMatcher)' instead."
reason: "Prefer the specific matcher '\(suggestedMatcher)' instead"
))
}
}

View File

@ -17,8 +17,8 @@ struct AccessibilityLabelForImageRule: ASTRule, ConfigurationProviderRule, OptIn
static let description = RuleDescription(
identifier: "accessibility_label_for_image",
name: "Accessibility Label for Image",
description: "All Images that provide context should have an accessibility label. " +
"Purely decorative images can be hidden from accessibility.",
description: "Images that provide context should have an accessibility label or should be explicitly hidden " +
"from accessibility",
kind: .lint,
minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: AccessibilityLabelForImageRuleExamples.nonTriggeringExamples,

View File

@ -15,9 +15,8 @@ struct AccessibilityTraitForButtonRule: ASTRule, ConfigurationProviderRule, OptI
static let description = RuleDescription(
identifier: "accessibility_trait_for_button",
name: "Accessibility Trait for Button",
description: "All views with tap gestures added should include the .isButton " +
"accessibility trait. If a tap opens an external link the .isLink " +
"trait should be used instead.",
description: "All views with tap gestures added should include the .isButton or the .isLink accessibility " +
"traits",
kind: .lint,
minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: AccessibilityTraitForButtonRuleExamples.nonTriggeringExamples,

View File

@ -19,7 +19,7 @@ struct AnyObjectProtocolRule: SwiftSyntaxCorrectableRule, OptInRule, Configurati
static let description = RuleDescription(
identifier: "anyobject_protocol",
name: "AnyObject Protocol",
description: "Prefer using `AnyObject` over `class` for class-only protocols.",
description: "Prefer using `AnyObject` over `class` for class-only protocols",
kind: .lint,
nonTriggeringExamples: [
Example("protocol SomeProtocol {}\n"),

View File

@ -8,7 +8,7 @@ struct ArrayInitRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule {
static let description = RuleDescription(
identifier: "array_init",
name: "Array Init",
description: "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array.",
description: "Prefer using `Array(seq)` over `seq.map { $0 }` to convert a sequence into an Array",
kind: .lint,
nonTriggeringExamples: [
Example("Array(foo)\n"),

View File

@ -8,7 +8,7 @@ struct BalancedXCTestLifecycleRule: SwiftSyntaxRule, OptInRule, ConfigurationPro
static let description = RuleDescription(
identifier: "balanced_xctest_lifecycle",
name: "Balanced XCTest Life Cycle",
description: "Test classes must implement balanced setUp and tearDown methods.",
description: "Test classes must implement balanced setUp and tearDown methods",
kind: .lint,
nonTriggeringExamples: [
Example(#"""

View File

@ -13,7 +13,7 @@ struct CaptureVariableRule: ConfigurationProviderRule, AnalyzerRule, CollectingR
identifier: "capture_variable",
name: "Capture Variable",
description: "Non-constant variables should not be listed in a closure's capture list" +
" to avoid confusion about closures capturing variables at creation time.",
" to avoid confusion about closures capturing variables at creation time",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct ClassDelegateProtocolRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "class_delegate_protocol",
name: "Class Delegate Protocol",
description: "Delegate protocols should be class-only so they can be weakly referenced.",
description: "Delegate protocols should be class-only so they can be weakly referenced",
kind: .lint,
nonTriggeringExamples: [
Example("protocol FooDelegate: class {}\n"),

View File

@ -10,7 +10,7 @@ struct CommentSpacingRule: SourceKitFreeRule, ConfigurationProviderRule, Substit
static let description = RuleDescription(
identifier: "comment_spacing",
name: "Comment Spacing",
description: "Prefer at least one space after slashes for comments.",
description: "Prefer at least one space after slashes for comments",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,10 +8,8 @@ struct CompilerProtocolInitRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "compiler_protocol_init",
name: "Compiler Protocol Init",
description: Self.violationReason(
protocolName: "such as `ExpressibleByArrayLiteral`",
isPlural: true
),
description: "The initializers declared in compiler protocols such as `ExpressibleByArrayLiteral` " +
"shouldn't be called directly.",
kind: .lint,
nonTriggeringExamples: [
Example("let set: Set<Int> = [1, 2]\n"),
@ -25,11 +23,6 @@ struct CompilerProtocolInitRule: SwiftSyntaxRule, ConfigurationProviderRule {
]
)
private static func violationReason(protocolName: String, isPlural: Bool = false) -> String {
return "The initializers declared in compiler protocol\(isPlural ? "s" : "") \(protocolName) " +
"shouldn't be called directly."
}
func makeVisitor(file: SwiftLintFile) -> ViolationsSyntaxVisitor {
Visitor(viewMode: .sourceAccurate)
}
@ -60,7 +53,8 @@ private extension CompilerProtocolInitRule {
violations.append(ReasonedRuleViolation(
position: node.positionAfterSkippingLeadingTrivia,
reason: violationReason(protocolName: compilerProtocol.protocolName)
reason: "Initializers declared in compiler protocol \(compilerProtocol.protocolName) " +
"shouldn't be called directly"
))
return
}

View File

@ -134,7 +134,7 @@ private extension DeploymentTargetRule {
return """
Availability \(violationType.displayString) is using a version (\(versionString)) that is \
satisfied by the deployment target (\(minVersion.stringValue)) for platform \(platform.rawValue).
satisfied by the deployment target (\(minVersion.stringValue)) for platform \(platform.rawValue)
"""
}
}

View File

@ -9,7 +9,7 @@ struct DiscardedNotificationCenterObserverRule: SwiftSyntaxRule, ConfigurationPr
identifier: "discarded_notification_center_observer",
name: "Discarded Notification Center Observer",
description: "When registering for a notification using a block, the opaque observer that is " +
"returned should be stored so it can be removed later.",
"returned should be stored so it can be removed later",
kind: .lint,
nonTriggeringExamples: [
Example("let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { }\n"),

View File

@ -8,7 +8,7 @@ struct DiscouragedDirectInitRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "discouraged_direct_init",
name: "Discouraged Direct Initialization",
description: "Discouraged direct initialization of types that can be harmful.",
description: "Discouraged direct initialization of types that can be harmful",
kind: .lint,
nonTriggeringExamples: [
Example("let foo = UIDevice.current"),

View File

@ -8,7 +8,7 @@ struct DuplicateEnumCasesRule: ConfigurationProviderRule, SwiftSyntaxRule {
static let description = RuleDescription(
identifier: "duplicate_enum_cases",
name: "Duplicate Enum Cases",
description: "Enum can't contain multiple cases with the same name.",
description: "Enum can't contain multiple cases with the same name",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct DuplicatedKeyInDictionaryLiteralRule: SwiftSyntaxRule, ConfigurationProvi
static var description = RuleDescription(
identifier: "duplicated_key_in_dictionary_literal",
name: "Duplicated Key in Dictionary Literal",
description: "Dictionary literals with duplicated keys will crash in runtime.",
description: "Dictionary literals with duplicated keys will crash in runtime",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct DynamicInlineRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "dynamic_inline",
name: "Dynamic Inline",
description: "Avoid using 'dynamic' and '@inline(__always)' together.",
description: "Avoid using 'dynamic' and '@inline(__always)' together",
kind: .lint,
nonTriggeringExamples: [
Example("class C {\ndynamic func f() {}}"),

View File

@ -8,7 +8,7 @@ struct EmptyXCTestMethodRule: OptInRule, ConfigurationProviderRule, SwiftSyntaxR
static let description = RuleDescription(
identifier: "empty_xctest_method",
name: "Empty XCTest Method",
description: "Empty XCTest method should be avoided.",
description: "Empty XCTest method should be avoided",
kind: .lint,
nonTriggeringExamples: EmptyXCTestMethodRuleExamples.nonTriggeringExamples,
triggeringExamples: EmptyXCTestMethodRuleExamples.triggeringExamples

View File

@ -10,11 +10,11 @@ struct ExpiringTodoRule: ConfigurationProviderRule, OptInRule {
var reason: String {
switch self {
case .approachingExpiry:
return "TODO/FIXME is approaching its expiry and should be resolved soon."
return "TODO/FIXME is approaching its expiry and should be resolved soon"
case .expired:
return "TODO/FIXME has expired and must be resolved."
return "TODO/FIXME has expired and must be resolved"
case .badFormatting:
return "Expiring TODO/FIXME is incorrectly formatted."
return "Expiring TODO/FIXME is incorrectly formatted"
}
}
}

View File

@ -8,7 +8,7 @@ struct IBInspectableInExtensionRule: SwiftSyntaxRule, ConfigurationProviderRule,
static let description = RuleDescription(
identifier: "ibinspectable_in_extension",
name: "IBInspectable in Extension",
description: "Extensions shouldn't add @IBInspectable properties.",
description: "Extensions shouldn't add @IBInspectable properties",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -10,7 +10,7 @@ struct IdenticalOperandsRule: ConfigurationProviderRule, SwiftSyntaxRule, OptInR
static let description = RuleDescription(
identifier: "identical_operands",
name: "Identical Operands",
description: "Comparing two identical operands is likely a mistake.",
description: "Comparing two identical operands is likely a mistake",
kind: .lint,
nonTriggeringExamples: operators.flatMap { operation in
[

View File

@ -20,7 +20,7 @@ struct InertDeferRule: ConfigurationProviderRule, SwiftSyntaxRule, OptInRule {
static let description = RuleDescription(
identifier: "inert_defer",
name: "Inert Defer",
description: "If defer is at the end of its parent scope, it will be executed right where it is anyway.",
description: "If defer is at the end of its parent scope, it will be executed right where it is anyway",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -9,7 +9,7 @@ struct LocalDocCommentRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRul
static let description = RuleDescription(
identifier: "local_doc_comment",
name: "Local Doc Comment",
description: "Doc comments shouldn't be used in local scopes. Use regular comments.",
description: "Prefer regular comments over doc comments in local scopes",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -132,7 +132,7 @@ struct MissingDocsRule: OptInRule, ConfigurationProviderRule {
StyleViolation(ruleDescription: Self.description,
severity: configuration.parameters.first { $0.value == acl }?.severity ?? .warning,
location: Location(file: file, byteOffset: offset),
reason: "\(acl.description) declarations should be documented.")
reason: "\(acl.description) declarations should be documented")
}
}
}

View File

@ -9,7 +9,7 @@ struct NSLocalizedStringKeyRule: SwiftSyntaxRule, OptInRule, ConfigurationProvid
identifier: "nslocalizedstring_key",
name: "NSLocalizedString Key",
description: "Static strings should be used as key/comment" +
" in NSLocalizedString in order for genstrings to work.",
" in NSLocalizedString in order for genstrings to work",
kind: .lint,
nonTriggeringExamples: [
Example("NSLocalizedString(\"key\", comment: \"\")"),

View File

@ -8,7 +8,7 @@ struct NSLocalizedStringRequireBundleRule: SwiftSyntaxRule, OptInRule, Configura
static let description = RuleDescription(
identifier: "nslocalizedstring_require_bundle",
name: "NSLocalizedString Require Bundle",
description: "Calls to NSLocalizedString should specify the bundle which contains the strings file.",
description: "Calls to NSLocalizedString should specify the bundle which contains the strings file",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -10,7 +10,7 @@ struct NSNumberInitAsFunctionReferenceRule: SwiftSyntaxRule, ConfigurationProvid
identifier: "ns_number_init_as_function_reference",
name: "NSNumber Init as Function Reference",
description: "Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous " +
"as it can cause the wrong initializer to be used, causing crashes. Use `.init(value:)` instead.",
"as it can cause the wrong initializer to be used, causing crashes; use `.init(value:)` instead",
kind: .lint,
nonTriggeringExamples: [
Example("[0, 0.2].map(NSNumber.init(value:))"),

View File

@ -8,7 +8,7 @@ struct NSObjectPreferIsEqualRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "nsobject_prefer_isequal",
name: "NSObject Prefer isEqual",
description: "NSObject subclasses should implement isEqual instead of ==.",
description: "NSObject subclasses should implement isEqual instead of ==",
kind: .lint,
nonTriggeringExamples: NSObjectPreferIsEqualRuleExamples.nonTriggeringExamples,
triggeringExamples: NSObjectPreferIsEqualRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct NotificationCenterDetachmentRule: SwiftSyntaxRule, ConfigurationProviderR
static let description = RuleDescription(
identifier: "notification_center_detachment",
name: "Notification Center Detachment",
description: "An object should only remove itself as an observer in `deinit`.",
description: "An object should only remove itself as an observer in `deinit`",
kind: .lint,
nonTriggeringExamples: NotificationCenterDetachmentRuleExamples.nonTriggeringExamples,
triggeringExamples: NotificationCenterDetachmentRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct OrphanedDocCommentRule: SourceKitFreeRule, ConfigurationProviderRule {
static let description = RuleDescription(
identifier: "orphaned_doc_comment",
name: "Orphaned Doc Comment",
description: "A doc comment should be attached to a declaration.",
description: "A doc comment should be attached to a declaration",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct OverriddenSuperCallRule: ConfigurationProviderRule, SwiftSyntaxRule, OptI
static let description = RuleDescription(
identifier: "overridden_super_call",
name: "Overridden Method Calls Super",
description: "Some overridden methods should always call super",
description: "Some overridden methods should always call super.",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct OverrideInExtensionRule: ConfigurationProviderRule, OptInRule, SwiftSynta
static let description = RuleDescription(
identifier: "override_in_extension",
name: "Override in Extension",
description: "Extensions shouldn't override declarations.",
description: "Extensions shouldn't override declarations",
kind: .lint,
nonTriggeringExamples: [
Example("extension Person {\n var age: Int { return 42 }\n}\n"),

View File

@ -10,7 +10,7 @@ struct PeriodSpacingRule: SourceKitFreeRule, ConfigurationProviderRule, OptInRul
static let description = RuleDescription(
identifier: "period_spacing",
name: "Period Spacing",
description: "Periods should not be followed by more than one space.",
description: "Periods should not be followed by more than one space",
kind: .style,
nonTriggeringExamples: [
Example("let pi = 3.2"),

View File

@ -8,7 +8,7 @@ struct PrivateActionRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "private_action",
name: "Private Actions",
description: "IBActions should be private.",
description: "IBActions should be private",
kind: .lint,
nonTriggeringExamples: [
Example("class Foo {\n\t@IBAction private func barButtonTapped(_ sender: UIButton) {}\n}\n"),

View File

@ -8,7 +8,7 @@ struct PrivateOutletRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "private_outlet",
name: "Private Outlets",
description: "IBOutlets should be private to avoid leaking UIKit to higher layers.",
description: "IBOutlets should be private to avoid leaking UIKit to higher layers",
kind: .lint,
nonTriggeringExamples: [
Example("class Foo {\n @IBOutlet private var label: UILabel?\n}\n"),

View File

@ -8,7 +8,7 @@ struct PrivateSubjectRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "private_subject",
name: "Private Combine Subject",
description: "Combine Subject should be private.",
description: "Combine Subject should be private",
kind: .lint,
nonTriggeringExamples: PrivateSubjectRuleExamples.nonTriggeringExamples,
triggeringExamples: PrivateSubjectRuleExamples.triggeringExamples

View File

@ -18,7 +18,7 @@ struct PrivateUnitTestRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRul
static let description = RuleDescription(
identifier: "private_unit_test",
name: "Private Unit Test",
description: "Unit tests marked private are silently skipped.",
description: "Unit tests marked private are silently skipped",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct ProhibitedInterfaceBuilderRule: ConfigurationProviderRule, SwiftSyntaxRul
static let description = RuleDescription(
identifier: "prohibited_interface_builder",
name: "Prohibited Interface Builder",
description: "Creating views using Interface Builder should be avoided.",
description: "Creating views using Interface Builder should be avoided",
kind: .lint,
nonTriggeringExamples: [
wrapExample("var label: UILabel!"),

View File

@ -8,7 +8,7 @@ struct ProhibitedSuperRule: ConfigurationProviderRule, SwiftSyntaxRule, OptInRul
static let description = RuleDescription(
identifier: "prohibited_super_call",
name: "Prohibited Calls to Super",
description: "Some methods should not call super",
description: "Some methods should not call super.",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -56,7 +56,7 @@ struct QuickDiscouragedCallRule: OptInRule, ConfigurationProviderRule {
StyleViolation(ruleDescription: Self.description,
severity: configuration.severity,
location: Location(file: file, byteOffset: $0),
reason: "Discouraged call inside a '\(name)' block.")
reason: "Discouraged call inside a '\(name)' block")
}
}

View File

@ -8,7 +8,7 @@ struct QuickDiscouragedFocusedTestRule: OptInRule, ConfigurationProviderRule, Sw
static let description = RuleDescription(
identifier: "quick_discouraged_focused_test",
name: "Quick Discouraged Focused Test",
description: "Discouraged focused test. Other tests won't run while this one is focused.",
description: "Non-focused tests won't run as long as this test is focused",
kind: .lint,
nonTriggeringExamples: QuickDiscouragedFocusedTestRuleExamples.nonTriggeringExamples,
triggeringExamples: QuickDiscouragedFocusedTestRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct QuickDiscouragedPendingTestRule: OptInRule, ConfigurationProviderRule, Sw
static let description = RuleDescription(
identifier: "quick_discouraged_pending_test",
name: "Quick Discouraged Pending Test",
description: "Discouraged pending test. This test won't run while it's marked as pending.",
description: "This test won't run as long as it's marked pending",
kind: .lint,
nonTriggeringExamples: QuickDiscouragedPendingTestRuleExamples.nonTriggeringExamples,
triggeringExamples: QuickDiscouragedPendingTestRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct RawValueForCamelCasedCodableEnumRule: SwiftSyntaxRule, OptInRule, Configu
static let description = RuleDescription(
identifier: "raw_value_for_camel_cased_codable_enum",
name: "Raw Value for Camel Cased Codable Enum",
description: "Camel cased cases of Codable String enums should have raw value.",
description: "Camel cased cases of Codable String enums should have raw value",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -12,7 +12,7 @@ struct RequiredDeinitRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription(
identifier: "required_deinit",
name: "Required Deinit",
description: "Classes should have an explicit deinit method.",
description: "Classes should have an explicit deinit method",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,8 +8,8 @@ struct SelfInPropertyInitializationRule: ConfigurationProviderRule, SwiftSyntaxR
static let description = RuleDescription(
identifier: "self_in_property_initialization",
name: "Self in Property Initialization",
description: "`self` refers to the unapplied `NSObject.self()` method, which is likely not expected. " +
"Make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`.",
description: "`self` refers to the unapplied `NSObject.self()` method, which is likely not expected; " +
"make the variable `lazy` to be able to refer to the current instance or use `ClassName.self`",
kind: .lint,
nonTriggeringExamples: [
Example("""

View File

@ -8,7 +8,7 @@ struct StrongIBOutletRule: ConfigurationProviderRule, SwiftSyntaxCorrectableRule
static let description = RuleDescription(
identifier: "strong_iboutlet",
name: "Strong IBOutlet",
description: "@IBOutlets shouldn't be declared as weak.",
description: "@IBOutlets shouldn't be declared as weak",
kind: .lint,
nonTriggeringExamples: [
wrapExample("@IBOutlet var label: UILabel?"),

Some files were not shown because too many files have changed in this diff Show More