Commit Graph

616 Commits

Author SHA1 Message Date
Marcelo Fabri 3e115835b1 Merge pull request #2846 from realm/mf-contains_over_filter_is_empty
Add `contains_over_filter_is_empty` opt-in rule
2019-08-25 20:55:11 -07:00
Marcelo Fabri 67526344ef Add contains_over_filter_is_empty opt-in rule 2019-08-25 20:22:41 -07:00
Marcelo Fabri 759ccd8a1e Avoid false positives in contains_over_filter_count 2019-08-25 20:11:23 -07:00
Marcelo Fabri 00d2b5d772 Add contains_over_filter_count opt-in rule
Fixes #2803
2019-08-25 20:00:50 -07:00
JP Simard 08946e65e5 release 0.34.0 2019-07-18 18:28:39 -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
Elliott Williams 3d5239429e Add AnyCollectingRule and isCollecting
All CollectingRules implement AnyCollectingRule, which is used to check
whether a linter will perform any collections and only print the
"Collecting" log message if so.
2019-07-18 14:59:42 -07:00
Elliott Williams a47b9a90fc Document Linter / CollectedLinter relation 2019-07-18 14:59:42 -07:00
Elliott Williams f277fbe5d2 Make RuleStorage have dictionary semantics and check for collected info inside Rule 2019-07-18 14:59:42 -07:00
Elliott Williams ddee9c8e6b Refactor spacing, indenting, and rename collect to collectInfo 2019-07-18 14:59:42 -07:00
Elliott Williams 7344732799 PR: Create File+Hashable, symlink Array+SwiftLint, fix nits 2019-07-18 14:59:42 -07:00
Elliott Williams 512e06a4e4 Update tests to compile and pass
Publicize Array extensions

Address linting violations
2019-07-18 14:59:42 -07:00
Elliott Williams b1ca533649 Add RuleStorage and a pre-linting stage to run collection
In order for rules to collect arbitrary information about all files
being linted, a shared RuleStorage instance is defined in each command
and passed into the linter.

Linting now requires two "passes": once to call collect and populate the
storage (rules that are non-collecting do nothing here), and again to
call validate. The old Linter factory now creates a Prelinter, which can
collect for a file and produce a Linter that orchestrates all the
traditional validation/collection logic.

This design enforces that a file is only validated once it has been
collected; in turn, the file-visiting loop ensures that all files are
collected before the first is validated, so that the storage is fully
populated.

Use storage-backed correct method

Crash if storage for a rule is accessed prematurely

Key FileInfo by File

Rename Prelinter to Linter and Linter to CollectedLinter

Clean up rule protocols such that rule-facing storage methods are actually called

