<commit_before>//
//  ForceUnwrappingRule.swift
//  SwiftLint
//
//  Created by <NAME> on 14/01/16.
//  Copyright (c) 2015 Realm. All rights reserved.
//

import SourceKittenFramework

public struct ForceUnwrappingRule: Rule, OptInRule {

    public init() {}

    public static let description = RuleDescription(
        identifier: "force_unwrapping",
        name: "Force Unwrapping",
        description: "Force unwrapping should be avoided.",
        nonTriggeringExamples: [
            "if let url = NSURL(string: query)",
            "navigationController?.pushViewController(viewController, animated: true)"
        ],
        triggeringExamples: [
            "let url = NSURL(string: query)↓!",
            "navigationController↓!.pushViewController(viewController, animated: true)",
            "let unwrapped = optional↓!",
            "return cell↓!"
        ]
    )

    public func validateFile(file: File) -> [StyleViolation] {
        // Get all identifiers from syntax map
        let identifiers = file.syntaxMap.tokens.filter({
                $0.type == SyntaxKind.Identifier.rawValue
            }).flatMap({
                file.contents.substringWithByteRange(start: $0.offset, length: $0.length)
            })
        // Check if there is any identifier followed by a '!'
        let violations = Set(identifiers).flatMap({
            return file.matchPattern("\($0)(\\((?:[^\\r\\n]|\\r(?!\\n))*?\\))?\\!")
        }).filter({ $0.1.first == .Identifier }).map({ $0.0 })

        return violations.map({
            StyleViolation(ruleDescription: self.dynamicType.description,
                severity: .Warning,
                location: Location(file: file, characterOffset: $0.location + $0.length - 1))
        })
    }
}<commit_msg>fix indentation in ForceUnwrappingRule<commit_after>//
//  ForceUnwrappingRule.swift
//  SwiftLint
//
//  Created by <NAME> on 14/01/16.
//  Copyright (c) 2015 Realm. All rights reserved.
//

import SourceKittenFramework

public struct ForceUnwrappingRule: Rule, OptInRule {

    public init() {}

    public static let description = RuleDescription(
        identifier: "force_unwrapping",
        name: "Force Unwrapping",
        description: "Force unwrapping should be avoided.",
        nonTriggeringExamples: [
            "if let url = NSURL(string: query)",
            "navigationController?.pushViewController(viewController, animated: true)"
        ],
        triggeringExamples: [
            "let url = NSURL(string: query)↓!",
            "navigationController↓!.pushViewController(viewController, animated: true)",
            "let unwrapped = optional↓!",
            "return cell↓!"
        ]
    )

    public func validateFile(file: File) -> [StyleViolation] {
        // Get all identifiers from syntax map
        let identifiers = file.syntaxMap.tokens.filter({
            $0.type == SyntaxKind.Identifier.rawValue
        }).flatMap({
            file.contents.substringWithByteRange(start: $0.offset, length: $0.length)
        })
        // Check if there is any identifier followed by a '!'
        let violations = Set(identifiers).flatMap({
            return file.matchPattern("\($0)(\\((?:[^\\r\\n]|\\r(?!\\n))*?\\))?\\!")
        }).filter({ $0.1.first == .Identifier }).map({ $0.0 })

        return violations.map({
            StyleViolation(ruleDescription: self.dynamicType.description,
                severity: .Warning,
                location: Location(file: file, characterOffset: $0.location + $0.length - 1))
        })
    }
}
{'fraction_non_alphanumeric': 0.13732692851087877, 'fraction_numerical': 0.01186775925402656, 'mean_word_length': 2.3022388059701493, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2139196', 'n_tokens_mistral': 1023, 'n_tokens_neox': 978, 'n_words': 233}