<commit_before>import Foundation
import SourceKittenFramework

public struct DisallowNoneCase: ASTRule, OptInRule, ConfigurationProviderRule {
    public var configuration = SeverityConfiguration(.warning)

    public init() {}

    public static var description = RuleDescription(
        identifier: "disallow_none_case",
        name: "Disallow None Case",
        description: "Disallows the naming of enum cases as 'none' which can conflict with Optional<T>.none",
        kind: .idiomatic,
        nonTriggeringExamples: [
            Example("")
        ],
        triggeringExamples: [
            Example("")
        ]
    )

    public func validate(
        file: SwiftLintFile,
        kind: SwiftDeclarationKind,
        dictionary: SourceKittenDictionary
    ) -> [StyleViolation] {
        guard kind.isForValidating && dictionary.isNameInvalid, let offset = dictionary.offset else { return [] }
        return [
            StyleViolation(
                ruleDescription: Self.description,
                severity: configuration.severity,
                location: Location(file: file, byteOffset: offset),
                reason: """
\(kind.reasonPrefix) should not be named `none` since the compiler can think you mean `Optional<T>.none`.
"""
            )
        ]
    }
}

private extension SwiftDeclarationKind {
    var isForValidating: Bool { self == .enum || self == .varClass || self == .varStatic }

    var reasonPrefix: String {
        switch self {
        case .enum: return "`case`"
        case .varClass, .varStatic: return "`static`/`class` members"
        default: return ""
        }<commit_msg>Uses correct enumcase instead of enum<commit_after>import Foundation
import SourceKittenFramework

public struct DisallowNoneCase: ASTRule, OptInRule, ConfigurationProviderRule {
    public var configuration = SeverityConfiguration(.warning)

    public init() {}

    public static var description = RuleDescription(
        identifier: "disallow_none_case",
        name: "Disallow None Case",
        description: "Disallows the naming of enum cases as 'none' which can conflict with Optional<T>.none",
        kind: .idiomatic
    )

    public func validate(
        file: SwiftLintFile,
        kind: SwiftDeclarationKind,
        dictionary: SourceKittenDictionary
    ) -> [StyleViolation] {
        guard kind.isForValidating && dictionary.isNameInvalid, let offset = dictionary.offset else { return [] }
        return [
            StyleViolation(
                ruleDescription: Self.description,
                severity: configuration.severity,
                location: Location(file: file, byteOffset: offset),
                reason: """
\(kind.reasonPrefix) should not be named `none` since the compiler can think you mean `Optional<T>.none when checking equality`.
"""
            )
        ]
    }
}

private extension SwiftDeclarationKind {
    var isForValidating: Bool { self == .enumcase || self == .varClass || self == .varStatic }

    var reasonPrefix: String {
        switch self {
        case .enum: return "`case`"
        case .varClass, .varStatic: return "`static`/`class` members"
        default: return ""
        }
{'fraction_non_alphanumeric': 0.09216300940438872, 'fraction_numerical': 0.0, 'mean_word_length': 2.5181918412348403, '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': '6439380', 'n_tokens_mistral': 826, 'n_tokens_neox': 786, 'n_words': 244}