Skip to content

Commit

Permalink
prefer contains over first(where:) != nil
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed May 15, 2017
1 parent bb4c94b commit 61e9b39
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/GenericTypeNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public struct GenericTypeNameRule: ASTRule, ConfigurationProviderRule {
return []
}

let containsAllowedSymbol = configuration.allowedSymbols.first(where: { name.contains($0) }) != nil
let containsAllowedSymbol = configuration.allowedSymbols.contains(where: name.contains)
if !containsAllowedSymbol && !CharacterSet.alphanumerics.isSuperset(ofCharactersIn: name) {
return [
StyleViolation(ruleDescription: type(of: self).description,
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/IdentifierNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct IdentifierNameRule: ASTRule, ConfigurationProviderRule {

let type = self.type(for: kind)
if !isFunction {
let containsAllowedSymbol = configuration.allowedSymbols.first(where: { name.contains($0) }) != nil
let containsAllowedSymbol = configuration.allowedSymbols.contains(where: name.contains)
if !containsAllowedSymbol &&
!CharacterSet.alphanumerics.isSuperset(ofCharactersIn: name) {
return [
Expand Down
2 changes: 1 addition & 1 deletion Source/SwiftLintFramework/Rules/TypeNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct TypeNameRule: ASTRule, ConfigurationProviderRule {
}

let name = name.nameStrippingLeadingUnderscoreIfPrivate(dictionary)
let containsAllowedSymbol = configuration.allowedSymbols.first(where: { name.contains($0) }) != nil
let containsAllowedSymbol = configuration.allowedSymbols.contains(where: name.contains)
if !containsAllowedSymbol && !CharacterSet.alphanumerics.isSuperset(ofCharactersIn: name) {
return [StyleViolation(ruleDescription: type(of: self).description,
severity: .error,
Expand Down

0 comments on commit 61e9b39

Please sign in to comment.