<commit_before>//
//  EmptyParametersRule.swift
//  SwiftLint
//
//  Created by <NAME> on 11/12/16.
//  Copyright © 2016 Realm. All rights reserved.
//

import Foundation
import SourceKittenFramework

public struct EmptyParametersRule: Rule, ConfigurationProviderRule {
    public var configuration = SeverityConfiguration(.warning)

    public init() {}

    public static let description = RuleDescription(
        identifier: "empty_parameters",
        name: "Empty Parameters",
        description: "Prefer `() -> ` over `Void -> `.",
        nonTriggeringExamples: [
            "let abc: () -> Void = {}\n",
            "func foo(completion: () -> Void)\n",
            "func foo(completion: () thows -> Void)\n"
        ],
        triggeringExamples: [
            "let abc: ↓Void -> Void = {}\n",
            "func foo(completion: ↓Void -> Void)\n",
            "func foo(completion: ↓Void throws -> Void)\n"
        ]
    )

    public func validateFile(_ file: File) -> [StyleViolation] {
        let kinds = SyntaxKind.commentAndStringKinds()
        return file.matchPattern("Void\\s*(throws\\s+)?->", excludingSyntaxKinds: kinds).map {
            StyleViolation(ruleDescription: type(of: self).description,
                           severity: configuration.severity,
                           location: Location(file: file, characterOffset: $0.location))
        }
    }
}
<commit_msg>Excluding curried functions<commit_after>//
//  EmptyParametersRule.swift
//  SwiftLint
//
//  Created by <NAME> on 11/12/16.
//  Copyright © 2016 Realm. All rights reserved.
//

import Foundation
import SourceKittenFramework

public struct EmptyParametersRule: Rule, ConfigurationProviderRule {
    public var configuration = SeverityConfiguration(.warning)

    public init() {}

    public static let description = RuleDescription(
        identifier: "empty_parameters",
        name: "Empty Parameters",
        description: "Prefer `() -> ` over `Void -> `.",
        nonTriggeringExamples: [
            "let abc: () -> Void = {}\n",
            "func foo(completion: () -> Void)\n",
            "func foo(completion: () thows -> Void)\n",
            "let foo: (ConfigurationTests) -> Void throws -> Void)\n",
            "let foo: (ConfigurationTests) ->   Void throws -> Void)\n",
            "let foo: (ConfigurationTests) ->Void throws -> Void)\n"
        ],
        triggeringExamples: [
            "let abc: ↓Void -> Void = {}\n",
            "func foo(completion: ↓Void -> Void)\n",
            "func foo(completion: ↓Void throws -> Void)\n",
            "let foo: ↓Void -> () throws -> Void)\n"
        ]
    )

    public func validateFile(_ file: File) -> [StyleViolation] {
        let kinds = SyntaxKind.commentAndStringKinds()
        let pattern = "Void\\s*(throws\\s+)?->"
        let excludingPattern = "->\\s*" + pattern // excludes curried functions
        return file.matchPattern(pattern,
                                 excludingSyntaxKinds: kinds,
                                 excludingPattern: excludingPattern).map {
            StyleViolation(ruleDescription: type(of: self).description,
                           severity: configuration.severity,
                           location: Location(file: file, characterOffset: $0.location))
        }
    }
}

{'fraction_non_alphanumeric': 0.132504548211037, 'fraction_numerical': 0.0066707095209217705, 'mean_word_length': 2.10933081998115, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4889608', 'n_tokens_mistral': 936, 'n_tokens_neox': 887, 'n_words': 225}