Skip to content

Commit

Permalink
Reset VariableNameRule to instantiating Location at the call site.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrhoyt committed Jan 24, 2016
1 parent 6107822 commit b145bf1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Source/SwiftLintFramework/Rules/VariableNameRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,21 @@ public struct VariableNameRule: ASTRule, ConfigProviderRule {

let nameCharacterSet = NSCharacterSet(charactersInString: name)
let description = self.dynamicType.description
let location = Location(file: file, byteOffset: offset)
if !NSCharacterSet.alphanumericCharacterSet().isSupersetOfSet(nameCharacterSet) {
return [StyleViolation(ruleDescription: description,
severity: .Error,
location: location,
location: Location(file: file, byteOffset: offset),
reason: "Variable name should only contain alphanumeric " +
"characters: '\(name)'")]
} else if kind != SwiftDeclarationKind.VarStatic && nameIsViolatingCase(name) {
return [StyleViolation(ruleDescription: description,
severity: .Error,
location: location,
location: Location(file: file, byteOffset: offset),
reason: "Variable name should start with a lowercase character: '\(name)'")]
} else if let severity = severity(forLength: name.characters.count) {
return [StyleViolation(ruleDescription: self.dynamicType.description,
severity: severity,
location: location,
location: Location(file: file, byteOffset: offset),
reason: "Variable name should be between \(config.minLengthThreshold) " +
"and \(config.maxLengthThreshold) characters long: '\(name)'")]
}
Expand Down

0 comments on commit b145bf1

Please sign in to comment.