100 Commits
Author SHA1 Message Date
JP Simard 76708d88f7 Remove Xcode project & Drop Carthage Support
Xcode has supported Swift Package Manager projects natively since Xcode
11, which has been out for over a year, where you can use Xcode by
having it open the `Package.swift` manifest rather than a `.xcodeproj`
or `.xcworkspace`.

I've been primarily developing SwiftLint in Xcode using this approach
for over a year, and despite a few nitpicks I have, it's been a joy to
use.

So I'd like to completely remove the Xcode project along with things
that support it:

* `SwiftLint.xcworkspace`/`SwiftLint.xcodeproj`: Neither of these are
  needed if we use `xed .` or `xed Package.swift` to develop SwiftLint
  in Xcode.
* `Cartfile`/`Cartfile.private`/`Cartfile.resolved`/`.gitmodules`/`Carthage/`:
  These were used to manage dependencies as git submodules for use in
  the Xcode workspace, but that's no longer necessary if Xcode delegates
  to SwiftPM to manage dependencies for us.
* Some scripts can be simplified, cleaned up or even completely removed.

* **Reduce duplication:** Rather than update dependencies or files in
  multiples places, there will only be the package manifest and the
  Podfile
* **Reduce merge conflicts:** This hasn't been too bad, but it's
  occasionally a pain when trying to land old PRs
* **Reduce development overhead:** No need to manually make sure that
  files in the Xcode project are sorted alphabetically
* **Reduce clone time:** No need to run
  `git submodules update --init --recursive` anymore

I think this breaks Carthage users that pull in SwiftLintFramework as a
dependency in a Cartfile.

However I can't find any references to [`SwiftLintFramework` in any
`Cartfile` files on GitHub](https://github.com/search?q=swiftlintframework+filename%3ACartfile&type=Code&ref=advsearch&l=&l=)
so this doesn't appear to be worth continuing to maintain.

Resolves https://github.com/realm/SwiftLint/issues/3412
2020-11-08 13:32:07 -05:00
Dalton Claybrook d305e03905 Add inclusive_language rule (#3243)
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
2020-11-07 22:03:08 -05:00
JP Simard 59d6c2ef52 Test CI with official Swift 5.3 release (#3356) 2020-09-20 11:16:10 -04:00
JP Simard d0d9ad575f Add Linux binary to release artifacts
There are a lot of libraries dynamically linked, so it's unlikely to
work in most places other than the same Docker image used to build the
binary (latest official Swift Docker image).

It might still be useful if you can guarantee that you'll use this from
that image.

    ldd .build/release/swiftlint
      linux-vdso.so.1 (0x00007fff38db5000)
      libswiftCore.so => /usr/lib/swift/linux/libswiftCore.so (0x00007f11503cd000)
      libFoundation.so => /usr/lib/swift/linux/libFoundation.so (0x00007f114fba6000)
      libswiftGlibc.so => /usr/lib/swift/linux/libswiftGlibc.so (0x00007f1151264000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f114f987000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f114f784000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f114f580000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f114f1e2000)
      libswiftDispatch.so => /usr/lib/swift/linux/libswiftDispatch.so (0x00007f115122b000)
      libdispatch.so => /usr/lib/swift/linux/libdispatch.so (0x00007f114ef82000)
      libBlocksRuntime.so => /usr/lib/swift/linux/libBlocksRuntime.so (0x00007f114ed7f000)
      libFoundationXML.so => /usr/lib/swift/linux/libFoundationXML.so (0x00007f11511d2000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f114e98e000)
      libicui18nswift.so.65 => /usr/lib/swift/linux/libicui18nswift.so.65 (0x00007f114e463000)
      libicuucswift.so.65 => /usr/lib/swift/linux/libicuucswift.so.65 (0x00007f114e062000)
      libicudataswift.so.65 => /usr/lib/swift/linux/libicudataswift.so.65 (0x00007f114c3b3000)
      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f114c02a000)
      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f114be12000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f1151053000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f114bc0a000)
      libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f114b849000)
      libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f114b491000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f114b274000)
      liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f114b04e000)
      libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f11494a5000)
