<commit_before>//
//  Cichlid.swift
//
//  Created by <NAME> on 2/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import AppKit

var sharedPlugin: Cichlid?

class Cichlid: NSObject {
    
    var bundle: NSBundle

    class func pluginDidLoad(bundle: NSBundle) {
        let appName = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? NSString
        if appName == "Xcode" {
            sharedPlugin = Cichlid(bundle: bundle)
        }
    }

    init(bundle: NSBundle) {
        self.bundle = bundle
        super.init()
        
        setupObserver()
    }

    deinit {
        cleanObserver()
    }
    
}

extension Cichlid {
    
    private func setupObserver() {
        NSNotificationCenter.defaultCenter().addObserver(self,
            selector: "notificationListener:",
            name: "IDEBuildOperationDidStopNotification",
            object: nil)
    }
    
    private func cleanObserver() {
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func notificationListener(notification: NSNotification) {
        guard
        let object = notification.object
        where XcodeHelpers.isCleanBuildOperation(object),
        let projectName = XcodeHelpers.currentProductName() else {
            return
        }
    
        Cleaner.clearDerivedDataForProject(projectName)
    }
    
}<commit_msg>Refactoring<commit_after>//
//  Cichlid.swift
//
//  Created by <NAME> on 2/29/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import AppKit

var sharedPlugin: Cichlid?

class Cichlid: NSObject {
    
    var bundle: NSBundle

    class func pluginDidLoad(bundle: NSBundle) {
        if
        let appName = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as? NSString
        where appName == "Xcode" {
            sharedPlugin = Cichlid(bundle: bundle)
        }
    }

    init(bundle: NSBundle) {
        self.bundle = bundle
        super.init()
        
        setupObserver()
    }

    deinit {
        cleanObserver()
    }
    
}

extension Cichlid {
    
    private func setupObserver() {
        NSNotificationCenter.defaultCenter().addObserver(self,
            selector: "observedBuildOperationDidStopNotification:",
            name: "IDEBuildOperationDidStopNotification",
            object: nil)
    }
    
    private func cleanObserver() {
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    
    func observedBuildOperationDidStopNotification(notification: NSNotification) {
        guard
        let object = notification.object
        where XcodeHelpers.isCleanBuildOperation(object),
        let projectName = XcodeHelpers.currentProductName() else {
            return
        }
    
        Cleaner.clearDerivedDataForProject(projectName)
    }
    
}
{'fraction_non_alphanumeric': 0.09110473457675754, 'fraction_numerical': 0.006456241032998565, 'mean_word_length': 2.2430232558139536, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1509389', 'n_tokens_mistral': 793, 'n_tokens_neox': 768, 'n_words': 159}