Commit Graph

982 Commits

Author SHA1 Message Date
Chris Brakebill 9db303e3a3
Respect 'validates_start_with_lowercase' for function names in `identifier_name` rule (#4188) 2022-09-09 23:36:55 +02:00
Ryan Cole c34955ca64
Add `accessibility_trait_for_button` rule (#3989) 2022-09-06 21:44:09 +00:00
Marcelo Fabri c7c4e0a1f3
Rewrite `implicit_getter` rule with SwiftSyntax (#4160)
* Rewrite `implicit_getter` rule with SwiftSyntax

* Handle different reason messages

* Add changelog + implicit return
2022-09-05 01:28:25 -04:00
Marcelo Fabri c1650e6918
Add `excludes_trivial_init` for `missing_docs (#4152)
Fixes #4107
2022-09-03 22:11:57 -07:00
JP Simard 9979c4fd27
Add new `self_binding` opt-in rule (#4146)
To enforce that `self` identifiers are consistently re-bound to a common
identifier name.

Configure `bind_identifier` to the name you want to use.

Defaults to `self`.

Addresses https://github.com/realm/SwiftLint/issues/2495
2022-08-30 16:37:19 -04:00
JP Simard 83bf37e642
Add `SwiftLintFile.isTestFile` (#4122) 2022-08-23 12:04:30 -04:00
JP Simard e8f738b39c
Automate producing release tarballs for Bazel (#4113) 2022-08-19 17:26:21 +00:00
JP Simard 408ba29951
Integrate with rules_xcodeproj (#4095) 2022-08-15 16:22:47 -04:00
sarastro-nl d1a1485af6
enable glob for includePaths (#4093) 2022-08-15 13:54:49 +00:00
Danny Mösch c1b74cd752
Rename test classes (#4083) 2022-08-11 07:33:11 +02:00
Danny Mösch d730e0b3fa
Let all example verification tests be generated by Sourcery (#4076) 2022-08-10 22:49:28 +02:00
Danny Mösch 828f36958f
Introduce option to ignore indentation of compiler directives in `indentation_width` rule (#4066) 2022-08-10 21:52:32 +02:00
Sara Tavares f8e1b178d6
chore(typo): fix typo on test (#4078) 2022-08-10 13:36:03 -04:00
Danny Mösch 449190d324
Verify examples in rules by default and enforce explicit exclusion (#4065)
A rule must conform to ManuallyTestedExamplesRule to skip generation of a test for its examples.
2022-08-09 22:32:09 +02:00
JP Simard 8b8b3d0738
Run all tests with Bazel (#4067)
Other than the one test case that uses paths with spaces in them which
Bazel doesn't support.
2022-08-07 16:56:45 -04:00
JP Simard 0ded5859a1
Rewrite ColonRule with SwiftSyntax (#4063)
Making it about 7x faster, finding some previously missed cases.
2022-08-04 17:23:52 -04:00
Danny Mösch cdb87e3869
Verify all examples provided in rule descriptions (#4061) 2022-08-04 23:06:37 +02:00
Danny Mösch 54a8435479
Use specific failure messages in extended tests (#4058) 2022-07-31 14:45:47 +02:00
JP Simard 1dab8181b8
Fix bazel extra rules tests on Linux (#4056) 2022-07-29 19:34:54 +00:00
JP Simard 8b90623b38
[Bazel] Set up tests (#4055)
Run with `bazel test --spawn_strategy=standalone //Tests/...`

Consumers who define rules via `swiftlint_extra_rules` can run tests for
their custom rules too:

```
./bazelw test \
  --spawn_strategy=standalone \
  @SwiftLint//Tests:ExtraRulesTests
```
2022-07-28 19:14:03 +00:00
JP Simard 05ac3c9d75
Require macOS 12 & Swift 5.6 (#4037)
This will unblock using Swift Concurrency features and updating to the
latest versions of Swift Argument Parser.

This won't drop support for linting projects with an older toolchain /
Xcode selected, as long as SwiftLint was _built_ with 5.6+ and is
_running_ on macOS 12+. So the main breaking change for end users here
is requiring macOS 12 to run.

However, the upside to using Swift Concurrency features is worth the
breaking change in my opinion. Also being able to stay on recent Swift
Argument Parser releases.
2022-07-26 03:55:36 -04:00
Danny Mösch 1c7b8b7dcb
Run Sourcery enabling automatic test for ModifierOrderRule (#4034) 2022-07-24 14:11:09 -04:00
Danny Mösch a51be7bcce
Refactor deployment target configuration to avoid duplications (#4017) 2022-07-06 17:07:15 -04:00
Taha Bebek e34f49695b
Support extension targets in `deployment_target` rule (#4011) 2022-07-05 22:41:56 +02:00
Marcelo Fabri 45a03dec20
Add back `void_function_in_ternary` rule (#3956) 2022-06-27 09:41:52 -07:00
Marcelo Fabri a19ffddf66
Support arrays for `included` & `excluded` in custom rules (#4006)
* Support arrays for `included` & `excluded` in custom rules

* Extract shouldValidate(filePath:) and add tests
2022-06-27 00:29:26 -07:00
Danny Mösch a20a75d422
Fix various shortcomings in relative path computation (#4005) 2022-06-24 02:25:37 -04:00
Marcelo Fabri 4382ef49b9
Use URL(fileURLWithPath:isDirectory) to avoid file system call (#3976) 2022-05-26 21:54:23 +02:00
Marcelo Fabri f880b66cbf
Rewrite `operator_usage_whitespace` with SwiftSyntax (#3962) 2022-05-06 16:48:57 -07:00
Ryan Cole 43c84146db
Add accessibility_label_for_image rule (#3862)
Warns if a SwiftUI Image does not have an accessibility label and is not hidden from accessibility. When this is the case, the image's accessibility label defaults to the name of the image file causing a poor UX.
2022-04-18 10:40:51 +02:00
Marcelo Fabri 5f44d3f306
Add comma_inheritance_rule rule (#3954)
Fixes #3950
2022-04-17 04:47:02 -07:00
Marcelo Fabri 1752587b7b
Add unavailable_condition rule (#3953)
Fixes #3897
2022-04-17 03:30:53 -07:00
Marcelo Fabri a786e310a3
Add back return_value_from_void_function rule (#3882) 2022-04-16 16:53:11 -07:00
JP Simard bdb548e1c0
Add a few more possible future Swift versions (#3946)
So tests don't fail on whatever the next Swift releases are.
2022-04-12 11:59:34 -04:00
coffmark 23fe6f4a39
[Test] fix Swift5.6.1 version (#3944) 2022-04-12 11:23:51 -04:00
Chris Hale 9beef23175
Throw error on bad expiring todo date format (#3626) 2022-04-11 21:20:05 +02:00
Marcelo Fabri 0fbf010ea4
Only skip autocorrect on files with errors (#3933)
* Only skip autocorrect on files with errors

* Use other kind of warning so tests succeed on Linux

* Update CHANGELOG.md

Co-authored-by: JP Simard <jp@jpsim.com>

Co-authored-by: JP Simard <jp@jpsim.com>
2022-04-05 10:59:50 -07:00
Danny Moesch fa2a0bab6c
Move StringView.byteOffset into generally accessible extension (#3917) 2022-03-25 07:27:50 +01:00
Danny Moesch a801bbc83b
Add new type-safe ArrayInitRule (#3914)
The idea of this new Analyzer rule is to filter the calls of `map` before they are passed on to the classic ArrayInitRule which does the detailed checking of the lambda function block. The rule makes sure that only the `map` function is considered that is defined by the `Sequence` protocol.
2022-03-23 22:29:50 +01:00
Paul Taykalo 1616023b63
Add ability to run only one(focused) example (#3911)
* Add ability to focus on a specific test example

* Update CHANGELOG.md

Co-authored-by: JP Simard <jp@jpsim.com>

* Update CONTRIBUTING.md

Co-authored-by: JP Simard <jp@jpsim.com>

Co-authored-by: JP Simard <jp@jpsim.com>
2022-03-22 19:21:25 +02:00
Marcelo Fabri 0e5d838765
Support #unavailable in deployment_target rule (#3898)
Fixes #3896
2022-03-16 10:41:04 -04:00
Marcelo Fabri db2721f78e
Require Swift 5.0 in runtime (#3886)
* Require Swift 5.0 in runtime

* Fix violation

* Enable legacy_rule by default

* Update changelog

* Fix changelog after rebase

* More cleanup
2022-03-11 14:01:27 -08:00
JP Simard 1abc50304c
Use alternate implementation of glob with globstar support (#3892)
Adapted from https://gist.github.com/efirestone/ce01ae109e08772647eb061b3bb387c3

The implementation from Pathos seems buggy.

Fixes https://github.com/realm/SwiftLint/issues/3891
2022-03-11 13:24:39 -05:00
Fumito Nakazawa 2ae22d06a2
Support recursive globs (#3843)
ref: https://github.com/realm/SwiftLint/issues/3789

## Overview
Support glob recursive by using [Pathos](https://github.com/dduan/Pathos)
- Introduce Pathos
- Replace glob logic
- Fix some test cases
2022-03-10 21:56:43 -05:00
JP Simard 3273cef42b
Prevent empty files from triggering rule violations (#3885)
There are many valid cases to have an empty Swift source files, and these
shouldn't trigger violations.
2022-03-09 16:09:11 -05:00
Marcelo Fabri b619154905
Automatically enforce min Swift version for all rules (#3881)
* Automatically enforce min Swift version for all rules

* Fix violations
2022-03-09 11:44:56 -08: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 51d97a2037
Add 5.5.3 to `testDetectSwiftVersion()` 2022-02-15 09:24:40 -05:00
JP Simard 1864d77f37
Fix testDetectSwiftVersion() test when running with Swift 5.6 2022-01-30 13:35:13 -05:00
JP Simard 31872aaa3f
Re-add 'weak_delegate' rule as opt-in
After feedback from users: https://github.com/realm/SwiftLint/pull/3809#issuecomment-1018859093
2022-01-21 16:57:13 -05:00