Discard unused closure parameters

This commit is contained in:
1024jp 2020-08-12 16:30:27 +09:00
parent f0b9e290cc
commit 9c36de1027
14 changed files with 29 additions and 31 deletions

View File

@ -70,9 +70,7 @@ disabled_rules:
- force_try
- nesting
- opening_brace
- pattern_matching_keywords
- trailing_comma
- unused_closure_parameter
- weak_delegate
private_outlet:

View File

@ -272,7 +272,7 @@ final class AppearancePaneController: NSViewController, NSMenuItemValidation, NS
info.enumerateDraggingItems(for: tableView, classes: [NSURL.self],
searchOptions: [.urlReadingFileURLsOnly: true,
.urlReadingContentsConformToTypes: [DocumentType.theme.utType]])
{ [unowned self] (draggingItem: NSDraggingItem, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) in
{ [unowned self] (draggingItem, _, _) in
guard let fileURL = draggingItem.item as? URL else { return }
@ -344,20 +344,20 @@ final class AppearancePaneController: NSViewController, NSMenuItemValidation, NS
// Restore
return [NSTableViewRowAction(style: .regular,
title: "Restore".localized,
handler: { [weak self] (action: NSTableViewRowAction, row: Int) in
handler: { [weak self] (_, _) in
self?.restoreTheme(name: themeName)
// finish swiped mode anyway
tableView.rowActionsVisible = false
})]
})]
} else {
// Delete
return [NSTableViewRowAction(style: .destructive,
title: "Delete".localized,
handler: { [weak self] (action: NSTableViewRowAction, row: Int) in
handler: { [weak self] (_, _) in
self?.deleteTheme(name: themeName)
})]
})]
}
}

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2016-2018 1024jp
// © 2016-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ final class AppleScript: Script {
let task = try NSUserAppleScriptTask(url: self.descriptor.url)
let scriptName = self.descriptor.name
task.execute(withAppleEvent: event) { (result: NSAppleEventDescriptor?, error: Error?) in
task.execute(withAppleEvent: event) { (_, error) in
if let error = error {
writeToConsole(message: error.localizedDescription, scriptName: scriptName)
}

View File

@ -76,7 +76,7 @@ final class DefinitionTableViewDelegate: NSObject, NSTableViewDelegate {
let identifier = tableView.tableColumns[columnIndex].identifier
let isChecked = checkbox.state == .on
tableView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) in
tableView.enumerateAvailableRowViews { (rowView, _) in
guard
rowView.isSelected,
let view = rowView.view(atColumn: columnIndex) as? NSTableCellView

View File

@ -86,7 +86,7 @@ final class DraggableArrayController: NSArrayController, NSTableViewDataSource {
let destinationRows = IndexSet(destinationRow..<(destinationRow + draggingItems.count))
// update
NSAnimationContext.runAnimationGroup({ context in
NSAnimationContext.runAnimationGroup({ _ in
// update UI
tableView.beginUpdates()
tableView.removeRows(at: sourceRows, withAnimation: [.effectFade, .slideDown])

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2016-2019 1024jp
// © 2016-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ final class EncodingTableCellView: NSTableCellView {
let mutableAttrString = attrString.mutable
attrString.enumerateAttribute(.foregroundColor, in: attrString.range)
{ (value: Any?, range: NSRange, stop: UnsafeMutablePointer<ObjCBool>) in
{ (value, range, _) in
let color = value as? NSColor
let newColor: NSColor?

View File

@ -211,20 +211,20 @@ final class FormatPaneController: NSViewController, NSMenuItemValidation, NSTabl
// Restore
return [NSTableViewRowAction(style: .regular,
title: "Restore".localized,
handler: { [weak self] (action: NSTableViewRowAction, row: Int) in
handler: { [weak self] (_, _) in
self?.restoreSyntaxStyle(name: styleName)
// finish swiped mode anyway
tableView.rowActionsVisible = false
})]
})]
} else {
// Delete
return [NSTableViewRowAction(style: .destructive,
title: "Delete".localized,
handler: { [weak self] (action: NSTableViewRowAction, row: Int) in
handler: { [weak self] (_, _) in
self?.deleteSyntaxStyle(name: styleName)
})]
})]
}
}
@ -256,7 +256,7 @@ final class FormatPaneController: NSViewController, NSMenuItemValidation, NSTabl
info.enumerateDraggingItems(for: tableView, classes: [NSURL.self],
searchOptions: [.urlReadingFileURLsOnly: true])
{ [unowned self] (draggingItem: NSDraggingItem, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) in
{ [unowned self] (draggingItem, _, _) in
guard
let fileURL = draggingItem.item as? URL,

View File

@ -415,7 +415,7 @@ extension MultipleReplacementListViewController: NSTableViewDataSource {
info.enumerateDraggingItems(for: tableView, classes: [NSURL.self],
searchOptions: [.urlReadingFileURLsOnly: true,
.urlReadingContentsConformToTypes: [DocumentType.replacement.utType]])
{ [weak self] (draggingItem: NSDraggingItem, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) in
{ [weak self] (draggingItem, _, _) in
guard let fileURL = draggingItem.item as? URL else { return }

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2018 1024jp
// © 2018-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ extension NSRegularExpression {
func matches(in string: String, options: NSRegularExpression.MatchingOptions, range: NSRange, using block: (_ stop: inout Bool) -> Void) -> [NSTextCheckingResult] {
var matches: [NSTextCheckingResult] = []
self.enumerateMatches(in: string, options: options, range: range) { (match, flags, stopPointer) in
self.enumerateMatches(in: string, options: options, range: range) { (match, _, stopPointer) in
var stop = false
block(&stop)
if stop {

View File

@ -156,7 +156,7 @@ extension MultiCursorEditing {
let glyphRange = layoutManager.glyphRange(forCharacterRange: range, actualCharacterRange: nil)
var locations: [Int] = []
layoutManager.enumerateLineFragments(forGlyphRange: glyphRange) { [unowned self] (_, usedRect, _, glyphRange, stop) in
layoutManager.enumerateLineFragments(forGlyphRange: glyphRange) { [unowned self] (_, usedRect, _, _, _) in
let rect = usedRect.offset(by: self.textContainerOrigin) // to view-based
let point = NSPoint(x: startPoint.x, y: rect.midY)

View File

@ -88,7 +88,7 @@ final class URLDetectionOperation: AsynchronousOperation {
var links: [(url: URL, range: NSRange)] = []
let detector = try! NSDataDetector(types: NSTextCheckingResult.CheckingType.link.rawValue)
detector.enumerateMatches(in: self.string, options: [.reportProgress], range: self.string.range) { (result, flag, stop) in
detector.enumerateMatches(in: self.string, options: [.reportProgress], range: self.string.range) { (result, _, stop) in
if self.isCancelled {
stop.pointee = true
}

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2015-2019 1024jp
// © 2015-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ final class ServicesProvider: NSObject {
guard let fileURLs = pboard.readObjects(forClasses: [NSURL.self]) as? [URL] else { return assertionFailure() }
for fileURL in fileURLs {
NSDocumentController.shared.openDocument(withContentsOf: fileURL, display: true) { (document: NSDocument?, documentWasAlreadyOpen: Bool, error: Error?) in
NSDocumentController.shared.openDocument(withContentsOf: fileURL, display: true) { (_, _, error) in
if let error = error {
NSApp.presentError(error)
}

View File

@ -8,7 +8,7 @@
//
// ---------------------------------------------------------------------------
//
// © 2015-2019 1024jp
// © 2015-2020 1024jp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -188,13 +188,13 @@ final class TextFind {
var forwardMatches = [NSRange]() // matches after the start location
let forwardRange = NSRange(startLocation..<(self.string as NSString).length)
self.enumerateMatchs(in: [forwardRange], using: { (matchedRange: NSRange, match: NSTextCheckingResult?, stop) in
self.enumerateMatchs(in: [forwardRange], using: { (matchedRange, _, _) in
forwardMatches.append(matchedRange)
})
var wrappedMatches = [NSRange]() // matches before the start location
var intersectionMatches = [NSRange]() // matches including the start location
self.enumerateMatchs(in: [(self.string as NSString).range], using: { (matchedRange: NSRange, match: NSTextCheckingResult?, stop) in
self.enumerateMatchs(in: [(self.string as NSString).range], using: { (matchedRange, _, stop) in
if matchedRange.location >= startLocation {
stop = true
return
@ -449,7 +449,7 @@ final class TextFind {
for scopeRange in ranges {
guard !cancelled else { return }
regex.enumerateMatches(in: string, options: options, range: scopeRange) { (result, flags, stop) in
regex.enumerateMatches(in: string, options: options, range: scopeRange) { (result, _, stop) in
guard let result = result else { return }
var ioStop = false

View File

@ -203,7 +203,7 @@ final class TextFindTests: XCTestCase {
textFind = try TextFind(for: "abcdefg ABCDEFG", findString: "(?!=a)b(c)(?=d)", mode: mode)
var matches = [[NSRange]]()
textFind.findAll { (matchedRanges, stop) in
textFind.findAll { (matchedRanges, _) in
matches.append(matchedRanges)
}
XCTAssertEqual(matches.count, 2)
@ -218,7 +218,7 @@ final class TextFindTests: XCTestCase {
textFind = try TextFind(for: "abcdefg ABCDEFG", findString: "ab", mode: mode)
matches = [[NSRange]]()
textFind.findAll { (matchedRanges, stop) in
textFind.findAll { (matchedRanges, _) in
matches.append(matchedRanges)
}
XCTAssertEqual(matches.count, 2)