Commit Graph

2436 Commits

Author SHA1 Message Date
JP Simard 46959cbd1a
Add UnusedDeclarationRule 2019-07-15 21:14:05 -07:00
Elliott Williams 816785f8a0
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-13 11:14:11 -07:00
Elliott Williams 68e8b2b526
Document Linter / CollectedLinter relation 2019-07-13 11:14:10 -07:00
Elliott Williams c823057ed3
Make RuleStorage have dictionary semantics and check for collected info inside Rule 2019-07-13 11:14:10 -07:00
Elliott Williams d5b6b65c73
Refactor spacing, indenting, and rename collect to collectInfo 2019-07-13 11:14:09 -07:00
Elliott Williams f0444d67ba
Remove File+Hashable and bump SourceKitten 2019-07-13 11:14:09 -07:00
Elliott Williams e95b8c4e22
PR: Create File+Hashable, symlink Array+SwiftLint, fix nits 2019-07-13 11:14:07 -07:00
Elliott Williams de5651d806
Update tests to compile and pass
Publicize Array extensions

Address linting violations
2019-07-13 10:32:12 -07:00
Elliott Williams ba8bfcae22
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-13 10:32:12 -07:00
Elliott Williams b6535eb73e
Add CollectingRule to support arbitrary pre-lint collection 2019-07-13 10:31:51 -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 94c6009fc4 Fix false positive in `function_default_parameter_at_end`
Fixes #2788
2019-07-04 22:25:52 -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
JP Simard 7f4b736ea3
Synthesize Equatable implementations where possible (#2790) 2019-07-01 17:22:18 -04:00
Marcelo Fabri 740e398f91 release 0.33.0 2019-06-02 09:54:05 -07:00
Marcelo Fabri 0ee12bd096
Catch `!= 0` in legacy_multiple rule (#2778) 2019-06-02 09:52: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
Marcelo Fabri 862913f0c0
Don't trigger no_fallthrough_only if next case is @unknown (#2770)
* Don't trigger no_fallthrough_only if next case is @unknown

Fixes #2696
2019-05-25 21:53:23 -07:00
JP Simard a55178e681
Use isDisjoint(with:) instead of intersection().isEmpty 2019-05-20 10:19:37 -07:00
Dalton Claybrook a371419ce4 Fix issue where force-unwrapping self does not trigger a violation of the `force_unwrapping` rule (#2764)
* Fix issue where force-unwrapping self does not trigger a rule violation

* Update changelog
2019-05-20 10:17:32 -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
Cihat Gündüz d01ed712f9
Merge pull request #2754 from samrayner/samrayner/file-types-order-extensions
#2749 Fix file_types_order in extension-only files
2019-05-14 12:44:04 +02:00
Sam Rayner 7b82250995 #2749 Fix file_types_order in extension-only files
Prevents extensions being flagged as in the wrong order when a file only contains extensions and nothing else (enums, classes, structs). In this case it's not intuitive that the longest extension be considered the "main" one so the file can be considered as having no "main" type.
2019-05-13 13:59:16 +01: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
Alvar Hansen af72c06be4 Skip module import if cursor info is missing module info (#2746) 2019-05-06 08:57:01 -07:00
Marcelo Fabri a3aa36757b Add `unowned_variable_capture` opt-in rule
Fixes #2097
2019-04-30 10:12:20 -07:00
Frederick Pietschmann 3b9917f89d Add nested type handling specification to file_name rule (#2718)
* Add nestedTypeSeparator to FileNameConfiguration

* Add tests for nested_type_separator configurability of file_name rule

* Add changelog entry

* Fix changelog position after rebase
2019-04-30 08:12:43 -07:00
Javier Soto 49c288eb3f Fixed typo in `nslocalizedstring_require_bundle` rule description 2019-04-29 17:06:28 -07:00
Marcelo Fabri d14d79d2c4 Don’t trigger redundant_void_return when using subscripts 2019-04-29 09:47:00 -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
Dalton Claybrook d0ce8b6ac8 Fix false positive in UnusedCaptureListRule (#2726) 2019-04-23 11:51:44 -07:00
JP Simard 230bedcd05
Bump ReduceIntoRule's minimum Swift version to Swift 4 2019-04-19 17:38:04 -04: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 59990129f9 PR feedback updates 2019-04-15 07:34:57 -04:00
Dalton Claybrook 665920aa0b Fix line length violation + updated changelog 2019-04-14 18:55:43 -04:00
Dalton Claybrook 41c8da2769 Cleanup 2019-04-14 18:46:34 -04:00
Dalton Claybrook 0a0a60b9da Rule is now passing tests 2019-04-14 18:34:47 -04: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
Marcelo Fabri bc8f9d69a0
Merge pull request #2710 from realm/marcelo/acl-swift-5
Fix false positives on `explicit_acl` and `explicit_top_level_acl`
2019-04-09 11:32:17 -07:00
Marcelo Fabri 537dec1d37 Fix false positives on `explicit_acl` and `explicit_top_level_acl`
Fixes #2705
2019-04-09 10:59:46 -07:00
Marcelo Fabri 51d47d492c `contains_over_first_not_nil` rule now also checks for `firstIndex(where:)`
Fixes #2678
2019-04-09 10:53:42 -07:00
Keith Smiley dd39c438e1 Return false for isFile for empty strings
As of Swift 5, corelibs-foundation crashes if you pass an empty string
to `fileExists` cae5eaca63/Foundation/FileManager.swift (L2033)
2019-04-02 18:15:40 -07:00
Marcelo Fabri 1d7b37be1d
Merge pull request #2701 from r-plus/bugfix-2700
fix: false positive on sorted_first_last with firstIndex(of:), firstIndex(where:), lastIndex(of:) and lastIndex(where:) method
2019-04-02 09:54:01 -07:00