realm / SwiftLint

A tool to enforce Swift style and conventions.
https://realm.github.io/SwiftLint
MIT License
18.7k stars 2.23k forks source link

Plans for Swift 3 #816

Closed cfilipov closed 7 years ago

cfilipov commented 8 years ago

I searched and found a number of issues that mention Swift 3, but nothing specifically about this project as a whole, forgive me if this has already been brought up. A recent comment on #781 has got me thinking about Swift 3 support and how it will work with SwiftLint.

  1. Are there plans to update this project to Swift 3 (the source code itself)?
    1. Of course this requires the dependencies be updated.
    2. Is this even necessary for linting Swift 3 code? I assume yes.
  2. Can/will SwiftLint handle multiple versions of Swift?
    1. It's likely people will have multiple projects at various stages of migration, but only a single installation of SwiftLint.
    2. One option would be for Swift 2.x SwiftLint to ignore Swift 3.x and Swift 3.x SwiftLint to treat all Swift 2.x as a rule violation (now that Swift 3 is released).
    3. Although the majority of breaking changes are behind us, there is still the possibility that new versions of Swift can introduce or remove features that result in lint errors. It would be helpful if SwiftLint had at least some rudimentary handling of multiple Swift versions.
  3. What happens when the current version of SwiftLint is run on a Swift 3 project? False positives? Does it know to ignore these files?

I think these things should be mentioned in the README. I am particularly concerned about those of us who have SwiftLint as part of their CI process and using it in git hooks. Once people start updating their projects to Swift 3 or updating to a new SwiftLint with older projects things should be handled as gracefully as possible.

Reedyuk commented 8 years ago

I think it makes sense that the .swiftlint file, determines the version of swift the project is using, that way it would work fine on CI's.

norio-nomura commented 8 years ago

SourceKitten can use sourcekitd.framework from Swift toolchains both of 2.x and 3.0. So basically, we don't need migrating SwiftLint itself to Swift 3.0 for supporting lints codes written in Swift 3.0.

norio-nomura commented 8 years ago

But, we may need to create testing method on both of Swift 2.x and Swift 3.0, if we would support both of them. If we would not support both of Swift 2.x and 3.0 simultaneously, users who needs both of them may be required to install multiple version of SwiftLint.

cfilipov commented 8 years ago

So you are saying each rule could support multiple versions of Swift by implementing validateSwift2_2File, validateSwift2_3File, validateSwift3_0Fileetc..?

norio-nomura commented 8 years ago

Yes. We can detect version of Swift by using such as #703, and run rules selected by that.

I guess we would be able to support versions of Swift that supported by single Xcode version, e.g. Swift 2.3 and 3.0 on Xcode 8.

SerenadeX commented 8 years ago

One issue I am having is updating an existing installation of SwiftLint while Xcode 8 is installed. It won't work with brew as it has to compile it after cloning it down. Any plans on making it work in at least Swift 2.3 so it can compile on install with Xcode 8?

norio-nomura commented 8 years ago

master branch is compatible with swift 2.3, but not yet released. On Sierra with Xcode 8, please try brew install --HEAD swiftlint for installing SwiftLint.

alak commented 8 years ago

any news about swift 3 support ?

norio-nomura commented 8 years ago

I think most rules are compatible with Swift 3 other than missing_docs and valid_docs. Migrating SwiftLint itself to Swift 3 is tracking on https://github.com/realm/SwiftLint/pull/832

jpsim commented 8 years ago

One thing to keep in mind is that the version of Swift used to build SwiftLint does not impact which versions of Swift can be linted or corrected by SwiftLint.

That's because SourceKit is dynamically found and linked at runtime, based on a hierarchy of search locations (see How is SourceKit resolved?).

SourceKit's API is fairly stable in practice, which makes it possible for a version of SwiftLint compiled with Swift 2.x to successfully lint or correct a codebase written with Swift 3.0.

However, Apple makes no guarantees about this and reserves the right to change things drastically with no warning or reason.

There are rare times where SourceKit does change in ways that affect SwiftLint, the removal of the __raw_doc_comment attribute (#728/SR-2487) comes to mind as an example of this.

So when @Alak asks "any news about swift 3 support ?", well SwiftLint has supported it automatically as soon as the Swift 3 betas came out.

If there are specific issues with Swift 3 (such as #728), we ask that you be diligent about thoroughly reporting these as GitHub Issues, which we'll then be able to address on an individual basis.

alak commented 8 years ago

Great answer, I will try it next week :). Thank you

Le sam. 26 nov. 2016 à 00:01, JP Simard notifications@github.com a écrit :

One thing to keep in mind is that the version of Swift used to build SwiftLint does not impact which versions of Swift can be linted or corrected by SwiftLint.

That's because SourceKit is dynamically found and linked at runtime, based on a hierarchy of search locations (see How is SourceKit resolved? https://github.com/jpsim/SourceKitten#how-is-sourcekit-resolved).

SourceKit's API is fairly stable in practice, which makes it possible for a version of SwiftLint compiled with Swift 2.x to successfully lint or correct a codebase written with Swift 3.0.

However, Apple makes no guarantees about this and reserves the right to change things drastically with no warning or reason.

There are rare times where SourceKit does change in ways that affect SwiftLint, the removal of the __raw_doc_comment attribute (#728 https://github.com/realm/SwiftLint/issues/728/SR-2487 https://bugs.swift.org/browse/SR-2487) comes to mind as an example of this.

So when @Alak https://github.com/Alak asks "any news about swift 3 support ?", well SwiftLint has supported it automatically as soon as the Swift 3 betas came out.

If there are specific issues with Swift 3 (such as #728 https://github.com/realm/SwiftLint/issues/728), we ask that you be diligent about thoroughly reporting these as GitHub Issues, which we'll then be able to address on an individual basis.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/realm/SwiftLint/issues/816#issuecomment-263030753, or mute the thread https://github.com/notifications/unsubscribe-auth/ABIu6P8DQlTP19E9quTlowlrq8LOwtInks5rB2jMgaJpZM4J-Vn_ .

marcelofabri commented 7 years ago

Closing this now since SwiftLint was migrated to Swift 3 in #832 and there're specific issues for Swift 3 bugs/enhancements (such as #728).