Skip to content

Commit

Permalink
Fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Keller committed Nov 2, 2017
1 parent a7fc3ad commit f7187b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions Sources/SwiftChatSE/ChatListener.swift
Expand Up @@ -154,7 +154,7 @@ open class ChatListener {
for usageComponent in availableUsageComponents {
for component in availableComponents {
let distance = Levenshtein.distanceBetween(usageComponent, and: component)
let componentScore = min(distance, usageComponent.characters.count)
let componentScore = min(distance, usageComponent.count)

if componentScore < bestMatch?.score ?? Int.max {
bestMatch = (score: componentScore, component: component, usageComponent: usageComponent)
Expand All @@ -176,13 +176,13 @@ open class ChatListener {
}
for _ in args {
if !availableComponents.isEmpty {
score += availableComponents.first!.characters.count / 3
score += availableComponents.first!.count / 3
availableComponents.removeFirst()
}
}

for component in (availableComponents + availableUsageComponents) {
score += component.characters.count
score += component.count
}

commandScores[usage] = score
Expand All @@ -200,7 +200,7 @@ open class ChatListener {
$0 != "*" && $0 != "..."
}.joined(separator: " ")

if score <= Int(ceil(Float(commandCharacters.characters.count)/2.0)) && score < (lowest?.score ?? Int.max) {
if score <= Int(ceil(Float(commandCharacters.count)/2.0)) && score < (lowest?.score ?? Int.max) {
lowest = (command, score)
}
}
Expand All @@ -216,10 +216,10 @@ open class ChatListener {
open func processMessage(_ room: ChatRoom, message: ChatMessage, isEdit: Bool) {
let lowercase = message.content.lowercased()

let shortName = String(name.characters[
name.characters.startIndex..<name.characters.index(
name.characters.startIndex,
offsetBy: min(name.characters.count, minNameCharacters)
let shortName = String(name[
name.startIndex..<name.index(
name.startIndex,
offsetBy: min(name.count, minNameCharacters)
)]
)

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftChatSE/ChatRoom.swift
Expand Up @@ -407,7 +407,7 @@ open class ChatRoom: NSObject {
///- parameter completion: The completion handler to call when the message is posted.
///The message ID will be passed to the completion handler.
open func postMessage(_ message: String, completion: ((Int?) -> Void)? = nil) {
if message.characters.count == 0 {
if message.count == 0 {
return
}
messageQueue.append((message, completion))
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftChatSE/CommandPrivilege.swift
Expand Up @@ -56,7 +56,7 @@ open class CommandPrivilege: Command {
let cleanedName = chatUser.name.replacingOccurrences(of: " ", with: "").lowercased()
if chatUser.id == Int(user) ||
cleanedName == user.lowercased() ||
(user.hasPrefix("@") && cleanedName == String(user.lowercased().characters.dropFirst())) ||
(user.hasPrefix("@") && cleanedName == String(user.lowercased().dropFirst())) ||
chatUser.id == idFromURL {

targetUser = chatUser
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftChatSE/Utilites.swift
Expand Up @@ -83,9 +83,9 @@ public func makeTable(_ heading: [String], contents: [String]...) -> String {
var tableWidth = 0

for col in 0..<cols {
maxLength.append(heading[col].characters.count)
maxLength.append(heading[col].count)
for row in contents[col] {
maxLength[col] = max(row.characters.count, maxLength[col])
maxLength[col] = max(row.count, maxLength[col])
}
rows = max(contents[col].count, rows)
alignedHeading.append(heading[col].padding(toLength: maxLength[col], withPad: " ", startingAt: 0))
Expand Down

0 comments on commit f7187b0

Please sign in to comment.