Make RuleStorage a reference type to solve mutating data races
2019-07-18 14:59:42 -07:00
JP Simard ffd0804746 release 0.33.1 2019-07-08 08:54:53 -07:00
JP Simard 3a0c2b0c05 Migrate LinterCache to use Codable models (#2799)
* Migrate LinterCache to use Codable models

improving performance and type safety

* Fix Linux

* Avoid creating a Decoder if it won't be used

For example if the file doesn't exist or can't be read.

* Use corelibs plist coder if available

It's available in the Swift 5.1 branch: https://github.com/apple/swift-corelibs-foundation/pull/1849

* Remove unused error case
2019-07-07 00:35:10 -07:00
Colton Schlosser 18e90be780 Split cache into one file per configuration (#2796)
* Split cache into one file per configuration

* Only write cache files with changes

* Avoid converting from Data -> String -> Data when saving cache files

* Move empty check to for where

* Split cache changelog entry

* Reword changelog entry to better reflect impact
2019-07-06 11:50:20 -07:00
Marcelo Fabri 0652b323f5 Use new source.request.compiler_version request 2019-07-04 10:59:43 -07:00
Marcelo Fabri 596bf8dbc8 Detect parameter attribute in vertical_parameter_alignment
Fixes #2792
2019-07-04 10:42:11 -07:00
Marcelo Fabri 740e398f91 release 0.33.0 2019-06-02 09:54:05 -07:00
Marcelo Fabri 6be5bf74c3 Add legacy_multiple opt-in rule (#2771)
Fixes #2612.
2019-06-01 22:49:23 -07:00
Marcelo Fabri 90cb1349c0 Add duplicate_enum_cases rule (#2777)
Fixes #2676
2019-06-01 20:32:55 -07:00
JP Simard c216ccc1e5 Remove WeakComputedProperyRule (#2761)
* Remove WeakComputedProperyRule

Addresses https://github.com/realm/SwiftLint/issues/2712

* fixup! Remove WeakComputedProperyRule
2019-05-16 02:19:01 -07:00
Kevin Randrup d7439410e9 Introduce " - " delimiter to allow rules to be commented (#2721)
* Introduce " - " delimiter to allow rules to be commented
Ex. swiftlint:disable:next force_try - Explanation here

* Fix changelog formatting
2019-05-12 21:40:12 -07:00
Marcelo Fabri a3aa36757b Add unowned_variable_capture opt-in rule
Fixes #2097
2019-04-30 10:12:20 -07:00
JP Simard 6534946fe3 release 0.32.0 2019-04-28 21:30:19 -07:00
Marcelo Fabri 3a36212b94 Swift 5 support (#2720)
* Update project to compile with Xcode 10.2

* Fix explicit_acl with Swift 5

* Update macOS VM image

* Fix ConfigurationTests on Swift 5

* Update Podspec

* Workaround SR-10486 to fix validation tests

* Fix testDetectSwiftVersion on Swift 5

* Update specs repo when validating CocoaPods spec

* Fix redundant_set_access_control tests

* Manually update Package.resolved

* Use .upToNextMinor

* [Azure Pipelines] Add `sw_vers`

* Relax expecting conditions for crashing output in `testSimulateHomebrewTest()`

Because TSAN makes `swiflint` to produce additional output on crashing.

* Add CHANGELOG entry

* Ignore extensions in explicit ACL rules

* Work around SR-10486 for Sourcery
2019-04-28 21:10:06 -07:00
Marcelo Fabri ad2733391a Merge pull request #2666 from daltonclaybrook/dc-reduce-into-rule
Add reduce_into opt-in rule
2019-04-15 14:52:04 -07:00
Dalton Claybrook d8f671c315 WIP - create unused capture list rule 2019-04-13 23:12:25 -04:00
Frederick Pietschmann 43e18458de Update file headers for new sourcery version 2019-04-12 17:13:27 +02:00
Frederick Pietschmann 81abf9f3f2 Let "disable all" command override "superfluous_disable_command" rule 2019-04-12 16:27:43 +02:00
Matthew Healy eecf27ede8 [nslocalizedstring_require_bundle] Run make sourcery 2019-03-30 00:10:14 +01:00
Cihat Gündüz 7b94984175 Split new rule up into two separate rules 2019-03-27 10:34:40 +01:00
Cihat Gündüz f379fdef77 Define new rule file_content_order with examples & tests 2019-03-27 10:34:40 +01:00
Dalton Claybrook 87dbf8e3d7 Fix Changelog issue, Sourcery version mismatch, and package.resolved issue 2019-03-24 16:22:19 -04:00
Dalton Claybrook 7c2e4dfd19 Add ReduceIntoRule 2019-03-24 16:22:19 -04:00
Marcelo Fabri 9fc1d571ae Merge pull request #2669 from pixyzehn/fix-link-for-redundant-@objc-attribute
Remove @ mark to fix invalid link in Rules.md
2019-03-13 09:41:20 -07:00
Xaver Lohmüller 57af7f0e30 Add ReduceBooleanRule (#2675)
* [reduce_boolean] Implement rule

* [reduce_boolean] Improve reason text

* [reduce_boolean] Fix new violations

* [reduce_boolean] Add CHANGELOG.md entry

* [reduce_boolean] Shorten rule name

* [reduce_boolean] Use regular map instead of compactMap

* [reduce_boolean] Match only possible syntax kinds
2019-03-10 10:54:14 -07:00
Nagasawa Hiroki 8fa2d0bcfc Remove punctuation from anchor 2019-03-09 17:12:22 +00:00
Matthew Healy a75198f9d0 [nsobject_prefer_isequal] Add autogenerated documentation 2019-03-01 21:15:03 +01:00
Matthew Healy 057c72c2a6 [nsobject_prefer_isequal] Run make sourcery 2019-03-01 21:15:03 +01:00
Marcelo Fabri 26c0048cf4 release 0.31.0 2019-02-28 15:01:30 -08:00
Paul Taykalo 1b0ac66334 Update reduce to reduce:into for a bit faster running (#2657) 2019-02-22 09:29:39 -08:00
Marcelo Fabri bf9758679b Support commands using “/* .. */“ 2019-02-09 01:48:36 -08:00
Marcelo Fabri 735c432eaf Skip whitespace only rule identifiers 2019-02-09 01:36:03 -08:00
Marcelo Fabri 19505dbcad Fix excessive superfluous_disable_command violations
Fixes #2623
2019-02-09 01:36:03 -08:00
Ben Staveley-Taylor e29d38cde2 Incorporate review comments
- Rename from Deinit_Required to Required_Deinit
- Adopt ASTRule protocol
2019-02-03 15:02:19 +00:00
Ben Staveley-Taylor bff405d34e Add deinit_required rule
Classes are required to have a deinit method.

This is a style to help debugging memory issues, when it is common to want to set a breakpoint at the point of deallocation. Most classes don't have a deinit, so the developer ends up having to quit, add a deinit and rebuild to proceed. If all classes have a deinit, debugging is much smoother.

Ref: https://github.com/realm/SwiftLint/issues/2620
2019-02-02 14:52:48 +00:00
JP Simard 2638827965 Add SwiftVersion.five and automatically detect it (#2602)
Add `SwiftVersion.five` and automatically detect it when computing `SwiftVersion.current`.
2019-01-27 20:26:30 -08:00
Marcelo Fabri 757b5fb94d Add weak_computed_property rule
Fixes #2596
2019-01-26 02:11:35 -08:00
Marcelo Fabri 6fadf80eae Add deployment_target rule
Fixes #2589
2019-01-24 21:42:11 -08:00