2020-09-02 15:33:46 -04:00
Ilias Karim a91c987552 Update Makefile with Swift 5.2.4 image 2020-06-18 14:51:45 -05:00
JP Simard d2643db495 [Docs] Build docs using jazzy (#3016)
* Add `.jazzy.yaml` configuration file
* Update `swiftlint generate-docs` to write docs to a directory rather than a single file
* Add jazzy to the Gemfile
* Run `bundle update`
* Add CI job to run jazzy automatically and publish to GitHub Pages

![swiftlint-jazzy](https://user-images.githubusercontent.com/474794/71799038-fcf4e180-3008-11ea-81fa-3eb9cf296506.gif)
2020-01-07 20:31:29 -08:00
Marcelo Fabri b695c696f9 Update make docker_test 2019-10-08 23:55:48 -07:00
Kyle Fleming 83541eeb80 Fix broken link in Makefile (#2826) 2019-07-26 20:18:48 -07:00
JP Simard e63e8cad0f Add UnusedDeclarationRule (#2814)
This PR adds a new `unused_declaration` analyzer rule to lint for unused declarations.
By default, detects unused `fileprivate`, `private` and `internal` declarations.
Configure the rule with `include_public_and_open: true` to also detect unused `public` and `open` declarations.

Completely remove the `unused_private_declaration` rule.

This is built on the work enabling collecting rule infrastructure in https://github.com/realm/SwiftLint/pull/2714.
2019-07-18 18:23:43 -07:00
JP Simard acfc592ee0 Mark Swift 5 as supported (#2730)
* Mark Swift 5 as supported

* Only set a single Swift version on podspec

Multiple swift versions requires CocoaPods 1.7.0, which is still
in beta.

* Modernize ruby hash syntax

* Update SourceKitten to 0.23.1
2019-04-29 11:55:16 -07:00
Norio Nomura 398733afa4 [Makefile] Avoid using -Xswiftc -static-stdlib if toolchain does not have usr/lib/swift_static directory
This is required on building with Xcode 10.2, because Xcode 10.2’s toolchain does not have `usr/lib/swift_static` directory.
2019-03-20 19:26:59 +09:00
JP Simard e6ff3521c8 Run analyze on CI with --strict (#2524)
and whitelist two intentional violations
2018-12-23 18:22:41 -08:00
JP Simard 827410a4cd Remove BoolExtensionTests from LinuxMain.swift 2018-11-27 11:41:14 -08:00
JP Simard 5901d3075f Require Swift 4.2 (#2466)
This bumps the minimum version required to build SwiftLint to 4.2. The primary motivating factor to drop support for Swift 4.0-4.1.x is that SwiftLint now uses CryptoSwift, which requires 4.2.

* Add changelog entry

* Remove --allow-warnings flag from CocoaPods commands

* Update CryptoSwift to 0.13.0

* Migrate to Swift 4.2

* Remove CircleCI tests for Swift < 4.2

* Update English and Chinese README

Korean README doesn't yet have a version table like this.

* Update gems

* Add changelog entry for fixed compiler warnings

* Update CocoaPods to 1.6.0.beta.2

To work around https://github.com/CocoaPods/CocoaPods/issues/7708
2018-11-18 17:32:25 -08:00
JP Simard d768897f1d Improve performance of collecting files to lint and lint cache lookups (#2465)
Performance has gotten pretty bad for complex SwiftLint configurations like the one used for Lyft's iOS code base involving lots of files in the directories being linted, large configuration files and many nested configuration files.

Two main areas were particularly ripe for improvement were:

1. Collecting which files to lint
2. Lint cache lookups

### Collecting which files to lint

Improve this by:

* using an NSOrderedSet to remove excluded paths instead of `Array.filter`
* parallelizing calls to `filesToLint` for all paths to lint and exclude
* using `FileManager.subpaths(atPath:)` instead of `enumerator(atPath:)`

|Change|Before|After|Speed up|
|-|-|-|-|
|NSOrderedSet|2.438s|0.917s|2.659x|
|Parallel Flat Map|2.438s|2.248s|1.085x|
|Subpaths|0.939s|0.867s|1.083x|
|**Total**|**2.438s**|**0.720s**|**3.386x**|

### Lint cache lookups

By using an MD5 hash of the Configuration description from CryptoSwift as the cache key instead of instead the full description, we can drastically speed up cache lookups for projects with complex SwiftLint configurations. I think the dictionary lookup for very large string keys doesn't perform very well.

---

* Speed up Configuration.lintablePaths

* Improve cache lookup performance by up to 10x

By using an MD5 hash of the Configuration description from CryptoSwift
as the cache key instead of instead the full description.

* Add changelog entries

* Swift 4.0 & Linux compatibility

* os(Darwin) isn't a thing

* Allow warnings in pod lib lint

SwiftLint supports building with Swift 4.0 to 4.2.

There is no version of CryptoSwift to support both Swift 4.0 and
Swift 4.2.

So allow warnings for now. We'll make one more Swift 4.0 compatible
release, then we'll bump the build requirements to Swift 4.2 and
remove the `--allow-warnings` flag.
2018-11-18 14:39:02 -08:00
JP Simard 30808b154d Publish with Swift 4.2 2018-11-13 23:13:16 -08:00
JP Simard 6cea034355 Analyze SwiftLint on CI (#2387)
* Enable analyzer_rules in .swiftlint.yml

* Add analyze and analyze_autocorrect commands to Makefile

* Run `swiftlint analyze` on CI

* Run make bootstrap before make analyze
2018-09-04 08:55:07 -07:00
JP Simard 687c6a7549 Fix make sourcery
* Invoke correct make job for `AutomaticRuleTests`
* Generate `LinuxMain` last so that it can include tests from
  AutomaticRuleTests
2018-08-31 15:38:46 -07:00
JP Simard 5da6115a6c Fix sourcery path glob for rules 2018-08-06 10:56:16 -07:00
Marcelo Fabri e0adb6e5f3 Check if git status is clean before releasing
Fixes #2327
2018-08-04 15:04:03 -07:00
Marcelo Fabri 8aadb802fb Split RulesTests into several test cases, generating them automatically 2018-07-21 17:23:08 -07:00
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00
Norio Nomura 98029f80c3 Add test_tsan target to Makefile 2018-04-09 10:14:54 +09:00
Norio Nomura 3bde4c9756 Add build to .PHONY in Makefile
This will make `make` not to be misled by the existence of `build` directory.
2017-12-30 12:40:57 +09:00
Norio Nomura 76031b6321 Add stencil to dependency of each sourcery targets 2017-11-28 08:21:45 +09:00
Norio Nomura 40c2eb2c4d Separate sourcery target into MasterRuleList.swift and LinuxMain.swift
Also set dependencies on each targets.
2017-11-25 22:33:32 +09:00
Norio Nomura 72b8dec683 Use -static-stdlib only when building on Darwin
This makes `make install` possible on Linux.
2017-11-19 12:43:00 +09:00
Norio Nomura 7d1b4016a7 Use SWIFTLINT_EXECUTABLE 2017-11-17 14:02:36 +09:00
Norio Nomura 69b2276e18 Remove unused variables 2017-11-17 13:57:59 +09:00
Norio Nomura 4ca2665556 Stop removing test bundle before docker_test
It became unnecessary in Swift 4.0.
2017-11-17 13:57:50 +09:00
Norio Nomura 224f44e41d Refactor Makefile
Change `all` target to execute `swift build` instead of `xcodebuild`.
2017-11-17 13:53:29 +09:00
Norio Nomura 745fc9505d Create destination directory by install -d 2017-11-17 11:47:12 +09:00
Norio Nomura 1ca05477e6 Use --disable-sandbox in prefix_install used by Homebrew
Homebrew uses sandbox on building bottle.
2017-11-17 11:22:01 +09:00
Norio Nomura 2fef26eabd Add destination path as argument of install for compatibility with Linux 2017-11-17 11:15:18 +09:00
Norio Nomura 4cc2bf37b1 Apply workaround for https://github.com/apple/swift-package-manager/pull/1320 2017-11-17 11:06:50 +09:00
Norio Nomura adf58cf08c Remove uninstall and package dependencies from install
It will be more desirable behavior when `make install` on Linux.
2017-11-17 10:52:33 +09:00
Norio Nomura 67a8fc3c78 Use SwiftPM to build installables 2017-11-17 09:53:28 +09:00
JP Simard 6428297814 Fix pod trunk push by passing --swift-version=4.0 2017-11-10 15:58:21 -08:00
Marcelo Fabri ee02e0f8e5 Remove support for building with Swift 3.1 2017-10-04 13:48:17 -07:00
JP Simard c5521292c1 Update Swift 4 docker image to Swift 4.0 release 2017-10-04 13:14:52 -07:00
JP Simard 9dc7ab7b9a Run tests in parallel 2017-10-04 11:54:49 -07:00
JP Simard 53baff5bca Add docker_test_4 command to Makefile 2017-09-10 13:48:38 -07:00
JP Simard 6712b5488d Merge pull request #1592 from realm/jp-sourcery-master-rule-list
Use Sourcery to generate LinuxMain.swift & MasterRuleList.swift
2017-06-02 15:02:44 -07:00
JP Simard 90ee3d377b fix make docker_test failure after running SwiftPM on Darwin
SwiftPM on Darwin produces a `.xctest` _bundle_ (i.e. folder).
SwiftPM on Linux produces a `.xctest` _binary_ (i.e. file).

SwitPM on Linux exits unsuccessfully if it finds a folder at the `.xctest` location.

```
$ make docker_test
...
Linking ./.build/debug/SwiftLintPackageTests.xctest
/usr/bin/ld.gold: fatal error: ./.build/debug/SwiftLintPackageTests.xctest: open: Is a directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
swift-test: error: exit(1): /usr/bin/swift-build-tool -f .build/debug.yaml test
make: *** [docker_test] Error 1
```

This change detects this scenario and pre-emptively deletes the `.xctest` folder if it exists.
2017-06-02 14:39:02 -07:00
JP Simard f1417da079 preserve Sourcery comment header in make sourcery 2017-06-02 14:28:37 -07:00
JP Simard 9a81734081 use Sourcery to generate MasterRuleList.swift 2017-06-02 14:28:37 -07:00
JP Simard 25a92c4e03 automatically generate LinuxMain.swift using Sourcery
This adds 6 tests that were accidentally not being run on Linux:

* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresComments
* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresFunctionDeclarations
* LineLengthConfigurationTests.testLineLengthConfigurationThrowsOnBadConfigValues
* LineLengthRuleTests.testLineLengthWithIgnoreCommentsEnabled
* LineLengthRuleTests.testLineLengthWithIgnoreFunctionDeclarationsEnabled
* RegionTests.testSeveralRegionsFromSeveralCommands
2017-06-02 14:28:37 -07:00
JP Simard 0968cf4702 call reset if docker_htop exits unsuccessfully
fixes #1570. From Stack Overflow: https://stackoverflow.com/a/44191071/373262
2017-05-25 16:11:08 -07:00
JP Simard c40fe7c21d commit changes before pushing & tagging 2017-05-22 14:08:17 -07:00
JP Simard e54eeef17e Add make push_version command.
Update 'Master' header with new version & name in CHANGELOG,
commit, tag & push.
2017-05-22 14:05:24 -07:00