[IRL-10685] Make some suggested changes to style guide #195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I applied some of the feedback received on the test run of the Airbnb style guide to be reviewed.
How I addressed each feedback
I changed it to 120. I think its more important that we have a max, than what the max is.
I removed this entirely.
This is not automated, so I changed the wording in the README to reflect the feedback.
I think based on the existing wording, this already fits just fine, so I left it unchanged.
Yea, I agree, handle does work in many cases. None of the naming is automated so it can be taken as a strong suggestion :)
Totally agree, modified the wording to reflect this.
I left this in. My rationale is that in the case of properties, the type is always included on the right hand side of the declaration when it can be omitted from the left, so it is never ambiguous. I hope that's alright
I've done my best to modify the rule appropriately based on this feedback.
I actually disagree, but I don't mind much and went ahead and changed this to apply to range operators.
Yes, and this kind of style guide rule starts to creep into "best practices" recommendations. It is generally correct, but there could be exceptions. I don't think it is automated, either. We could leave it in as a guideline, or remove it entirely.
It does. I agree with the thrust-- reading through someone else's code to figure out what it is doing is much more difficult when we have to leave the context to follow a dependency chain to see what a closure is doing unnecessarily. There will always be times where this is required, but I think this is another case of a "mostly true guideline".
I think that's reasonable. This is a small concern for us now, it becomes much larger when you are dealing with a very large codebase (1m+ lines of swift) and access control begins to have a meaningful impact on build times. I still believe the thrust is correct, and we could argue that your exception still follows the wording of the rule. I added "for the intended usage" to the README.
If I understand correctly, you are saying that in these situations you write two enums, one for the API's data model and one for the client's, and some glue to convert between the two, thus making the external mapping explicit. I think that's a reasonable approach to solve the same problem, and modified the wording accordingly.
Yep, once you are switching over a combination this is untenable. I modified it to be specific to single enums.
I removed the guidance about the empty line (could not find an automated rule that was enforcing it). I think we'll keep preferring imports at the top of the file for now.
Properties don't always include scopes spanning multiple lines, and when they do I think it is generally fine to give them some spacing. I agree that single line declarations of properties should not have spaces between them, and I believe that is not the intent of this rule.
This is tough. I do not mind the extension method of grouping code, although I think it serves effectively the same purpose as a pragma mark. That said, SwiftFormat provides the tooling to automate adding pragma marks and not grouping things into extensions. Would you be okay with letting it group into pragma marks as described and letting the extension division be optional or preferred?
Also tough. As far as I could see, there is no way to customize the order of these. I have considered / argued about this particular order in the past and I'd be happy to discuss / justify it if that might help assuage your concerns. Apart from that, the question becomes: would you rather have an automatically enforced order, even if it isn't the exact order you'd have chosen yourself? Or would you forego the automatically enforced order for that reason. I prefer the former.
I didn't change anything related to this, I think you make a fair point, but contextual grouping isn't possible to automate in any way I can think of.
I think its helpful to quickly parse what amounts to the interface of a class or struct and what it is, i.e. I can see that there are 5 properties injected into it at initialization and two computed properties which are derived from X, Y, and Z almost at a glance if the order is set up like this.