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: case .unused:
return nil return nil
case .missing(let module): 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( static let description = RuleDescription(
identifier: "block_based_kvo", identifier: "block_based_kvo",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(#""" Example(#"""

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ struct DiscouragedOptionalBooleanRule: OptInRule, ConfigurationProviderRule, Swi
static let description = RuleDescription( static let description = RuleDescription(
identifier: "discouraged_optional_boolean", identifier: "discouraged_optional_boolean",
name: "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, kind: .idiomatic,
nonTriggeringExamples: DiscouragedOptionalBooleanRuleExamples.nonTriggeringExamples, nonTriggeringExamples: DiscouragedOptionalBooleanRuleExamples.nonTriggeringExamples,
triggeringExamples: DiscouragedOptionalBooleanRuleExamples.triggeringExamples triggeringExamples: DiscouragedOptionalBooleanRuleExamples.triggeringExamples

View File

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

View File

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

View File

@ -11,7 +11,7 @@ struct ExplicitACLRule: OptInRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "explicit_acl", identifier: "explicit_acl",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("internal enum A {}\n"), Example("internal enum A {}\n"),

View File

@ -8,7 +8,7 @@ struct ExplicitEnumRawValueRule: SwiftSyntaxRule, OptInRule, ConfigurationProvid
static let description = RuleDescription( static let description = RuleDescription(
identifier: "explicit_enum_raw_value", identifier: "explicit_enum_raw_value",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

@ -8,7 +8,7 @@ struct ExplicitTopLevelACLRule: SwiftSyntaxRule, OptInRule, ConfigurationProvide
static let description = RuleDescription( static let description = RuleDescription(
identifier: "explicit_top_level_acl", identifier: "explicit_top_level_acl",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("internal enum A {}\n"), Example("internal enum A {}\n"),

View File

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

View File

@ -8,7 +8,7 @@ struct FatalErrorMessageRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInR
static let description = RuleDescription( static let description = RuleDescription(
identifier: "fatal_error_message", identifier: "fatal_error_message",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -12,7 +12,7 @@ struct FileNameNoSpaceRule: ConfigurationProviderRule, OptInRule, SourceKitFreeR
static let description = RuleDescription( static let description = RuleDescription(
identifier: "file_name_no_space", identifier: "file_name_no_space",
name: "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 kind: .idiomatic
) )

View File

@ -14,7 +14,7 @@ struct FileNameRule: ConfigurationProviderRule, OptInRule, SourceKitFreeRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "file_name", identifier: "file_name",
name: "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 kind: .idiomatic
) )

View File

@ -8,7 +8,7 @@ struct ForWhereRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "for_where", identifier: "for_where",
name: "Prefer 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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ struct FunctionDefaultParameterAtEndRule: SwiftSyntaxRule, ConfigurationProvider
static let description = RuleDescription( static let description = RuleDescription(
identifier: "function_default_parameter_at_end", identifier: "function_default_parameter_at_end",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("func foo(baz: String, bar: Int = 0) {}"), Example("func foo(baz: String, bar: Int = 0) {}"),

View File

@ -11,7 +11,7 @@ struct ImplicitlyUnwrappedOptionalRule: SwiftSyntaxRule, ConfigurationProviderRu
static let description = RuleDescription( static let description = RuleDescription(
identifier: "implicitly_unwrapped_optional", identifier: "implicitly_unwrapped_optional",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("@IBOutlet private var label: UILabel!"), Example("@IBOutlet private var label: UILabel!"),

View File

@ -8,7 +8,7 @@ struct IsDisjointRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "is_disjoint", identifier: "is_disjoint",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet)"), Example("_ = Set(syntaxKinds).isDisjoint(with: commentAndStringKindsSet)"),

View File

@ -8,7 +8,7 @@ struct JoinedDefaultParameterRule: SwiftSyntaxCorrectableRule, ConfigurationProv
static let description = RuleDescription( static let description = RuleDescription(
identifier: "joined_default_parameter", identifier: "joined_default_parameter",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("let foo = bar.joined()"), Example("let foo = bar.joined()"),

View File

@ -9,7 +9,7 @@ struct LegacyConstantRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "legacy_constant", identifier: "legacy_constant",
name: "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, kind: .idiomatic,
nonTriggeringExamples: LegacyConstantRuleExamples.nonTriggeringExamples, nonTriggeringExamples: LegacyConstantRuleExamples.nonTriggeringExamples,
triggeringExamples: LegacyConstantRuleExamples.triggeringExamples, triggeringExamples: LegacyConstantRuleExamples.triggeringExamples,

View File

@ -8,7 +8,7 @@ struct LegacyConstructorRule: SwiftSyntaxCorrectableRule, ConfigurationProviderR
static let description = RuleDescription( static let description = RuleDescription(
identifier: "legacy_constructor", identifier: "legacy_constructor",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("CGPoint(x: 10, y: 10)"), Example("CGPoint(x: 10, y: 10)"),

View File

@ -8,7 +8,7 @@ struct LegacyMultipleRule: OptInRule, ConfigurationProviderRule, SwiftSyntaxRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "legacy_multiple", identifier: "legacy_multiple",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("cell.contentView.backgroundColor = indexPath.row.isMultiple(of: 2) ? .gray : .white"), 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( static var description = RuleDescription(
identifier: "legacy_random", identifier: "legacy_random",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("Int.random(in: 0..<10)\n"), Example("Int.random(in: 0..<10)\n"),

View File

@ -9,7 +9,7 @@ struct NimbleOperatorRule: ConfigurationProviderRule, OptInRule, CorrectableRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "nimble_operator", identifier: "nimble_operator",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("expect(seagull.squawk) != \"Hi!\"\n"), Example("expect(seagull.squawk) != \"Hi!\"\n"),

View File

@ -8,7 +8,7 @@ struct NoFallthroughOnlyRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "no_fallthrough_only", identifier: "no_fallthrough_only",
name: "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, kind: .idiomatic,
nonTriggeringExamples: NoFallthroughOnlyRuleExamples.nonTriggeringExamples, nonTriggeringExamples: NoFallthroughOnlyRuleExamples.nonTriggeringExamples,
triggeringExamples: NoFallthroughOnlyRuleExamples.triggeringExamples triggeringExamples: NoFallthroughOnlyRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct NoGroupingExtensionRule: OptInRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "no_grouping_extension", identifier: "no_grouping_extension",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("protocol Food {}\nextension Food {}\n"), Example("protocol Food {}\nextension Food {}\n"),

View File

@ -8,7 +8,7 @@ struct NoMagicNumbersRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "no_magic_numbers", identifier: "no_magic_numbers",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("var foo = 123"), Example("var foo = 123"),

View File

@ -8,7 +8,7 @@ struct ObjectLiteralRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "object_literal", identifier: "object_literal",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("let image = #imageLiteral(resourceName: \"image.jpg\")"), Example("let image = #imageLiteral(resourceName: \"image.jpg\")"),

View File

@ -8,7 +8,7 @@ struct PatternMatchingKeywordsRule: SwiftSyntaxRule, ConfigurationProviderRule,
static let description = RuleDescription( static let description = RuleDescription(
identifier: "pattern_matching_keywords", identifier: "pattern_matching_keywords",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("default"), Example("default"),

View File

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

View File

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

View File

@ -13,7 +13,7 @@ struct RedundantObjcAttributeRule: SwiftSyntaxRule, SubstitutionCorrectableRule,
static let description = RuleDescription( static let description = RuleDescription(
identifier: "redundant_objc_attribute", identifier: "redundant_objc_attribute",
name: "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, kind: .idiomatic,
nonTriggeringExamples: RedundantObjcAttributeRuleExamples.nonTriggeringExamples, nonTriggeringExamples: RedundantObjcAttributeRuleExamples.nonTriggeringExamples,
triggeringExamples: RedundantObjcAttributeRuleExamples.triggeringExamples, triggeringExamples: RedundantObjcAttributeRuleExamples.triggeringExamples,

View File

@ -8,7 +8,7 @@ struct RedundantOptionalInitializationRule: SwiftSyntaxCorrectableRule, Configur
static let description = RuleDescription( static let description = RuleDescription(
identifier: "redundant_optional_initialization", identifier: "redundant_optional_initialization",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("var myVar: Int?\n"), Example("var myVar: Int?\n"),

View File

@ -9,7 +9,7 @@ struct RedundantSetAccessControlRule: ConfigurationProviderRule, SwiftSyntaxRule
identifier: "redundant_set_access_control", identifier: "redundant_set_access_control",
name: "Redundant Access Control for Setter", name: "Redundant Access Control for Setter",
description: "Property setter access level shouldn't be explicit if " + 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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("private(set) public var foo: Int"), Example("private(set) public var foo: Int"),

View File

@ -8,7 +8,7 @@ struct RedundantStringEnumValueRule: SwiftSyntaxRule, ConfigurationProviderRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "redundant_string_enum_value", identifier: "redundant_string_enum_value",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -9,7 +9,7 @@ struct RedundantVoidReturnRule: ConfigurationProviderRule, SubstitutionCorrectab
static let description = RuleDescription( static let description = RuleDescription(
identifier: "redundant_void_return", identifier: "redundant_void_return",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("func foo() {}\n"), Example("func foo() {}\n"),

View File

@ -8,7 +8,7 @@ struct ReturnValueFromVoidFunctionRule: ConfigurationProviderRule, OptInRule, Sw
static let description = RuleDescription( static let description = RuleDescription(
identifier: "return_value_from_void_function", identifier: "return_value_from_void_function",
name: "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, kind: .idiomatic,
minSwiftVersion: .fiveDotOne, minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: ReturnValueFromVoidFunctionRuleExamples.nonTriggeringExamples, nonTriggeringExamples: ReturnValueFromVoidFunctionRuleExamples.nonTriggeringExamples,

View File

@ -8,7 +8,7 @@ struct StaticOperatorRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "static_operator", identifier: "static_operator",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

@ -83,7 +83,7 @@ private enum SugaredType: String {
} }
var violationReason: 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( static var description = RuleDescription(
identifier: "toggle_bool", identifier: "toggle_bool",
name: "Toggle Bool", name: "Toggle Bool",
description: "Prefer `someBool.toggle()` over `someBool = !someBool`.", description: "Prefer `someBool.toggle()` over `someBool = !someBool`",
kind: .idiomatic, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("isHidden.toggle()\n"), Example("isHidden.toggle()\n"),

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ struct UntypedErrorInCatchRule: OptInRule, ConfigurationProviderRule, SwiftSynta
static let description = RuleDescription( static let description = RuleDescription(
identifier: "untyped_error_in_catch", identifier: "untyped_error_in_catch",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -53,10 +53,10 @@ private extension UnusedEnumeratedRule {
let reason: String let reason: String
if firstTokenIsUnderscore { if firstTokenIsUnderscore {
position = firstElement.positionAfterSkippingLeadingTrivia 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 { } else {
position = secondElement.positionAfterSkippingLeadingTrivia 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)) violations.append(ReasonedRuleViolation(position: position, reason: reason))

View File

@ -8,7 +8,7 @@ struct VoidFunctionInTernaryConditionRule: ConfigurationProviderRule, SwiftSynta
static let description = RuleDescription( static let description = RuleDescription(
identifier: "void_function_in_ternary", identifier: "void_function_in_ternary",
name: "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, kind: .idiomatic,
minSwiftVersion: .fiveDotOne, minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: [ nonTriggeringExamples: [

View File

@ -8,7 +8,7 @@ struct XCTFailMessageRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "xctfail_message", identifier: "xctfail_message",
name: "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, kind: .idiomatic,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -8,7 +8,7 @@ struct XCTSpecificMatcherRule: SwiftSyntaxRule, OptInRule, ConfigurationProvider
static let description = RuleDescription( static let description = RuleDescription(
identifier: "xct_specific_matcher", identifier: "xct_specific_matcher",
name: "XCTest 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, kind: .idiomatic,
nonTriggeringExamples: XCTSpecificMatcherRuleExamples.nonTriggeringExamples, nonTriggeringExamples: XCTSpecificMatcherRuleExamples.nonTriggeringExamples,
triggeringExamples: XCTSpecificMatcherRuleExamples.triggeringExamples triggeringExamples: XCTSpecificMatcherRuleExamples.triggeringExamples
@ -72,7 +72,7 @@ private extension XCTSpecificMatcherRule {
violations.append(ReasonedRuleViolation( violations.append(ReasonedRuleViolation(
position: node.positionAfterSkippingLeadingTrivia, 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( static let description = RuleDescription(
identifier: "accessibility_label_for_image", identifier: "accessibility_label_for_image",
name: "Accessibility Label for Image", name: "Accessibility Label for Image",
description: "All Images that provide context should have an accessibility label. " + description: "Images that provide context should have an accessibility label or should be explicitly hidden " +
"Purely decorative images can be hidden from accessibility.", "from accessibility",
kind: .lint, kind: .lint,
minSwiftVersion: .fiveDotOne, minSwiftVersion: .fiveDotOne,
nonTriggeringExamples: AccessibilityLabelForImageRuleExamples.nonTriggeringExamples, nonTriggeringExamples: AccessibilityLabelForImageRuleExamples.nonTriggeringExamples,

View File

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

View File

@ -19,7 +19,7 @@ struct AnyObjectProtocolRule: SwiftSyntaxCorrectableRule, OptInRule, Configurati
static let description = RuleDescription( static let description = RuleDescription(
identifier: "anyobject_protocol", identifier: "anyobject_protocol",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("protocol SomeProtocol {}\n"), Example("protocol SomeProtocol {}\n"),

View File

@ -8,7 +8,7 @@ struct ArrayInitRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "array_init", identifier: "array_init",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("Array(foo)\n"), Example("Array(foo)\n"),

View File

@ -8,7 +8,7 @@ struct BalancedXCTestLifecycleRule: SwiftSyntaxRule, OptInRule, ConfigurationPro
static let description = RuleDescription( static let description = RuleDescription(
identifier: "balanced_xctest_lifecycle", identifier: "balanced_xctest_lifecycle",
name: "Balanced XCTest Life Cycle", 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(#""" Example(#"""

View File

@ -13,7 +13,7 @@ struct CaptureVariableRule: ConfigurationProviderRule, AnalyzerRule, CollectingR
identifier: "capture_variable", identifier: "capture_variable",
name: "Capture Variable", name: "Capture Variable",
description: "Non-constant variables should not be listed in a closure's capture list" + 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -8,7 +8,7 @@ struct ClassDelegateProtocolRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "class_delegate_protocol", identifier: "class_delegate_protocol",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("protocol FooDelegate: class {}\n"), Example("protocol FooDelegate: class {}\n"),

View File

@ -10,7 +10,7 @@ struct CommentSpacingRule: SourceKitFreeRule, ConfigurationProviderRule, Substit
static let description = RuleDescription( static let description = RuleDescription(
identifier: "comment_spacing", identifier: "comment_spacing",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

@ -134,7 +134,7 @@ private extension DeploymentTargetRule {
return """ return """
Availability \(violationType.displayString) is using a version (\(versionString)) that is \ 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", identifier: "discarded_notification_center_observer",
name: "Discarded Notification Center Observer", name: "Discarded Notification Center Observer",
description: "When registering for a notification using a block, the opaque observer that is " + 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("let foo = nc.addObserver(forName: .NSSystemTimeZoneDidChange, object: nil, queue: nil) { }\n"), 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( static let description = RuleDescription(
identifier: "discouraged_direct_init", identifier: "discouraged_direct_init",
name: "Discouraged Direct Initialization", 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("let foo = UIDevice.current"), Example("let foo = UIDevice.current"),

View File

@ -8,7 +8,7 @@ struct DuplicateEnumCasesRule: ConfigurationProviderRule, SwiftSyntaxRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "duplicate_enum_cases", identifier: "duplicate_enum_cases",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -8,7 +8,7 @@ struct DuplicatedKeyInDictionaryLiteralRule: SwiftSyntaxRule, ConfigurationProvi
static var description = RuleDescription( static var description = RuleDescription(
identifier: "duplicated_key_in_dictionary_literal", identifier: "duplicated_key_in_dictionary_literal",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

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

View File

@ -10,11 +10,11 @@ struct ExpiringTodoRule: ConfigurationProviderRule, OptInRule {
var reason: String { var reason: String {
switch self { switch self {
case .approachingExpiry: 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: case .expired:
return "TODO/FIXME has expired and must be resolved." return "TODO/FIXME has expired and must be resolved"
case .badFormatting: 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( static let description = RuleDescription(
identifier: "ibinspectable_in_extension", identifier: "ibinspectable_in_extension",
name: "IBInspectable in Extension", name: "IBInspectable in Extension",
description: "Extensions shouldn't add @IBInspectable properties.", description: "Extensions shouldn't add @IBInspectable properties",
kind: .lint, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -10,7 +10,7 @@ struct IdenticalOperandsRule: ConfigurationProviderRule, SwiftSyntaxRule, OptInR
static let description = RuleDescription( static let description = RuleDescription(
identifier: "identical_operands", identifier: "identical_operands",
name: "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, kind: .lint,
nonTriggeringExamples: operators.flatMap { operation in nonTriggeringExamples: operators.flatMap { operation in
[ [

View File

@ -20,7 +20,7 @@ struct InertDeferRule: ConfigurationProviderRule, SwiftSyntaxRule, OptInRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "inert_defer", identifier: "inert_defer",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -9,7 +9,7 @@ struct LocalDocCommentRule: SwiftSyntaxRule, ConfigurationProviderRule, OptInRul
static let description = RuleDescription( static let description = RuleDescription(
identifier: "local_doc_comment", identifier: "local_doc_comment",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -132,7 +132,7 @@ struct MissingDocsRule: OptInRule, ConfigurationProviderRule {
StyleViolation(ruleDescription: Self.description, StyleViolation(ruleDescription: Self.description,
severity: configuration.parameters.first { $0.value == acl }?.severity ?? .warning, severity: configuration.parameters.first { $0.value == acl }?.severity ?? .warning,
location: Location(file: file, byteOffset: offset), 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", identifier: "nslocalizedstring_key",
name: "NSLocalizedString Key", name: "NSLocalizedString Key",
description: "Static strings should be used as key/comment" + 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("NSLocalizedString(\"key\", comment: \"\")"), Example("NSLocalizedString(\"key\", comment: \"\")"),

View File

@ -8,7 +8,7 @@ struct NSLocalizedStringRequireBundleRule: SwiftSyntaxRule, OptInRule, Configura
static let description = RuleDescription( static let description = RuleDescription(
identifier: "nslocalizedstring_require_bundle", identifier: "nslocalizedstring_require_bundle",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -10,7 +10,7 @@ struct NSNumberInitAsFunctionReferenceRule: SwiftSyntaxRule, ConfigurationProvid
identifier: "ns_number_init_as_function_reference", identifier: "ns_number_init_as_function_reference",
name: "NSNumber Init as Function Reference", name: "NSNumber Init as Function Reference",
description: "Passing `NSNumber.init` or `NSDecimalNumber.init` as a function reference is dangerous " + 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("[0, 0.2].map(NSNumber.init(value:))"), Example("[0, 0.2].map(NSNumber.init(value:))"),

View File

@ -8,7 +8,7 @@ struct NSObjectPreferIsEqualRule: SwiftSyntaxRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "nsobject_prefer_isequal", identifier: "nsobject_prefer_isequal",
name: "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, kind: .lint,
nonTriggeringExamples: NSObjectPreferIsEqualRuleExamples.nonTriggeringExamples, nonTriggeringExamples: NSObjectPreferIsEqualRuleExamples.nonTriggeringExamples,
triggeringExamples: NSObjectPreferIsEqualRuleExamples.triggeringExamples triggeringExamples: NSObjectPreferIsEqualRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct NotificationCenterDetachmentRule: SwiftSyntaxRule, ConfigurationProviderR
static let description = RuleDescription( static let description = RuleDescription(
identifier: "notification_center_detachment", identifier: "notification_center_detachment",
name: "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, kind: .lint,
nonTriggeringExamples: NotificationCenterDetachmentRuleExamples.nonTriggeringExamples, nonTriggeringExamples: NotificationCenterDetachmentRuleExamples.nonTriggeringExamples,
triggeringExamples: NotificationCenterDetachmentRuleExamples.triggeringExamples triggeringExamples: NotificationCenterDetachmentRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct OrphanedDocCommentRule: SourceKitFreeRule, ConfigurationProviderRule {
static let description = RuleDescription( static let description = RuleDescription(
identifier: "orphaned_doc_comment", identifier: "orphaned_doc_comment",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

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

View File

@ -8,7 +8,7 @@ struct PrivateActionRule: SwiftSyntaxRule, OptInRule, ConfigurationProviderRule
static let description = RuleDescription( static let description = RuleDescription(
identifier: "private_action", identifier: "private_action",
name: "Private Actions", name: "Private Actions",
description: "IBActions should be private.", description: "IBActions should be private",
kind: .lint, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("class Foo {\n\t@IBAction private func barButtonTapped(_ sender: UIButton) {}\n}\n"), 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( static let description = RuleDescription(
identifier: "private_outlet", identifier: "private_outlet",
name: "Private Outlets", 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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example("class Foo {\n @IBOutlet private var label: UILabel?\n}\n"), 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( static let description = RuleDescription(
identifier: "private_subject", identifier: "private_subject",
name: "Private Combine Subject", name: "Private Combine Subject",
description: "Combine Subject should be private.", description: "Combine Subject should be private",
kind: .lint, kind: .lint,
nonTriggeringExamples: PrivateSubjectRuleExamples.nonTriggeringExamples, nonTriggeringExamples: PrivateSubjectRuleExamples.nonTriggeringExamples,
triggeringExamples: PrivateSubjectRuleExamples.triggeringExamples triggeringExamples: PrivateSubjectRuleExamples.triggeringExamples

View File

@ -18,7 +18,7 @@ struct PrivateUnitTestRule: SwiftSyntaxCorrectableRule, ConfigurationProviderRul
static let description = RuleDescription( static let description = RuleDescription(
identifier: "private_unit_test", identifier: "private_unit_test",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

@ -8,7 +8,7 @@ struct ProhibitedInterfaceBuilderRule: ConfigurationProviderRule, SwiftSyntaxRul
static let description = RuleDescription( static let description = RuleDescription(
identifier: "prohibited_interface_builder", identifier: "prohibited_interface_builder",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
wrapExample("var label: UILabel!"), wrapExample("var label: UILabel!"),

View File

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

View File

@ -56,7 +56,7 @@ struct QuickDiscouragedCallRule: OptInRule, ConfigurationProviderRule {
StyleViolation(ruleDescription: Self.description, StyleViolation(ruleDescription: Self.description,
severity: configuration.severity, severity: configuration.severity,
location: Location(file: file, byteOffset: $0), 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( static let description = RuleDescription(
identifier: "quick_discouraged_focused_test", identifier: "quick_discouraged_focused_test",
name: "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, kind: .lint,
nonTriggeringExamples: QuickDiscouragedFocusedTestRuleExamples.nonTriggeringExamples, nonTriggeringExamples: QuickDiscouragedFocusedTestRuleExamples.nonTriggeringExamples,
triggeringExamples: QuickDiscouragedFocusedTestRuleExamples.triggeringExamples triggeringExamples: QuickDiscouragedFocusedTestRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct QuickDiscouragedPendingTestRule: OptInRule, ConfigurationProviderRule, Sw
static let description = RuleDescription( static let description = RuleDescription(
identifier: "quick_discouraged_pending_test", identifier: "quick_discouraged_pending_test",
name: "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, kind: .lint,
nonTriggeringExamples: QuickDiscouragedPendingTestRuleExamples.nonTriggeringExamples, nonTriggeringExamples: QuickDiscouragedPendingTestRuleExamples.nonTriggeringExamples,
triggeringExamples: QuickDiscouragedPendingTestRuleExamples.triggeringExamples triggeringExamples: QuickDiscouragedPendingTestRuleExamples.triggeringExamples

View File

@ -8,7 +8,7 @@ struct RawValueForCamelCasedCodableEnumRule: SwiftSyntaxRule, OptInRule, Configu
static let description = RuleDescription( static let description = RuleDescription(
identifier: "raw_value_for_camel_cased_codable_enum", identifier: "raw_value_for_camel_cased_codable_enum",
name: "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, kind: .lint,
nonTriggeringExamples: [ nonTriggeringExamples: [
Example(""" Example("""

View File

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

View File

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

View File

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

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