-
Notifications
You must be signed in to change notification settings - Fork 212
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
Swiftlint #128
Swiftlint #128
Conversation
5e95dc0
to
bfda8b5
Compare
bfda8b5
to
edfa2e6
Compare
edfa2e6
to
122edcb
Compare
observer.onCompleted() | ||
return Disposables.create() | ||
} | ||
public static func cascade<S: Sequence>(_ observables: S) -> Observable<T> where S.Iterator.Element == Element { |
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.
The big changes here is just spacing.
This seems to be the only file to use Tabs instead of Spaces, so changing one portion of the code made everything look strange, so I just re-indented it.
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.
The old tabs-vs-spaces war eh? Always been a tabs guy, never understood the purpose of spaces, as:
- some developers like to have 2, 3, 4 or 8 spaces indentation. Using a tab makes it flexible
- using tabs makes smaller files (yeah I know in this day and age, not important)
:)
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.
Well, it's not a war or anything. I just think people mostly use spaces, because it ensures the files look the same wherever you go.
I don't mind going one way or the other but then we need to see if we go the same everywhere. Otherwise, if you use tabs and someone who uses spaces edits your files, it will look very strange (like happened for me).
Good either way :)
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 remember that editors like Emacs and VIM support a comment indicator that tells whether a file uses spaces or tabs, and adjust accordingly. AppCode and all IntelliJ-derived IDEs have a setting to automatically detect what's being use. Is there anything we could do for Xcode ?
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.
Pray? :( 🙏
I also think the default setting is spaces so that could cause even more issues potentially.
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 trying to think if there's any good way to support either method but I don't have enough experience here TBH
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 trying to think if there's any good way to support either method
I think this defeats the purpose of avoiding such major diffs out of simple re-indent, correct?
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.
When I'm saying "a way to support either" - i mean without messing up the code on each commit 😛
Tests/RxSwift/nwiseTests.swift
Outdated
@@ -12,6 +12,7 @@ import RxSwift | |||
import RxSwiftExt | |||
import RxTest | |||
|
|||
// swiftlint:disable:next type_name |
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 made this an exception since, even though you usually want Capitalized class named, in this case nwise would read NwiseTests, and It seemed odd. Any opinions welcomed :)
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.
NWise
might look even more odd, but I'd prefer sticking to this rule in particular :)
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 mean NwiseTests
or nwiseTests
?
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.
NwiseTests
, but would suggest a second opinion as well :)
let underlying = scheduler.createHotObservable([ | ||
next(150, 1), | ||
next(210, 2), | ||
next(230, 3), | ||
next(301, 4), | ||
next(350, 5), | ||
next(399, 6), | ||
completed(500), | ||
completed(500) |
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.
why do we drop trailing commas? I believe it's configurable from SwiftLint
?
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.
Doesn't make sense have a trailing comma for an array ... It's like a sentence ending with a comma instead of a dot, don't you think ?
Also, it's not across all tests which is even weirder. I personally highly prefer (and seems like its the standard) to have commas between elements, but not with a trailing one
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.
Its main purpose is cleaner diffs in the future. I personally prefer them (and I don't believe there is a way to say they are not standard :D) but it's arguable of course ¯_(ツ)_/¯
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 don't think it makes much difference in diffs
And also - in the codebase itself (not tests), there are no trailing commas ... so how can we reason about trailing commas specifically in tests? What makes this special ?
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.
It does, no doubt :) so with a trailing comma it would look like;
next(50, "alpha"),
+ completed(50),
while without it will be
- next(50, "alpha")
+ next(50, "alpha"),
+ completed(50),
I'd say swiftlint is here to make it consistent across both codebase and tests. Again, this is a style preference so should be fine with any of them.
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.
Not really. Sometimes I'd leave trailing commas (i.e. if I'm in a rush) or while in the process of working on array items that I move around, removing the last trailing comma means more work to re-add it if I move it so ... well that's expert-level nitpicking.
The argument that I like is @mosamer 's reasoning about cleaner diffs. Looks like a win!
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.
Yup, Let me put those back in place :)
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.
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.
Don't think so. Can't we just allow them?
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.
Oh yeah, we can definitely allow :)
I just thought you want to retro-actively change. I'll just fix the rule. Thanks !
// provide simple predicate that always return true | ||
|
||
// provide simple predicate that always returns true |
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.
As other comments were modified to capitalize first word, shouldn't we modify this as well for sake of consistency.
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.
Yup, for sure - I just did it as I go, it wasn't a purpose of this PR :)
We can keep cleaning as part of this PR or as a separate one TBH.
.travis.yml
Outdated
before_script: | ||
- swiftlint |
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 not sure if this will have any effect for warning violations rules. What about removing in favor of Danger
integration once implemented?
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.
Yeah, that was the plan indeed :)
I just wanted something until we have Danger working and didn't want to have everything in a single PR.
122edcb
to
a3c7a48
Compare
Given the context of #127, I may suggest this PR -along with future ones- to be pointed to another branch than |
@mosamer This specific PR doesn't create any breaking changes so I don't think there is any reason to point it to a different branch. Do you mean like a develop branch? Since we don't have one right now. The parts of the list that are code-breaking would definitely need to be on a separate branch, but this specifically (like Danger) isn't really a code-breaking change (or a code change, at all 😋 ) |
I don't think any of the items on the list is going to introduce a code breaking change. However, the overall context is a major change I'd say. That's why I tend to prefer having that on a separate branch (as a staging environment) before fully committing to it. That said, I totally acknowledge that this specific PR is needed anyway in |
@mosamer I think specifically for non-code changes (e.g. this and Danger), master is fine. For the other code-related changed I'm going to make a separate branch linked to a milestone, probably. Sounds good to you ? |
All looks good here ! Gonna do Danger next, so we actually have something that uses this in PRs. |
type_body_length: 500 | ||
cyclomatic_complexity: | ||
warning: 15 | ||
error: 25 |
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.
Don't we need a trailing newline here? I'm surprised that swiftlint doesn't complain
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.
newline after what? the last line here?
Neh its YAML, no need :)
755283f
to
c6c2e35
Compare
Ok so three last changes:
This should be it for this PR :) Let me know if any other open points. |
c6c2e35
to
52dfeaa
Compare
Great work. Now I have to install Swiftlint 💯 |
Great job guys 👍 in relation to dangling commas I would enforce it because it creates a good habit. Actually I was against it at the beginning but now I found it useful. and FYI they use it in swift devs :I check this link and draw your conclusions. read also the comments 🌮 https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8 |
@bobgodwinx thanks for the feedback :) I don't think its a "Good habit" more like it is a preference. I also, in my own codebase, don't like having dangling commas. But I really don't it this way or the other, specifically for these multi-lined cases where it benefits the diffs. Let's see if this is abused in next PRs, and iterate 💯 |
@freak4pc no worries. The same topic also exploded the swift dev team :) just read their mailing list. FYI I am standing on the fence on this. But it's good to hear all options. http://ericasadun.com/2016/05/27/trailing-commas-open-source-and-community-participation/ |
@bobgodwinx Yeah I've read the last two before responding to @mosamer but those are about tuples, where it's really not as relevant. That was also the Rejection Rationale by Lattner. |
.swiftlint.yml
Outdated
@@ -3,6 +3,7 @@ included: | |||
- Tests | |||
disabled_rules: | |||
- line_length | |||
- trailing_comma |
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.
this disables the rule, so no checks are made. To mandate the use of a trailing comma on a multiline collections I think it should read as
trailing_comma:
mandatory_comma: true
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 think this is a bit towards the other extreme and I'm not sure that's a good choice 🤔
I'm in favor of not having the rule at all so you could have either with or without. There seems to be several that are opposed and several that are for, so I wouldn't say it's enough of a call it mandatory for everyone.
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.
never mind, i misunderstood earlier comments as opting-in for the use of trailing commas. Disabling the rule should be the best choice for now until we settle :)
52dfeaa
to
4d67ba3
Compare
This PR: