-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline test failure messages #3040
Changes from 25 commits
77ddb0b
16ae3e4
c8ae950
d450701
4cb9cf3
3349b4d
ef7c1f0
53d3eb1
4d98c0b
b1d7df1
e9ca45a
e9401c2
c2b5a84
9b6c100
ee82639
dd45e24
312fd3a
e165d96
49eec02
27e2e31
a474d26
4b9482c
6cd264c
44a7ebe
80f97c8
dace1f2
0ec30db
f1f613b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/// Captures code and context information for an example of a triggering or | ||
/// non-triggering style | ||
public struct Example { | ||
/// The contents of the example | ||
public var code: String | ||
/// The path to the file where the example was created | ||
public var file: StaticString | ||
/// The line in the file where the example was created | ||
public var line: UInt | ||
} | ||
|
||
public extension Example { | ||
/// Create a new Example with the specified code, file, and line | ||
/// - Parameters: | ||
/// - code: The contents of the example | ||
/// - file: The path to the file where the example is located. | ||
/// Defaults to the file where this initializer is called. | ||
/// - line: The line in the file where the example is located. | ||
/// Defaults to the line where this initializer is called. | ||
init(_ code: String, file: StaticString = #file, line: UInt = #line) { | ||
self.code = code | ||
self.file = file | ||
self.line = line | ||
} | ||
|
||
/// Retunrs the same example, but with the `code` that is passed in | ||
/// - Parameter code: the new code to use in the modified example | ||
func with(code: String) -> Example { | ||
var new = self | ||
new.code = code | ||
return new | ||
} | ||
|
||
/// Returns a copy of the Example with all instances of the "↓" character removed. | ||
func removingViolationMarkers() -> Example { | ||
return with(code: code.replacingOccurrences(of: "↓", with: "")) | ||
} | ||
} | ||
|
||
extension Example: Hashable { | ||
public static func == (lhs: Example, rhs: Example) -> Bool { | ||
// Ignoring file/line metadata because two Examples could represent | ||
// the same idea, but captured at two different points in the code | ||
return lhs.code == rhs.code | ||
} | ||
|
||
public func hash(into hasher: inout Hasher) { | ||
// Ignoring file/line metadata because two Examples could represent | ||
// the same idea, but captured at two different points in the code | ||
hasher.combine(code) | ||
} | ||
} | ||
|
||
extension Example: Comparable { | ||
public static func < (lhs: Example, rhs: Example) -> Bool { | ||
return lhs.code < rhs.code | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
/// A value describing an instance of Swift source code that is considered invalid by a SwiftLint rule. | ||
public struct StyleViolation: CustomStringConvertible, Equatable, Codable { | ||
/// The identifier of the rule that generated this violation. | ||
public let ruleIdentifier: String | ||
|
||
/// The description of the rule that generated this violation. | ||
public let ruleDescription: RuleDescription | ||
public let ruleDescription: String | ||
|
||
/// The name of the rule that generated this violation. | ||
public let ruleName: String | ||
|
||
/// The severity of this violation. | ||
public let severity: ViolationSeverity | ||
public var severity: ViolationSeverity | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any specific reason why do we need mutable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personal style: I'm fine making things |
||
|
||
/// The location of this violation. | ||
public let location: Location | ||
public var location: Location | ||
|
||
/// The justification for this violation. | ||
public let reason: String | ||
|
@@ -23,9 +29,13 @@ public struct StyleViolation: CustomStringConvertible, Equatable, Codable { | |
/// - parameter severity: The severity of this violation. | ||
/// - parameter location: The location of this violation. | ||
/// - parameter reason: The justification for this violation. | ||
public init(ruleDescription: RuleDescription, severity: ViolationSeverity = .warning, | ||
location: Location, reason: String? = nil) { | ||
self.ruleDescription = ruleDescription | ||
public init(ruleDescription: RuleDescription, | ||
severity: ViolationSeverity = .warning, | ||
location: Location, | ||
reason: String? = nil) { | ||
self.ruleIdentifier = ruleDescription.identifier | ||
self.ruleDescription = ruleDescription.description | ||
self.ruleName = ruleDescription.name | ||
self.severity = severity | ||
self.location = location | ||
self.reason = reason ?? ruleDescription.description | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just drop this line completely: https://github.com/realm/SwiftLint/blob/master/CONTRIBUTING.md#tracking-changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused. That page says:
Many other changelog entries link to the issue or PR. Why drop this line?