<commit_before>//  Created by <NAME> on 12/9/16.

import Foundation
import SwiftCLI

// NOTE:
// This file was not refactored as port of the work/big-refactoring branch for version 4.0 to prevent unexpected behavior changes.
// A rewrite after writing extensive tests for the expected behavior could improve readebility, extensibility and performance.

enum CodeCommanderError: Error {
    case missingPath
    case pathNotADirectory
    case enumeratorCreationFailed
    case findFilesFailed
}

private enum CodeCommanderConstants {
    static let sourceCodeExtensions: Set<String> = ["h", "m", "mm", "swift"]
}

/// Sends `xcrun extractLocStrings` commands with specified input/output paths to bash.
public class CodeCommander {
    // MARK: - Stored Type Properties
    public static let shared = CodeCommander()

    // MARK: - Instance Methods
    public func export(stringsFilesToPath stringsFilePath: String, fromCodeInDirectoryPath codeDirectoryPath: String, customFunction: String?) throws {
        let files = try findFiles(in: codeDirectoryPath)
        let customFunctionArgs = customFunction != nil ? ["-s", "\(customFunction!)"] : []

        let arguments = ["extractLocStrings"] + files + ["-o", stringsFilePath] + customFunctionArgs
        try run("/usr/bin/xcrun", arguments: arguments)
    }

    func findFiles(in codeDirectoryPath: String) throws -> [String] {
        let fileManager = FileManager.default
<commit_msg>Turn off multiple key/value pair warnings by default<commit_after>//  Created by <NAME> on 12/9/16.

import Foundation
import SwiftCLI

// NOTE:
// This file was not refactored as port of the work/big-refactoring branch for version 4.0 to prevent unexpected behavior changes.
// A rewrite after writing extensive tests for the expected behavior could improve readebility, extensibility and performance.

enum CodeCommanderError: Error {
    case missingPath
    case pathNotADirectory
    case enumeratorCreationFailed
    case findFilesFailed
}

private enum CodeCommanderConstants {
    static let sourceCodeExtensions: Set<String> = ["h", "m", "mm", "swift"]
}

/// Sends `xcrun extractLocStrings` commands with specified input/output paths to bash.
public class CodeCommander {
    // MARK: - Stored Type Properties
    public static let shared = CodeCommander()

    // MARK: - Instance Methods
    public func export(stringsFilesToPath stringsFilePath: String, fromCodeInDirectoryPath codeDirectoryPath: String, customFunction: String?) throws {
        let files = try findFiles(in: codeDirectoryPath)
        let customFunctionArgs = customFunction != nil ? ["-s", "\(customFunction!)"] : []
        let defaultFunctionArgs = ["-q"]

        let arguments = ["extractLocStrings"] + files + ["-o", stringsFilePath] + customFunctionArgs + defaultFunctionArgs
        try run("/usr/bin/xcrun", arguments: arguments)
    }

    func findFiles(in codeDirectoryPath: String) throws -> [String] {
        let fileManager = FileManager.default

{'fraction_non_alphanumeric': 0.08975217682518419, 'fraction_numerical': 0.004688546550569324, 'mean_word_length': 3.89672131147541, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '413693', 'n_tokens_mistral': 791, 'n_tokens_neox': 766, 'n_words': 281}