Add legacy_uigraphics_functions rule#6269
Conversation
Generated by 🚫 Danger |
|
I wasn't actually aware of Edit: I remove the helper in #6271 so that visitor and rewrite can directly be used. |
|
I have created an analyzer rule that reports all uses of any deprecated declarations (marked with The types mentioned in this PR all seem like they should be detectable by my analyzer rule. I used AI to create it, as I don't know SourceKitten, SourceKit, SwiftLint APIs, etc. I am cleaning up the code now, and will try to learn SourceKitten, etc. by reading the code. Once it's cleaned up, would you review it? If so, I assume I should make a new issue for it (as I haven't found an existing one), and move this discussion to that issue. Would it supersede this rule? What configuration options would you prefer? What names would you prefer be used? e.g., should it be the I assume it would be helpful to filter out deprecated uses where the replacement is not available for the current project (e.g., based on the minimum supported platform versions), but I haven't determined if it's easy to obtain that info. If such filtering were provided, should the rule be able to read the minimum platform versions from a Should there be some way to globally ignore uses of specified declarations? If so, should they be specified via strings like "URL.init(fileURLWithPath:isDirectory:)"? Should the rule try to detect the replacement declaration, and output its details in the violation message (I assume it will be too difficult to apply fixes via Should the rule detect deprecated declarations via additional mechanisms? e.g., should it support manual replacement mappings (e.g., Etc. |
Both rules (and more existing ones) can live side by side. As Analyzer rules run very slow, the syntax-based rules are faster alternatives that might be sufficient for some/most users. Let's chat about the other questions you have in the PR that you are about to create. A dedicated issue is not needed. 😉 |
|
Will do. I will create a draft PR later today if you want to look over the code before I have a chance to completely understand SourceKit & ensure that the PR is up to snuff. I'll update the code & switch to a normal PR once I've had the chance to completely look through it all. I'll also keep everything barebones to get feedback first, then add bells & whistles once everything has been discussed. |
|
FYI: the AI code was worse than I expected. I need to completely redo most of it, and to research beforehand. I will get back to it in a bit, then submit a PR once it's much better. |
90f71ca to
0f65858
Compare
0f65858 to
6105e44
Compare
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
6105e44 to
d0539eb
Compare
Add new
legacy_uigraphics_functionsrule to encourage the use of modern UIGraphicsImageRenderer instead of legacy UIGraphics{Begin|End}ImageContext.The modern replacement is safer, cleaner, Retina-aware and more performant.
The legacy API is deprecated
Resolves #6268