-
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
Started to add rationales #5681
base: main
Are you sure you want to change the base?
Conversation
Here's an example of your CHANGELOG entry: * Started to add rationales.
[mildm8nnered](https://github.com/mildm8nnered)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
2e234b3
to
e9e38be
Compare
That's an ambitious plan with 238 existing rules. 😅 But I very much appreciate the effort. This definitely something helpful and can be extended over time with the infrastructure as a starting point. A few thoughts from my side:
|
238 is a lot yes, but I think definitely achievable. I've had a lot of fun writing the ones so far, and it's the kind of thing that you can knock some off on a rainy afternoon. Keep going, and before you know it you're done. I think one think to talk about is "voice" - we could go for something very dry and technical, or somewhat more lighthearted, or even something a bit zany. I think my take is that some kind of middle ground is good, but it would be nice to have some "character" to the rationale's, and to let them be a little bit opionated in places ("almost no-one enables this rule").
So I think I kind of see "Why should I care about this rule/how should I get the most out of it", together with a bit more of a narrative explanation of what it actually is - sometimes the examples can be a little obtuse.
Yep - I think it would be great to have something more formal for config options. It's kind of a pain, because we probably have a lot, and someone has to write the text (see rationale's), but we could definitely do a better job of explaining what individual options do. I think mentions of config options in rationale's are of the kind - "this option is one that you might want to use" rather than documenting the config options per se.
My kind of tacky solution was
So strip "```" for the Terminal and add I think the Terminal case is harder. Adding |
Oh, perfect. Happy to learn you like writing documentation. 😉
I think all these styles are fine. And maybe even a mixture makes them interesting for readers. One consistent style throughout the whole set of rules is anyway almost impossible.
The thing is that without using Markdown, there is no good way to use different text styles and add links to other rules or further references. For the terminal output, all the styling modifiers could be removed afterwards.
Important is that it allows to choose other languages as well. |
Source/SwiftLintBuiltInRules/Rules/Idiomatic/AnonymousArgumentInMultilineClosureRule.swift
Outdated
Show resolved
Hide resolved
:-)
I hadn't thought of it like that, but actually I think that is absolutely the best approach. Nothing too prescriptive, and then we can catch anything that goes too far off-piste, or lacks clarity in individual CR. I think comprehensibility to English as a second language speakers is important, so probably we wouldn't want rationale's in Yorkshire Dialect or Runyonese, sadly.
Any tips for how you think we should go about the styling modifiers stripping? Not entirely keen on having a markdown parser just so that I can de-markdown it :-)
So the intention is to ignore any language code that's present, as an override. |
2db6532
to
7370528
Compare
7370528
to
72177c2
Compare
Fully support that, especially the last part! 🫣
Well, there is swiftlang/swift-markdown from Apple which I had been playing around with a little at that time. A new dependency should be well thought of. As these rationales are going to provide such a huge benefit, that would be justified though I guess. Apart from removing any Markdown styling, it would also allow SwiftLint to check that the whole text is actually valid Markdown before rendering the docs in the build. On the other hand, even unrendered Markdown is so well readable, that I wouldn't complain if we just print the text as is into the console (keeping also URLs). There are also console rendering tools available that could be used to prettify the output. That, however, oughtn't be SwiftLint's job then.
👍 |
c53b70e
to
6ec46a0
Compare
6ec46a0
to
1954f36
Compare
132d531
to
1d9eaf6
Compare
cfe760a
to
a5087ac
Compare
Are these CI failures something that I'm doing @SimplyDanny ? - https://buildkite.com/swiftlint/swiftlint/builds/8753 - they all seem to be concurrency related, but it feels like they come and go at random |
They fail randomly. It's annoying. A retrigger normally helps. I hope this gets fixed by having strict concurrency checking always on by default. But until then there's still a long way to go. Optionally, we can disable warnings reported as errors in Bazel builds for the time being. |
It feel like mine always fail :-) Apart from pushing an empty commit, is there a better way to retrigger them? |
4f6079b
to
3f4bbe9
Compare
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.
We can also merge this piece by piece. Every new rational improves the rule. No need to wait for all rules being updated.
Source/SwiftLintBuiltInRules/Rules/Lint/BlanketDisableCommandRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/BlanketDisableCommandRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Lint/ClassDelegateProtocolRule.swift
Outdated
Show resolved
Hide resolved
for variables and imports. | ||
|
||
The `attributes_with_arguments_always_on_line_above`, `always_on_same_line`, and `always_on_line_above` \ | ||
configuration parameters can be used to fine-tune the rules behaviour for particular attributes. |
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 recommend not mentioning options in the rationale and rather plan to add dedicated rationals to the configuration elements.
rationale: """ | ||
See https://ericasadun.com/2016/10/02/quick-style-survey/ for discussion. | ||
|
||
Summarizing here: "[Erica Sadun's] take on things after the poll and after talking directly with a number of \ |
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.
You could make use of quotes here like so:
Erica Sadun says:
> My name is Erica.
return line + "swift" | ||
} | ||
} | ||
} |
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 we make this duplicated piece reusable somehow?
3f4bbe9
to
eb9cef8
Compare
eb9cef8
to
33c9ddc
Compare
Using the Copilot to craft rule descriptions is a very good idea. This can reduce the effort a lot. 👍 For coding in SwiftLint it's often not very helpful unfortunately. |
Co-authored-by: Danny Mösch <[email protected]>
37706c8
to
a1c8384
Compare
Addresses #4811
The idea is to add a longer explanation of the purpose or motivation behind each rule.
You can now see the output via
swiftlint rules rule_name
For example
And when rendered via Jazzy: