Commit Graph

119 Commits

Author SHA1 Message Date
Danny Mösch c1b74cd752 Rename test classes (#4083) 2022-08-11 07:33:11 +02:00
JP Simard fe652e8c8a Update Makefile to drop support for Swift 5.5 2022-07-26 09:45:16 -04:00
Juozas Valančius a28516d5e8 Create .artifactbundle during release 2022-03-31 09:52:22 -04:00
JP Simard 91b58c6cbe Strip binary when building for release
Shaves ~32% off the binary size.

Brings the universal fat binary on macOS from 86MB to 58MB.
2022-03-18 20:43:55 -04:00
JP Simard 21bb280068 Build additional Docker image with Swift 5.5 (#3904)
* Build additional Docker image with Swift 5.5
* Build `swiftlint_linux_swift_5_5.zip`
2022-03-17 17:27:05 -04:00
JP Simard ca2712aaee Make linux zip from GitHub's remote Docker image
Locally I had trouble building the image on both my previous Intel MacBook Pro
and my new M1 Max MacBook Pro.
2022-03-16 11:05:09 -04:00
JP Simard 92e199649d Fix make package command (#3890) 2022-03-10 20:00:49 -05:00
JP Simard ebaa6d2182 Add workaround for https://github.com/CocoaPods/CocoaPods/issues/11185 2022-03-08 16:33:17 -05:00
JP Simard 0f3de846d8 push to HEAD in make push_version 2022-03-08 16:18:20 -05:00
JP Simard a43e52aa91 Integrate Swift Syntax in the force_cast rule (#3867)
We've tried adding Swift Syntax support to SwiftLint in the past but had to turn it off in https://github.com/realm/SwiftLint/pull/3107 due to distribution and portability issues.

With https://github.com/keith/StaticInternalSwiftSyntaxParser it should be possible to avoid those issues by statically linking the internal Swift syntax parser so it's available no matter where users have Xcode installed on their computer.

By removing all calls to SourceKit (collecting comment commands + checking the current Swift version), there's a really significant performance improvement.

| Framework | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| SourceKit | 517.8 ± 8.3 | 505.5 | 531.1 | 6.59 ± 0.43 |
| SwiftSyntax | 78.6 ± 5.0 | 72.6 | 92.1 | 1.00 |

In practice, the SourceKit overhead will continue being there for as long as any rule being run is still looking up the SwiftLint syntax map though.
2022-03-07 12:51:24 -05:00
JP Simard be1f8596e4 Require Swift 5.5 to build SwiftLint (#3869)
* Disable Swift 5.4 CI jobs
* Remove SwiftLintFramework podspec
  I couldn't find a single use in GitHub's search: https://github.com/search?q=SwiftLintFramework+filename%3APodfile+language%3ARuby+language%3ARuby&type=Code
  Just not worth maintaining anymore.
* Change package swift tools version to 5.5
* Update docker_test to use Swift 5.5 image
* Clean up old Swift versions in SwiftVersionTests
  Even though these older Swift versions should still be supported, these tests
  can't be built against those versions so they're useless.
* Run docker commands with `--platform linux/amd64`
* Remove LinuxMain
  It looks like tests are discovered dynamically on Linux as of recent
  SwiftPM versions.
2022-03-07 12:15:03 -05:00
JP Simard 6ce4766517 Fix pkg installer (#3817) 2022-01-24 18:26:52 +00:00
JP Simard 4d3217f959 Run CI with Xcode 13 & Swift 5.5 (#3711)
Currently Xcode 13 beta 5, will switch to GM when available.
2021-09-10 09:24:39 -07:00
JP Simard 888619912f Run CI with Xcode 12.5.1 & Swift 5.4 (#3710)
And require Swift 5.4 or Xcode 12.5 or later to build SwiftLint.
2021-09-10 08:32:02 -07:00
Norio Nomura a84aee23df [Makefile] Update zip_linux target to depending Dockerfile
Hiding dependencies required at build time in the Dockerfile
2020-12-05 00:25:42 +09:00
JP Simard be21dc3b4b Add scrip/get-version script
Previous way wasn't working and this way we edit one less file when
pushing new versions.
2020-11-23 11:15:52 -05:00
JP Simard f45f381320 fixup! Remove Info.plist files 2020-11-20 15:25:50 -05:00
Norio Nomura 88d77a3211 [Makefile] Build swiftlint as a universal binary on macOS
SwiftPM 5.3 uses the `XCBuild.framework` to generate universal binaries when it receives multiple `--arch` options.
In that case, `--show-bin-path` returns `.build/apple/Products/Release`.
2020-11-19 18:48:11 +09:00
Norio Nomura 97052faf18 Use -static-stdlib on building Linux binary for release artifacts
This change prevents `swiftlint` from having links to shared libraries belonging to `/usr/lib/swift`.
```
$ docker run -v$PWD:$PWD -w$PWD --rm swift sh -c 'ldd $(swift build -c release --show-bin-path)/swiftlint'
	linux-vdso.so.1 (0x00007ffee8bb8000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f75e750b000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f75e7308000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f75e7104000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f75e6d66000)
	libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f75e69a5000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f75e661c000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f75e6404000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f75e6013000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f75ea7bf000)
	libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f75e5c5b000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f75e5a3e000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f75e5818000)
	libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f75e3c6f000)
```
I confirmed that `swiftlint` produced by `make zip_linux` works with following docker images:
- swift:5.3.1-xenial
- swift:5.3.1-bionic
- swift:5.3.1-focal
- swift:5.3.1-centos8
- swift:5.3.1-amazonlinux2
- norionomura/swift:5.3.1
- norionomura/swift:5.3.0
- norionomura/swift:5.2.5
- norionomura/swift:5.1.5
- norionomura/swift:5.0.3
2020-11-18 21:39:31 +09:00
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