<commit_before>import AppKit

private let kAPIKeyURL = URL(string: "https://openradar.appspot.com/apikey")!
private let kOpenRadarUsername = "openradar"

final class OpenRadarPreferencesViewController: ViewController {
    @IBOutlet private var APIKeyTextField: NSTextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        if let (_, password) = Keychain.get(.openRadar) {
            self.APIKeyTextField.stringValue = password
        }

        self.APIKeyTextField.becomeFirstResponder()
    }

    @IBAction private func getAPIKey(_ sender: Any) {
        NSWorkspace.shared().open(kAPIKeyURL)
    }

    fileprivate func saveCurrentToken() {
        let token = self.APIKeyTextField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
        Keychain.set(username: kOpenRadarUsername, password: token, forKey: .openRadar)
    }
}

extension OpenRadarPreferencesViewController: NSTextFieldDelegate {
    override func controlTextDidEndEditing(_: Notification) {<commit_msg>Delete radar token if field is empty<commit_after>import AppKit

private let kAPIKeyURL = URL(string: "https://openradar.appspot.com/apikey")!
private let kOpenRadarUsername = "openradar"

final class OpenRadarPreferencesViewController: ViewController {
    @IBOutlet private var APIKeyTextField: NSTextField!

    override func viewDidLoad() {
        super.viewDidLoad()

        if let (_, password) = Keychain.get(.openRadar) {
            self.APIKeyTextField.stringValue = password
        }

        self.APIKeyTextField.becomeFirstResponder()
    }

    @IBAction private func getAPIKey(_ sender: Any) {
        NSWorkspace.shared().open(kAPIKeyURL)
    }

    fileprivate func saveCurrentToken() {
        let token = self.APIKeyTextField.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
        if token.isEmpty {
            Keychain.delete(.openRadar)
        } else {
            Keychain.set(username: kOpenRadarUsername, password: token, forKey: .openRadar)
        }
    }
}

extension OpenRadarPreferencesViewController: NSTextFieldDelegate {
    override func controlTextDidEndEditing(_: Notification) {
{'fraction_non_alphanumeric': 0.0863275781614559, 'fraction_numerical': 0.0, 'mean_word_length': 3.6206896551724137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5661767', 'n_tokens_mistral': 626, 'n_tokens_neox': 606, 'n_words': 126}