Skip to content

Commit

Permalink
[LineLengthRule] Increase default parameters. Fixes #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed May 28, 2015
1 parent b984a0f commit 32b72b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
[aarondaub](https://github.com/aarondaub)
[#21](https://github.com/realm/SwiftLint/issues/21)

* Increase default `LineLengthRule` parameters to 120, 150, 180, 200, 250.
[JP Simard](https://github.com/jpsim)
[#28](https://github.com/realm/SwiftLint/issues/28)

##### Enhancements

* The following rules now conform to `ASTRule`:
Expand Down
8 changes: 4 additions & 4 deletions Source/SwiftLintFramework/Rules/LineLengthRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public struct LineLengthRule: ParameterizedRule {
public let identifier = "line_length"

public let parameters = [
RuleParameter(severity: .VeryLow, value: 100),
RuleParameter(severity: .Low, value: 120),
RuleParameter(severity: .Medium, value: 150),
RuleParameter(severity: .VeryLow, value: 120),
RuleParameter(severity: .Low, value: 150),
RuleParameter(severity: .Medium, value: 180),
RuleParameter(severity: .High, value: 200),
RuleParameter(severity: .VeryHigh, value: 250)
]
Expand All @@ -28,7 +28,7 @@ public struct LineLengthRule: ParameterizedRule {
return StyleViolation(type: .Length,
location: Location(file: file.path, line: line.index),
severity: parameter.severity,
reason: "Line should be 100 characters or less: currently " +
reason: "Line should be 120 characters or less: currently " +
"\(count(line.content)) characters")
}
}
Expand Down
16 changes: 8 additions & 8 deletions Source/SwiftLintFrameworkTests/LinterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class LinterTests: XCTestCase {
}

func testControlStatements() {
verifyRule(ControlStatementRule().example, type: .ControlStatement, commentDoesntViolate: true)
verifyRule(ControlStatementRule().example, type: .ControlStatement)
}

func testNumberOfFunctionsInAType() {
Expand Down Expand Up @@ -200,20 +200,20 @@ class LinterTests: XCTestCase {
// MARK: String Violations

func testLineLengths() {
let longLine = join("", Array(count: 100, repeatedValue: "/")) + "\n"
let longLine = join("", Array(count: 120, repeatedValue: "/")) + "\n"
XCTAssertEqual(violations(longLine), [])
let testCases: [(String, Int, ViolationSeverity)] = [
("/", 101, .VeryLow),
(join("", Array(count: 21, repeatedValue: "/")), 121, .Low),
(join("", Array(count: 51, repeatedValue: "/")), 151, .Medium),
(join("", Array(count: 101, repeatedValue: "/")), 201, .High),
(join("", Array(count: 151, repeatedValue: "/")), 251, .VeryHigh)
("/", 121, .VeryLow),
(join("", Array(count: 31, repeatedValue: "/")), 151, .Low),
(join("", Array(count: 61, repeatedValue: "/")), 181, .Medium),
(join("", Array(count: 81, repeatedValue: "/")), 201, .High),
(join("", Array(count: 131, repeatedValue: "/")), 251, .VeryHigh)
]
for testCase in testCases {
XCTAssertEqual(violations(testCase.0 + longLine), [StyleViolation(type: .Length,
location: Location(file: nil, line: 1),
severity: testCase.2,
reason: "Line should be 100 characters or less: " +
reason: "Line should be 120 characters or less: " +
"currently \(testCase.1) characters")])
}
}
Expand Down

0 comments on commit 32b72b4

Please sign in to comment.