-
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
Add Rules to Support Ray Wenderlich's Swift Style Guide #319
Comments
I'd love to try and help with as many of these as I can. Hopefully I'll be able to submit a pull request soon! Any recommendations on a simple rule to start with? Would any of these be a particularly good first rule for me to try and implement? |
For |
It may not be worth implementing "For Loops: Prefer the for-in style instead of the for-condition-increment style." There is an accepted proposal for Swift 3 that eliminates this style of https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md |
True, but on the other hand, if people writing Swift got a diagnostic for that with Swift 2.1.x, they might be more likely to adapt their code before 2.2 when the Swift compiler itself will have a deprecation diagnostic. |
From #319 CGGeometry: Prefer struct-scope constants CGRect.infinite, CGRect.null, etc. over global constants CGRectInfinite, CGRectNull, etc.
Is this still in progress? Let me know if I can contribute. |
@mattgabor still lots of low hanging fruit here! Feel free to implement any of the non-checked items in the initial comment here. |
@glennrfisher could you update the ones already done here? For findability we should probably split them up into each separate rule (making sure there are not duplicates out there already) |
related #57 |
"Function Names: Use camel case" and "Enumerations: Use upper camel case." is completed in pull request #954 |
I'd love to have this one:
Is there a way to easily distinguish between class inheritance and protocol conformance in a class declaration? If so, I assume this rule would simply check for the latter? |
@glennrfisher It would be cool to have a map between the Ray Wenderlich rule and the actual rule name for |
Maybe this is a bug, but this function passed without any validation error (should be caught be |
@myworkout-jenkins please open a new issue with more details (sample code, configuration file, SwiftLint version, etc) |
@marcelofabri I will, just wanted to get it confirmed wether it was a bug or not. I can provide a sample project setup etc. and post an issue if it indeed is a bug |
there's no way to say if it's a bug or not without a proper issue 😉 |
Color me on the side of using the Swift language documentation rules for containers, Array and Dictionary<keyType, valueType> -- the syntactic sugar version of [type] and [keyType: valueType] are nice shortcuts, but there are times that they cannot be used (some closures). |
@atlassian-gaustin I'm not aware of any cases where that rule is giving false positives. The only case that it's not allowed to use the syntactic sugar version (AFAIK) is using something like |
It's the compiler that occasionally barfs without using the "proper" definitions in those cases. The problem is that using the syntactic sugar everywhere BUT in those locations causes an inconsistency in the code between the definition and later usage. |
Can give me an example where the compiler rejects the syntactic sugar version? |
Trying to dig up places in my own code where the syntactic sugar version would fail, but I tend to use the full description in my initializers (e.g. |
I don't agree: you can use them almost in every case (and the rule won't trigger false positives). |
The problem is that you either have the rule disabled, or use syntactic sugar when it can be used but you can never have just the idiomatic rule enabled -- because there is no option for just the idiomatic rule. |
What do you mean by idiomatic rule? |
The non-syntactic-sugar version. With only "on" or "off" for syntactic-sugar, you either have "use syntactic sugar everywhere you can" or "mix syntactic sugar with idiomatic, we don't care". You can never have "only use idiomatic form".
There needs to be a "third state" for container types. As I envision it:
|
@atlassian-gaustin I'd rather make that another (opt-in) rule. Can you open another issue to discuss it? |
They are linked -- what would the result be if both were set to on? |
Guys, is it work in progress. I see that some list items were marked as completed [x] but know associated commits in this Issue. How are things looks like on this day? |
sorry, but how is the indentation configuration supposed to work? release 0.24.1: Dented Tumbler says: Indentation can now be specified via a configuration file. But where is the doc that says how to use it? |
You can set an indentation: 4 # 4 spaces
indentation: 2 # 2 spaces
indentation: tabs # tabs It'd be a great starter task to add this to the sample configuration in the readme.! |
Is this issue still relevant? |
There are still valid open points. I haven't checked if there are dedicated issues for these points already. It would be better to track them in separate tickets. |
It would be great if SwiftLint supported Ray Wenderlich's Swift Style Guide:
Double
instead ofNSNumber
).let
instead ofvar
if the value of the variable will not change. Supported by compiler.optionalString
ormaybeView
, since optionalness is already captured in the variable's type. (Prefer using the same name:if let subview = subview { ... }
.)let bounds = CGRect(...)
instead oflet bounds = CGRectMake(...)
).CGRect.infinite
,CGRect.null
, etc. over global constantsCGRectInfinite
,CGRectNull
, etc.var deviceModels: [String]
) instead of the full generics syntax (var deviceModels: Array<String>
).for-in
style instead of thefor-condition-increment
style.Probably Not Worth It
let message: String = "Click the button."
). -> There are probably many valid reasons to break this rule.self
except when required by the compiler or for disambiguating property names from arguments. -> This seems very difficult to verify.function_body_length
rule._
for unnamed parameters. -> Not worthing trying to style-check comments.The text was updated successfully, but these errors were encountered: