Commit Graph

982 Commits

Author SHA1 Message Date
JP Simard 341ec2a907
Remove 'weak_delegate' rule (#3809)
This was very prone to false positives and not worth keeping.

The identifier will stick around for a release to ease the migration.
2022-01-21 17:56:59 +00:00
Sergei aff3536bb8
Fix the regex for expiring-todos. (#3803)
- Make "middle part" `.*` not so greedy with `?`.
- Use `(?!` negative look-ahead to improve matching.
- Added corresponding unit tests.

Co-authored-by: Sergei Shirokov <sshirokov@malwarebytes.com>
2022-01-21 17:42:17 +00:00
Andrés Cecilia Luque af59581b66
Fix specifying the cachePath from command line (#3797) 2022-01-21 08:01:48 -08:00
Danny Mösch 050473a0e1
Add optional prefer_self_in_static_references rule (#3732) 2021-11-29 18:42:53 +00:00
JP Simard 5a98458d94
Add more Swift versions to testDetectSwiftVersion() 2021-11-01 11:39:34 -04:00
Marcelo Fabri 4052c43f16 Make rule more generic and rename it 2021-09-29 10:28:39 -07:00
Marcelo Fabri cfa3dff7fe Fix unrelated test 2021-09-29 10:28:39 -07:00
Marcelo Fabri 2674d367f9 Fix violation 2021-09-29 10:28:39 -07:00
Marcelo Fabri 68bfc13941 Add add_target_in_variable_declaration_closure rule 2021-09-29 10:28:39 -07:00
Ben Fox 00799cc782
Fixes MissingDocRuleConfiguration (#3713)
* add configuration for missing_docs

* fix MissingDocsRuleConfiguration

* add to changelog

* fix up Config default values and update tests

* use XCTAssertTrue and XCTAssertFalse

* fix line length violation

* finish up unit tests

* rever Package.resolved
2021-09-13 15:23:55 -04: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
JP Simard 986d98c475
Fix tests on Swift 5.5 / Xcode 13 (#3709) 2021-09-09 21:11:22 +00:00
Ben Fox 1f44d56357
add configuration for missing_docs (#3701)
* `excludes_extensions` defaults to `true` to skip reporting violations
  for extensions with missing documentation comments.
* `excludes_inherited_types` defaults to `true` to skip reporting
  violations for inherited declarations, like subclass overrides.
2021-09-01 21:42:47 +00:00
Kane Cheshire 4a293632c2 Named rule correctly for Sourcery to work properly 2021-08-24 00:19:35 -07:00
Marcelo Fabri 50b6992852 Fix issues with explicit_type_interface on Swift 5.4
Fixes #3615
2021-08-16 02:23:28 -07:00
Marcelo Fabri 9939c536d5
Add anonymous_argument_in_multiline_closure opt-in rule (#3659)
* Add anonymous_argument_in_multiline_closure opt-in rule

* Restrict match to the closure

* Fixes
2021-06-17 17:03:19 -07:00
Steven Grosmark 300bf77967
Improve `file_length` warnings when excluding comments (#3654)
* Improve `file_length` warnings when excluding comments

* Update changelog

* Update Source/SwiftLintFramework/Rules/Metrics/FileLengthRule.swift

Co-authored-by: Yegor Chsherbatykh <ego1309@yandex.ru>

Co-authored-by: Steven Grosmark <steven.grosmark@ww.com>
Co-authored-by: Yegor Chsherbatykh <ego1309@yandex.ru>
2021-06-17 11:11:17 -07:00
Kane Cheshire 91b125b001 Ran sourcery + tidied up 2021-05-24 12:05:29 -07:00
Kane Cheshire d7aeea39d9 Adding examples/tests 2021-05-24 12:05:29 -07:00
Kane Cheshire 538764278b Adding new DisallowNoneCase rule 2021-05-24 12:05:29 -07:00
raduciobanu002 07c8e52fc8
"Colon Spacing" rule name update (#3583)
* * Changed rule name from "Colon" to "Colon Spacing"
* Updated tests

* Update CHANGELOG.md

Co-authored-by: Seth Friedman <sethfri@gmail.com>
2021-05-20 23:46:54 -04:00
Steven 625cd180ae
Fix `type_contents_order` initializer detection (#3622) 2021-05-10 09:56:21 -04:00
Marcelo Fabri a10158c475
Add duplicated_key_in_dictionary_literal rule (#3613) 2021-04-28 17:25:08 -07:00
JP Simard 058869f446
Require Swift 5.3 or higher to build (#3553)
* Require Swift 5.3 or higher to build

* Remove Swift Version Support tables from readmes

These weren't exactly accurate because SwiftLint should still work with
older Swift versions long after we update the minimum version of Swift
needed to _build_ the tool. So I doubt this table was very helpful to
anyone.
2021-03-04 18:07:04 +00:00
JP Simard e47fb60c7a
Regenerate Sourcery output 2021-03-03 15:41:50 -05:00
László Kustra 87d4accb39
Add "Capture non-constant variable" rule 2021-03-02 16:11:33 -05:00
Otavio Cordeiro 24122e1325
Rename Rule to BalancedXCTestLifecycleRule 2021-03-01 01:29:16 +01:00
Otavio Cordeiro bd4dcd5b23
Add required_xctest_tearddown opt-in rule 2021-02-28 23:48:05 +01:00
JP Simard fed8644e01
Remove duplicate disable commands 2021-02-26 12:09:40 -05:00
JP Simard 3e04acd97d
Revert "Revert "Fix issue that prevented the inclusion of a configuration file from a parent folder (#3491)""
This reverts commit b66f7c7992.
2021-02-26 11:44:10 -05:00
JP Simard 9182eda98c
Disable file & type body length rules in ConfigurationTests 2021-02-26 10:37:47 -05:00
JP Simard 5b1d737683
Merge pull request #3538 from realm/feature/fix-custom-rules-merging
Multiple fixes for custom rules
2021-02-25 16:14:50 -05:00
JP Simard b66f7c7992
Revert "Fix issue that prevented the inclusion of a configuration file from a parent folder (#3491)"
This reverts commit 2f6fd1e95f.
2021-02-25 14:49:10 -05:00
Frederick Pietschmann 0dfb04b25a Add 2 new tests for custom rules when in only_rules mode 2021-02-25 19:22:57 +01:00
Frederick Pietschmann 520d224719 Revert "Revert "Merge pull request #3473 from realm/feature/3472-fix-custom-rules-merging" (#3503)"
This reverts commit 6a38b15657.
2021-02-25 19:22:57 +01:00
Frederick Pietschmann 2f6fd1e95f
Fix issue that prevented the inclusion of a configuration file from a parent folder (#3491)
* Add (currently failing) test for #3485

* [#3485] Add missing rootDir adjustment for included / excluded paths

* Add changelog entry

* Adjust tests for relative included / excluded paths
2021-02-23 18:19:19 -05:00
JP Simard 402e76b33d
Add a few more possible upcoming versions to testDetectSwiftVersion
To give us more lead time before we need to update this again.
2021-02-23 16:27:27 -05:00
JP Simard eca9ea4bb8
Adding Legacy ObjC Type Rule #2758 (#3531) 2021-02-23 12:08:01 -08:00
Otavio Cordeiro 46777539ad
Add opt-in rule private_passthrough_subject (#3504) 2021-02-08 10:43:27 -08:00
DwayneCoussement f66c51b9f2
Update tests to support Swift 5.3.3 (#3509) 2021-02-02 07:18:31 -08:00
Otavio Cordeiro 59eb887cfa
Add opt-in rule discouraged_assert (#3506)
Co-authored-by: Keith Smiley <keithbsmiley@gmail.com>
2021-01-29 09:30:57 -08:00
JP Simard 6a38b15657
Revert "Merge pull request #3473 from realm/feature/3472-fix-custom-rules-merging" (#3503)
This reverts commit 537e53f6b3, reversing
changes made to ba49f7d309.
2021-01-22 10:31:05 -08:00
Frederick Pietschmann 22d25da7fc Add newline at end of yml test file 2021-01-15 00:14:50 +01:00
Frederick Pietschmann 2d17045b11 [#3477] Fix bug that prevented the reconfiguration of a custom rule in a child config 2021-01-14 23:35:21 +01:00
Frederick Pietschmann 5bffc77af6 Fix custom_rules merging when a configuration is based on only_rules 2021-01-14 23:35:21 +01:00
Frederick Pietschmann 0a0e3f50eb Add 5.3.2 to testDetectSwiftVersion() 2020-12-20 15:56:14 +01:00
JP Simard ab6aeed5b1
Replace non_private_xctest_member with test_case_accessibility (#3464)
in `.swiftlint.yml`.
2020-12-11 09:05:02 -08:00
JP Simard f8bc10aaaa
Merge pull request #3460 from realm/dont-log-a-warning-if-no-configuration-files-were-explicitly-specified
Don't log a warning if no configuration files were explicitly specified
2020-12-11 10:02:41 -05:00
JP Simard 2b50902d1a
Revert most changes, just don't log a warning 2020-12-09 17:14:04 -05:00
Keith Smiley 800030ad11
Remove NonPrivateXCTestMembersRule (#3459)
* Remove NonPrivateXCTestMembersRule

I accidentally implemented this rule twice. So TestCaseAccessibilityRule
did the same thing but with a bit more behavior. This change deletes
NonPrivateXCTestMembersRule but also ports over the autocorrection from
it to TestCaseAccessibilityRule.
2020-12-09 13:16:40 -08:00
JP Simard f0f0086aca
Merge pull request #3443 from realm/remove-info.plist-files
Remove Info.plist files
2020-11-23 10:47:36 -05:00
Frederick Pietschmann 26aae94f1b Drop unneeded import statement 2020-11-21 00:58:24 +01:00
Frederick Pietschmann 28cb43afa9 Fix test resources access on Linux 2020-11-21 00:35:34 +01:00
Frederick Pietschmann 715a8db2db Adjust file naming in child / parent config tests 2020-11-21 00:20:40 +01:00
Frederick Pietschmann 495d742f65 Fix issues originating from new set semantics 2020-11-21 00:05:42 +01:00
Frederick Pietschmann 4c5a3f0577 Add remote, parent & child configuration features 2020-11-20 23:08:37 +01:00
JP Simard e143a18e5c
Remove Info.plist files
These are no longer needed now that we removed the Xcode project.
2020-11-20 15:01:09 -05:00
JP Simard cd9cf682e7
Merge pull request #3441 from realm/fix-how-test-failures-are-rendered
Fix how test failures are rendered
2020-11-20 11:55:02 -05:00
JP Simard 5a077d9f3f
Fix how test failures are rendered 2020-11-20 11:19:27 -05:00
Keith Smiley b7ec75b68b Add support for testing Examples with configuration
This was extracting from another change that no longer needed it. It
should be helpful for anyone testing custom configuration with their
non-analyzer rules.

I added a random example of something that wasn't previously tested as
an example.
2020-11-16 15:37:15 -08:00
Keith Smiley 866102c3fc
Add XCTestCase examples to unused declaration rule (#3192) 2020-11-16 15:32:51 -08:00
Keith Smiley 3151e6c45f
Add NonPrivateXCTestMembersRule (#3248)
Co-authored-by: JP Simard <jp@jpsim.com>
2020-11-16 09:50:56 -08:00
JP Simard 07f559549a
Rename OverridenSuperCallConfiguration to fix typo (#3426)
* BREAKING CHANGE: As `OverridenSuperCallConfiguration` is a
publicly-exposed struct, this rename should be considered breaking.

* Fix consoleDescription for OverriddenSuperCallConfiguration
2020-11-11 13:37:12 -05:00
Jan-Otto Kröpke 874cacbd1f
Add codeclimate reporter (#3425) 2020-11-11 10:29:00 -08:00
Bryan Ricker 8a0eb67561 chore: rename OverridenSuperCallConfiguration to OverriddenSuperCallConfiguration
BREAKING CHANGE: As `OverridenSuperCallConfiguration` is a
publicly-exposed struct, this rename should be considered breaking.
2020-11-10 20:40:41 -08:00
Noah Gilmore 6d4487c517 Fix a few test which failed due to comment_spacing being a default rule 2020-11-10 16:08:25 -08:00
JP Simard bf2790df54
Enable CommentSpacingRule by default
And fix violations in SwiftLint
2020-11-10 12:50:39 -05:00
Noah Gilmore dd5c0d3599 Add CommentSpacingRule (#3233) 2020-11-09 21:54:14 -08:00
Skoti b9841595a5
Separated nesting level counting for types and functions in `nesting` rule (fixes #1151). Enhanced `nesting` rule to search for nested types and functions within closures and statements. Enhanced `nesting` rule to allow for one nested type within a function even if breaking a maximum type level nesting (fixes #1151). 2020-11-09 12:06:34 -05: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
Marcelo Fabri c8596a647a Add prefer_nimble opt-in rule
Fixes #3293
2020-11-08 00:09:51 -08:00
Seth Friedman e316bd693d
Fix finding the nested config when a single file path is passed (#3379)
This was previously attempted in #3342, but produced a bug in the case where `--config` is used to specify a config from outside of the source tree. The `--config` argument wasn't always being used as an override, and was being merged with the config in the source tree. This has now been addressed and reverts the revert done in #3362. 

Fixes #3341
2020-11-07 23:07:03 -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 390e9a2423
Remove UnneededNotificationCenterRemovalRule (#3407)
See https://github.com/realm/SwiftLint/issues/3338 for detailed
motivation.
2020-11-07 18:59:33 -05:00
JP Simard 35ad3f941c
Add 5.3.1 to testDetectSwiftVersion() 2020-11-07 16:58:12 -05:00
JP Simard 2dcce6b184
[AttributesRule] Fix parameterized attributes (#3405)
Some attributes are parameterized, such as `@objc(name)`. Previously
these reported `attributes` violations because their contents weren't
included in the configuration, which would just have `@objc`.
2020-11-07 16:57:57 -05:00
Zsolt Kovács ac2c5e4054
Allow opening brace on newline in case of multiline function (#3068) 2020-11-07 16:02:17 -05:00
JP Simard b005920cc5
Improve compilation times (#3404)
By speeding up a handful of the longest expressions to compile.
2020-11-07 12:16:25 -08:00
Mikhail Monakov fc0092dc8c
Add excluding by prefix option (#3345)
As we discussed here https://github.com/realm/SwiftLint/pull/3325 sometimes current excluding algorithm maybe slower than excluding paths by absolute prefix. So I added option for such cases.

Based on what I've checked it works faster for next scenarios:
- the number of input files is relatively small (e.g. when using `use-script-input-files`) and excluded directories contain relatively big number of lintable files
- the number of excluded directories relatively small (e.g. Pods + ThirdParty) and globs not used
2020-11-07 10:54:06 -08:00
JP Simard d628c41665
[IdentifierNameRule] Allow "allowed symbols" as first character (#3403)
This means that if `allowed_symbols` contains `_`, you can now write
identifiers like `let _myLet`.

Fixes https://github.com/realm/SwiftLint/issues/3306
2020-11-07 09:54:04 -08:00
Keith Smiley 5d6e25ae5f
Add TestCaseAccessibilityRule (#3376)
Co-authored-by: JP Simard <jp@jpsim.com>
2020-10-12 08:59:45 -07:00
JP Simard a67b0f26e7
Revert "Fix finding the nested config when a single file path is passed (#3342)" (#3362)
This reverts commit ea06b79e0d.
2020-09-22 08:30:52 -07:00
Seth Friedman ea06b79e0d
Fix finding the nested config when a single file path is passed (#3342)
Fixes #3341

When SwiftLint searches for nested configurations and only one file has been passed in via the `paths` argument, SwiftLint returns early after inadvertently comparing the containing directory of the file-to-be-linted to itself. This happens because `rootDirectory` is calculated from `rootPath`, which is set to the file being linted in this scenario.
2020-09-22 07:24:52 -07:00
JP Simard 6d2e8cfc06
Skip correcting files with parser diagnostics (#3349)
* Skip correcting files with parser diagnostics

Also fix many rule examples with parser diagnostics.

* Sourcery

* Link to issue in changelog entry
2020-09-17 18:14:00 -04:00
Ryan Demo 51544bb4cc
Add `excluded_match_kinds` custom rule config parameter (#3336)
This allows custom rules to define an `excluded_match_kinds` array instead of listing out all but one or a few of the `SyntaxKind`s in `match_kinds`. Rules that include both `match_kinds` and `excluded_match_kinds` will be invalid, since there's not an obvious way to resolve the two without an arbitrary priority between them.
2020-09-10 21:08:41 -04:00
cfiken 1b95821205 Fix: testDetectSwiftVersion for Swift 5.2.5 2020-08-13 12:48:33 +09:00
Marcelo Fabri 5e1c13be52 Add `unneeded_notification_center_removal` rule
Fixes #2755
2020-08-10 07:46:51 -07:00
Marcelo Fabri 6dbc0523fa Rename file 2020-08-05 20:13:53 -07:00
Marcelo Fabri 2b7230709d Move tests 2020-08-05 20:13:03 -07:00
Adrian Bolinger c156af86bc Add tests for AccessControlLevel
- add assertions for `description`
- add assertions to test 'priority'
2020-08-05 20:10:51 -07:00
antonnazarov 63bd8ce7a5 Add PreferZeroOverExplicitInitRule 2020-08-05 15:05:02 -07:00
Keith Smiley cf94d5d8ea
Add IBInspectableInExtensionRule (#3174) 2020-08-04 14:15:40 -07:00
Marcelo Fabri 9e5557fbc5
Merge pull request #3160 from realm/mf-computed_accessors_order
Add computed_accessors_order rule
2020-08-04 05:04:45 -07:00
Marcelo Fabri 0219584605 Update LinuxMain to add missing test 2020-08-04 03:24:15 -07:00
Marcelo Fabri 240e25232f Add computed_accessors_order rule
Fixes #3158
2020-08-04 03:23:36 -07:00
Marcelo Fabri 1f5ee4d9fd Run tests on Xcode 12 as well 2020-08-04 02:45:42 -07:00
Frederick Pietschmann eaff622233 Add support for Xcode 11.5 and Swift 5.2.4 2020-06-18 14:52:20 -05:00
Noah Gilmore bda1cd56e0
#3167: Fixes false positives for multiline_parameters_brackets and multiline_arguments_brackets (#3171)
* Issue #3167: Fixes false positives for multiline_parameters_brackets and multiline_arguments_brackets

* Add changelog entry

* Fix trailing comma in MultilineParametersBracketsRule nontriggering examples

* Remove header comments from ExtendedStringTests.swift

Co-authored-by: Paul Taykalo <ptaykalo@macpaw.com>
2020-05-29 11:59:02 +03:00
JP Simard 345933ebb1
Run CI on Linux Swift 5.2 (#3199)
* Run CI on Linux Swift 5.2

* fixup! Run CI on Linux Swift 5.2

* Move SwiftVersion tests to its own file
2020-05-06 14:16:17 -07:00
JP Simard 52cd6ebe06
Fix `@available` attribute to work around SR-12500
https://bugs.swift.org/browse/SR-12500
2020-05-06 13:33:10 -07:00