-
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
Inline test failure messages #3040
Conversation
Generated by 🚫 Danger |
Thanks for your work on this!
If I recall correctly, in the very early days all rules were run for every example, and one of the rules validated that files had a single newline at the end, so every example needed a newline to avoid triggering that rule. We now just run a single rule when validating each example, so these newlines are no longer required.
This is why examples are often split into separate files than the rule implementations. I'd argue that having that kind of data-like string literals mixed in with the implementation ends up being noisy and hard to read, even if it doesn't contribute to the complexity of the code. At the end of the day, the linter is just there to help. If the best thing for the code quality is to disable the rule in some cases, that's perfectly valid. Finally, there's another big migration happening right now touching a ton of files: #3037 |
Thanks for the heads up on the other PR. Fortunately, they effectively merge cleanly right now (except for a file that I modified and you deleted; can I ask why some rule files were removed? Or is that temporary?). |
That was temporary as we were migrating rules. That PR has merged now and it looks like there are no conflicts with this one! |
* None. | ||
* Inline test failure messages to make development of SwiftLint easier. Test failures in triggering and non-triggering examples will appear inline in their respective files so you can immediately see which cases are working and which are not. | ||
[ZevEisenberg](https://github.com/ZevEisenberg) | ||
[#3040](https://github.com/realm/SwiftLint/pull/3040) |
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:
- A list of Markdown hyperlinks to the issues the change addresses. One entry per line. Usually just one. If there was no issue tracking this change, you may instead link to the change's pull request.
Many other changelog entries link to the issue or PR. Why drop this line?
Source/SwiftLintFramework/Documentation/RuleDocumentation.swift
Outdated
Show resolved
Hide resolved
@jpsim thanks for the comments. I know it’s a bit of a monster, so I’m glad to know it’s not going into the void! Removing the new lines may have been too ambitious, because it seems to have broken a couple of newline-sensitive rules in unexpected ways that I’m having a hard time pinning down, so I may back off on that. I’m having a little trouble closing the last 5% of work, and I’d love to pair with you or someone else who has a lot of experience with the code base to get it over the finish line. I’m free this weekend and all of next week, so the timing is good for me (which is why I’m doing it in the first place 😅). |
I’m afraid I’m short on time these days but maybe you can find someone in the Slack group willing to help? |
I ended up removing the commits where I had deleted trailing new lines. Too much for one PR, and it was causing failures that I didn't want or need to deal with as part of this one. |
I was surprised how much fell into place once I had removed the Also, since this is now ready for review, please let me know if there's anything I can do to make your job easier for reviewing this. I know it's a lot, so if I can help by wrangling reviewers, I'm happy to do so. |
@jpsim in order to fix the length warnings, I ended up restructuring the test helpers. There are no material changes here - just moving files and functions around. I figured you'd want to review that stuff separately: https://github.com/ZevEisenberg/SwiftLint/pull/1 |
@ZevEisenberg please make sure that
|
@PaulTaykalo thanks for taking a look. Fixing those failures involved a bunch of busywork that made this PR harder to review, so I fixed them on a sub-PR that I'd like to get reviewed and merged into this branch first. It's here, in case you've got time to look at it: https://github.com/ZevEisenberg/SwiftLint/pull/1 |
Many thanks to @PaulTaykalo for helping me figure out the best way to get this branch ready to merge. I'm deferring the test helper cleanup, which will be an independent PR. |
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.
few comments and I'm ok with merging it in
|
||
/// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
any specific reason why do we need mutable severity
and location
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.
Personal style: I'm fine making things var
if I need to change them, and letting the call site's use of let
or var
determine the mutability. But I'm also happy to add .with
modifiers to the StyleViolation
type 🙂
reason: $0.reason) | ||
var new = $0 | ||
new.severity = .warning | ||
return new |
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.
with(severity: .warning) ?
return StyleViolation(ruleDescription: violation.ruleDescription, severity: violation.severity, | ||
location: locationWithoutFile, reason: violation.reason) | ||
var new = violation | ||
new.location = locationWithoutFile |
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.
again we can use with(location: locationWithoutFile
) extension
this will remove the need of having mutable property ad well as the some rules disabing
https://github.com/realm/SwiftLint/pull/3040/files#diff-32f83ec6a61cedc75c20b4319015fff9R6
A big thank you @ZevEisenberg for pushing this through and @PaulTaykalo for the code review and shepherding this in! 👏 Sorry I haven't been able to help much. |
Fixes #3035
Example
literal init to all strings and removeExpressibleByStringLiteral
conformance fromExample
type.\n
from the many test cases that have them.Remove trailing newlines from all examples where possible.rolled back because it was too invasivemerge https://github.com/ZevEisenberg/SwiftLint/pull/1this PR is no longer dependent on that one@jpsim here's a start! I took a pretty lazy approach to converting files over to the new format, opting for an
ExpressibleByStringLiteral
band-aid (that doesn't even partially work) just so I can get it up and running. Before merging, we'll need to go through and add an explicitExample(...)
initializer to literally every example.I've also been pretty liberal with smashing things in order to get it all compiling, so I'm very open to ideas if you have suggestions for how to make the PR more conservative.
I have two open questions that I'd love some feedback on:
\n
, but not all of them do. Do you know why it's there? Can I delete those newlines? Here's an example:"public func a() {}\n"
.