Commit Graph

2085 Commits

Author SHA1 Message Date
Paul Taykalo 3a36b6998b Fix false-positive identical operands rule 2019-11-10 21:54:34 +02:00
Paul Taykalo f569e3d973
Rename Traverse to Traverse with Parent 2019-11-09 13:29:43 -08:00
Paul Taykalo c85d3099a1
Update documentation 2019-11-09 13:29:43 -08:00
Paul Taykalo a52a94c987
Use Generic Dictionary Traversing for multiple cases 2019-11-09 13:29:43 -08:00
Paul Taykalo 848370a522 Simpler check for FileTypesOrderRule 2019-11-08 01:35:01 +02:00
Paul Taykalo d771d223e3 Remove unused imports 2019-11-07 16:20:18 +02:00
Paul Taykalo ac40778cb3 Use SwiftLintFile wrapper over the File 2019-11-07 15:19:17 +02:00
Paul Taykalo 2a308c1698 Fix DiscardedNotificationCenterObserverRule 2019-11-07 12:07:56 +02:00
Paul Taykalo ec6d82af56 Cache Access Control Level property 2019-11-07 11:52:50 +02:00
Paul Taykalo b1cdc119ec Use swift enums instead of raw values 2019-11-07 11:05:19 +02:00
Paul Taykalo 4fff698c09 Update UnusedDeclarationRule to use SourceKittenDictionary 2019-11-07 10:28:30 +02:00
Paul Taykalo 18a3896f97 Update swift structure dictionary 2019-11-07 08:51:16 +02:00
Paul Taykalo f0ad230e81 fix linting issues 2019-11-07 08:50:50 +02:00
Paul Taykalo b901c670d4 Cache file structure dictionary 2019-11-07 08:50:50 +02:00
Paul Taykalo 8c963d2c15 Working solution with SouceKittenDictionary wrapper 2019-11-07 08:50:50 +02:00
Paul Taykalo 1db3eb7890 Change zip.allSatisfy to map == 2019-10-25 19:53:45 +03:00
Paul Taykalo b996e0c890 Allow force casts when chainng operators 2019-10-25 19:40:37 +03:00
Paul Taykalo 94c3f9a14b Update rules and fix syntax violations 2019-10-25 19:20:34 +03:00
Paul Taykalo 1833a44031 Include optional chaining operator when joiing operands 2019-10-25 16:03:03 +03:00
Paul Taykalo a361848866 Identical operands rule using syntaxmap 2019-10-25 04:04:38 +03:00
Marcelo Fabri 355a219b8a PR feedback 2019-10-23 12:31:07 -07:00
Marcelo Fabri cff53944c4 Optimize `redundant_void_return` 2019-10-20 20:40:11 -07:00
Marcelo Fabri a9ae253bd4
Merge pull request #2889 from 00FA9A/mp/2888
Add `raw_value_for_camel_cased_codable_enum` (#2888)
2019-10-20 20:37:20 -07:00
Marcelo Fabri 029f1a9916
Merge pull request #2892 from vani2/syntactic-sugar-autocorrect
Add autocorrection to the syntactic sugar rule
2019-10-20 20:36:41 -07:00
Marcelo Fabri 3b5458a248 Use String.isLowercase() 2019-10-20 19:19:54 -07:00
MarkoPejovic 109899c56c Implement #2888 2019-10-20 19:19:54 -07:00
Ivan Vavilov 8af5825ca1 Add some test cases 2019-10-20 19:08:54 -07:00
Ivan Vavilov ffa955dc7d Add autocorrection to the syntactic sugar rule 2019-10-20 19:08:54 -07:00
Paul Taykalo d891b1ec60 Use binary search when searching for lines indexes in LetVarWhiteSpacesRule (#2901)
* Use binary search when searching for lines indexes

* Update Changelog

* Remove unused old method of searching line by offset

* Update line by offset call with already implemented function
2019-10-20 11:30:32 -07:00
Marcelo Fabri 2dcaf3ee78
Merge pull request #2894 from realm/mf-update-sourcekitten
Update SourceKitten to 0.26.0
2019-10-08 09:36:57 -07:00
Marcelo Fabri f5174b3168 Update SourceKitten to 0.26.0 2019-10-08 00:51:18 -07:00
Max Härtwig 1a5aa05c34 Add missing Foundation import 2019-10-07 09:42:19 +02:00
Max Härtwig b9368cbca6 Fix reference to 2019-10-07 09:27:31 +02:00
Max Härtwig a157957df4 Make `toggle_bool` rule substitution correctable 2019-10-07 01:16:15 +02:00
Marcelo Fabri d4ef1f0ad0 Add `flatmap_over_map_reduce` opt-in rule
Fixes #2883
2019-09-26 10:07:12 -07:00
Nathan Van Fleet 406a8f20f8 Add Mark rule for triple slash Mark comments (#2868)
* Add Mark rule for triple slash Mark comments

* Move changelog entry to appropriate section

* Re-add Package.resolved

* Fix trailing comma

* Rebuild Rules.md using Xcode 10.3

* Combine two regexes into one
2019-09-18 17:21:13 -07:00
Colton Schlosser 2c076151f4 Add `contains_over_range_not_nil` rule, make `contains_over_first_not_nil` also match == nil (#2811) 2019-09-03 12:03:00 -04:00
JP Simard ffb2f4f76d
Require Swift 5.0 to build (#2857)
* Require Swift 5.0 to build

* Update CI

* Stop testing with Swift 4.x & Xcode 10.0/10.1
* Use official Swift docker image instead of norionomura's
* Use Xcode 10.3 as latest stable version

* Update READMEs

* Fixup xcodeproj

* Fixup CI Swift container image tag

* Fixup changelog
2019-09-03 11:42:57 -04:00
Marcelo Fabri 40bc8de5c7 Add no_space_in_method_call rule (#2855)
* Add no_space_in_method_call rule

* Avoid false positive with typecasting
2019-09-03 10:03:21 -04:00
Marcelo Fabri dae7a7b193 Don't trigger `missing_docs` on extensions
Fixes #2851
2019-08-30 14:29:32 -07:00
Colton Schlosser 130371b8cc Add `empty_collection_literal` rule 2019-08-28 21:57:02 -04:00
JP Simard 0d18758241
Use reduce(into:) for unused imports rule (#2850) 2019-08-28 16:20:47 -07:00
Marcelo Fabri 3879151abf Enable some opt-in rules (#2801) 2019-08-28 14:49:23 -07:00
Marcelo Fabri b24fd6cdd4 Enable `contains_over_filter_is_empty` in SwiftLint itself 2019-08-25 20:58:11 -07:00
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
Marcelo Fabri 7c6d5d0994
Merge pull request #2815 from atfelix/issue-2791-swiftui-previews
Removes `type_name` violation for SwiftUI template code
2019-08-25 19:32:05 -07:00
Adam Felix 6f67cfa5aa Issue-2791: `type_name` violation for with SwiftUI template code
* Ignore SwiftUI Previews underscore character
2019-08-25 20:01:28 -04:00
Marcelo Fabri e96e75b49f
Merge pull request #2844 from realm/mf-bugfix-2690
Don't trigger `missing_docs` on `deinit`
2019-08-25 04:07:17 -07:00
Marcelo Fabri 150db104c7 Don't trigger `missing_docs` on `deinit`
Fixes #2690
2019-08-25 03:28:44 -07:00
Marcelo Fabri f6b73431a1 Avoid triggering redundant_type_annotation with @IBInspectable
Fixes #2842
2019-08-25 02:22:33 -07:00
Timofey Solonin 7800220ff7 #2737 - Fix unused_imports false positive when only operators from the module are used (#2840)
As was discussed #2737, I utilized the `indexsource` request to look up the operators and fetch the cursorInfo per operator. In the implementation I refrained from using `usr` to look up the operator because SourceKit [doesn't support](5add168042/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp (L1799)) fetching cursorInfo by `usr` when it comes from C (but it can still be fetched by offset).

I also made [an alternative implementation](https://github.com/realm/SwiftLint/compare/master...biboran:fix-unused-imports-for-operators-alternative) which uses the `indexsource` request instead of the `editor.open`. It seems to work with the unit tests but I am not 100% sure it doesn't introduce a regression since there is no oss-check for analyzer rules.

I also updated [the example](https://github.com/biboran/synthax-bug-example) to better reflect the original issue in case you want to test the changes manually
2019-08-23 16:19:57 -07:00
a-25 40457a7044 Fixed false positive in `colon` (#2836) 2019-08-14 08:42:34 -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
Marcelo Fabri 94c6009fc4 Fix false positive in `function_default_parameter_at_end`
Fixes #2788
2019-07-04 22:25:52 -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 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
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
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
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
Dalton Claybrook 696cdf801c Add triggering examples with parentheses to the number separator rule tests 2019-04-02 09:02:49 -04:00
r-plus 72dc428b2f
Add some non-triggering examples to SortedFirstLastRule 2019-04-02 10:40:43 +09:00
r-plus c7a1cc1d54
fix: false positive on sorted_first_last with firstIndex(of:) and lastIndex(of:) method
Fixes #2700
2019-04-01 15:03:46 +09:00
Matthew Healy f54e7406d9 [nslocalizedstring_require_bundle] Implement NSLocalizedStringRequireBundleRule 2019-03-30 00:17:43 +01:00
Matthew Healy 74b51c5d38 [nslocalizedstring_require_bundle] Add NSLocalizedStringRequireBundleRule description 2019-03-30 00:10:14 +01:00
Dalton Claybrook ce2d1c973b Update variable name to be more specific which negates the need for a comment 2019-03-27 07:51:39 -04:00
Dalton Claybrook a5d4fb1c14 Add comment explaining the fix 2019-03-27 07:51:39 -04:00
Dalton Claybrook 10711bb92b Fix issue where using parentheses around a number could result in a false-positive on number_separator 2019-03-27 07:51:39 -04:00
Cihat Gündüz dc22d93c30
Merge pull request #2296 from Dschee/file-content-order
File Types Order & Type Contents Order
2019-03-27 12:32:37 +01:00
Cihat Gündüz b145d666d0 Fix issues after rebasing to master 2019-03-27 11:54:56 +01:00
jsloop 3d528030d6 Update documentation #2684 2019-03-27 15:14:50 +05:30
Cihat Gündüz 7d5aa7a574 Fix holdover from debugging session (aka "rogue print call") 2019-03-27 10:34:58 +01:00
Cihat Gündüz 311965f23c Fix issues after rebase 2019-03-27 10:34:58 +01:00
Cihat Gündüz 4f2f0ac350 Fix issue with missing types in older Swift versions 2019-03-27 10:34:41 +01:00
Cihat Gündüz f3ccc8cd4c Regenerate file for Linux testing & fix leftover 2019-03-27 10:34:41 +01:00
Cihat Gündüz 50fba286ab Add tests for different configurations in type_contents_order 2019-03-27 10:34:41 +01:00
Cihat Gündüz 04b2f9cac4 Split nonTriggeringExamples in components 2019-03-27 10:34:41 +01:00
Cihat Gündüz bea1d31937 Add tests for different configurations in file_types_order 2019-03-27 10:34:41 +01:00
Cihat Gündüz 843a9334d3 Move rule examples out of rule file 2019-03-27 10:34:41 +01:00
Cihat Gündüz 7d43a71510 Add more specific instance property type ib_inspectable 2019-03-27 10:34:41 +01:00
Cihat Gündüz 553b22110a Improve english in violatin reasons 2019-03-27 10:34:41 +01:00
Cihat Gündüz 56cea92913 Make implementation less probable to crash 2019-03-27 10:34:41 +01:00
Cihat Gündüz 99f60685a3 Implement equatable protocols manually for Swift 4.0 conformance 2019-03-27 10:34:41 +01:00
Cihat Gündüz 38277b75b5 Cleanup after rebase 2019-03-27 10:34:41 +01:00
Cihat Gündüz 423f30025b Fix offset encoding issue 2019-03-27 10:34:41 +01:00
Cihat Gündüz ea7f5e6b47 Fix configuration naming issue 2019-03-27 10:34:41 +01:00
Cihat Gündüz a3fc519a01 Whitelist supporting types instead of blacklist 2019-03-27 10:34:41 +01:00
Cihat Gündüz a9ec3b5949 Fix pointers & update Rules.md 2019-03-27 10:34:41 +01:00
Cihat Gündüz 664efbc916 Add more specific reason in found violations 2019-03-27 10:34:41 +01:00
Cihat Gündüz e0fb65624b Add configurations for both rules 2019-03-27 10:34:41 +01:00
Cihat Gündüz 39b1fb516c Complete implementation of type_contents_order rule 2019-03-27 10:34:41 +01:00
Cihat Gündüz 92d9cacb85 Implement violation finding part type_contents_rule 2019-03-27 10:34:40 +01:00
Cihat Gündüz 423c4ec8f7 Fix issues with file_types_order rule 2019-03-27 10:34:40 +01:00
Cihat Gündüz b19b0ca294 Basic file_types_order implementation 2019-03-27 10:34:40 +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
jsloop e8cf3e5469 Update rule to match any function
- Updated rule to not trigger if notification observer is passed to any function as argument (https://github.com/realm/SwiftLint/issues/2684)
2019-03-27 12:17:58 +05:30
Dalton Claybrook 0aa6c429fb Fix build error on linux 2019-03-24 16:36:10 -04:00
Dalton Claybrook 1e69dd950a Now the reduce_into rule is only triggered for COW types 2019-03-24 16:22:20 -04:00
Dalton Claybrook 92de850471 ReduceIntoRule is now an ASTRule 2019-03-24 16:22:20 -04:00
Dalton Claybrook 7c2e4dfd19 Add ReduceIntoRule 2019-03-24 16:22:19 -04:00
jsloop 9308c38ba4 Update discarded notification center observer
- This fixes an issue where the notification center observer is appended to an array, which triggers the violation. Fixes https://github.com/realm/SwiftLint/issues/2684.
2019-03-23 15:56:16 +05:30
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
Marcelo Fabri 6b3b89cff4 Colon rule now catches violations on generic type declarations
Fixes #2628
2019-03-03 20:06:13 -08:00
Matthew Healy dbb5aa4c9e [nsobject_prefer_isequal] Implement NSObject == linter rule 2019-03-01 21:15:03 +01:00
Matthew Healy 1c90d8745f [nsobject_prefer_isequal] Add NSObjectPreferIsEqualRule definition 2019-03-01 21:15:03 +01:00
Cihat Gündüz 7155b86919
Merge pull request #2638 from realm/cg-first_where-fix
Fix false positives on rule `first_where`
2019-02-27 12:25:03 +01:00
Paul Taykalo 1b0ac66334 Update reduce to reduce:into for a bit faster running (#2657) 2019-02-22 09:29:39 -08:00
Cihat Gündüz 3c607f1f4a [first_where] Make triggering example valid Swift code 2019-02-14 21:29:49 +01:00
Cihat Gündüz 5e1b491eea [first_where] Fix code smells like suggested by @marcelofabri 2019-02-14 21:29:49 +01:00
Cihat Gündüz 09fb947887 [first_where] Prevent false positives by excluding some substructures 2019-02-14 21:29:49 +01:00
Cihat Gündüz 2d67f611b8 [first_where] Add false positives from #1930 as non-triggering examples 2019-02-14 21:29:49 +01:00
Cihat Gündüz 3ab600f5a2 [number_separator] Add more non-triggering examples + Rename option to exclude_ranges 2019-02-14 21:19:15 +01:00
Cihat Gündüz 57fe9947a6 [number_separator] Add valid_ranges option instead of ignoring years by default 2019-02-14 21:19:15 +01:00
Cihat Gündüz 85a6a77791 [number_separator] Allow year integer literals to be written without separator 2019-02-14 21:19:15 +01:00
Cihat Gündüz efee4ed582 [number_separator] Add false positives to default non-triggering examples 2019-02-14 21:19:15 +01:00
Cihat Gündüz 74d40f2845 [unused_closure_parameter] Check if self is a keyword to prevent potential issues
This was suggested by @[marcelofabri](/marcelofabri) here:
https://github.com/realm/SwiftLint/pull/2639#discussion_r256048671
2019-02-14 18:49:13 +01:00
Cihat Gündüz fe146a3e40 [unused_closure_parameter] Make an exception for the `self` keyword and handle like identifier
Rationale: This makes the usage of the Delegated pattern usable without violating this rule.
See here for more details: https://github.com/dreymonde/Delegated
2019-02-14 18:49:13 +01:00
Cihat Gündüz 315f3a30a4 [unused_closure_parameter] Add false positive to non-triggering examples 2019-02-14 18:49:13 +01:00
Marcelo Fabri 0bc7d41958
Merge pull request #2641 from realm/cg-explicit_type_interface-fix
Fixes false positives on `explicit_type_interface` with type reference assignments
2019-02-14 09:18:55 -08:00
Almaz Ibragimov ee21684e93 Fixed `where` keyword detection method and CHANGELOG 2019-02-14 04:47:24 +03:00
Almaz Ibragimov 72a18e4aec Fix false positives on no_grouping_extension rule when using where clause 2019-02-14 03:05:46 +03:00
Cihat Gündüz 70f686591d [explicit_type_interface] Simplified type assignment regex 2019-02-12 18:50:24 +01:00
Cihat Gündüz 04ce4f8c49 [explicit_type_interface] Make sure type reference assignments are detected with allow_redundancy 2019-02-12 14:44:26 +01:00
Marcelo Fabri 19505dbcad Fix excessive `superfluous_disable_command` violations
Fixes #2623
2019-02-09 01:36:03 -08:00
Marcelo Fabri 34616f7fd0 Minor changes to LetVarWhitespaceRule.swift 2019-02-03 15:01:35 -08:00
Marcelo Fabri 82440d361d
Merge pull request #2629 from Igor-Palaguta/let_var_whitespace-With-Warning
Let var whitespace with warning
2019-02-03 14:53:31 -08:00
Marcelo Fabri cc1418502d
Merge pull request #2622 from Igor-Palaguta/TriggerBooleanNimbleOperators
Trigger boolean nimble operators
2019-02-03 14:39:59 -08:00
Igor Palaguta 279f52c6ff Add #error 2019-02-04 00:35:26 +02:00
Ben Staveley-Taylor 56f9aca477 Change rule kind from Style to Lint 2019-02-03 20:39:07 +00:00
Igor Palaguta 7078a5057b ignore warning directives 2019-02-03 20:22:45 +02:00
Ben Staveley-Taylor b8b83d025b Code formatting tidy-up 2019-02-03 15:15:53 +00: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
Igor Palaguta 3043c081d3 fix line length warning 2019-02-01 01:58:44 +02:00
Igor Palaguta c616f1e846 fix variable name 2019-02-01 01:52:34 +02:00
Igor Palaguta 939468e1fe trigget beTrue and beFalse 2019-02-01 01:51:33 +02:00
Maru d8a91501a6 Remove unmeaning comment in colon rule (#2610) 2019-01-29 08:30:09 -08:00
JP Simard 7b447ab5b1
Fix `lower_acl_than_parent` when linting with Swift 5 (#2609) 2019-01-28 12:49:23 -08:00
JP Simard e5396af9e6
Fix lint issues from #2593 2019-01-28 10:53:01 -08:00
dirtydanee 6493c6f8b5 Make `redundant_objc_attribute` rule autocorrectable. (#2593)
* Moved the violation point from the variables offset to the `@objc` attribute startIndex. I think it kinda makes sense, since the violations warns against the redundant attribute, there is nothing to fix on the variable itself.
* Searching for ranges of violations initially, and converting later only to `StyleViolation`-s
* Making the rule conforming to `CorrectableRule`. Kinda straightforward, the only extra is that I am counting the attribute's trailing whitespace and newline characters and removing with the attribute. I am doing so since I would like to keep the format of the code.
2019-01-28 10:16:11 -08:00
Marcelo Fabri e4ba455cf0
Merge pull request #2599 from realm/mf-migrate-correctable-rules
Migrate CorrectableRules to use new protocols
2019-01-27 21:42:07 -08:00
JP Simard 9cec649ab6
Add tests that fail with Swift 5 (#2604)
These are tests that pass with Swift 4.2.x but fail with Swift 5.0
from Xcode 10.2 beta 1.
2019-01-27 20:54:03 -08:00
JP Simard 18ad2473d0
Remove unnecessary backticks (#2601)
These were once required but now that we only support Swift 4.2 or later, they're unnecessary.
2019-01-27 20:19:49 -08:00
JP Simard f08c3e4239
Use firstIndex(where:) instead of index(where:) (#2600)
to silence a Swift 5 warning. This is compatible with Swift 4.2.
2019-01-27 20:19:16 -08:00
Marcelo Fabri b3c399b025 Migrate EmptyParametersRule 2019-01-27 19:05:31 -08:00
Marcelo Fabri c1002d7fc6 Migrate EmptyEnumArgumentsRule 2019-01-27 19:02:57 -08:00
Marcelo Fabri 225780ad32 Migrate CommaRule 2019-01-27 19:00:53 -08:00
Marcelo Fabri dbe920da69 Migrate EmptyParenthesesWithTrailingClosureRule 2019-01-27 18:59:38 -08:00
Marcelo Fabri 19df08ff93 Convert ClosingBraceRule 2019-01-27 18:57:25 -08:00
Marcelo Fabri 03632b24f1 Migrate TrailingSemicolonRule 2019-01-27 18:53:05 -08:00
Marcelo Fabri 6642180212 Migrate RedundantOptionalInitializationRule 2019-01-27 18:50:29 -08:00
Marcelo Fabri 08570c1dd1 Migrate RedundantVoidReturnRule 2019-01-27 18:48:33 -08:00
Marcelo Fabri 708f763215 Migrate RedundantTypeAnnotationRule 2019-01-27 18:46:55 -08:00
Marcelo Fabri b0a6ec22e0 Migrate RedundantNilCoalescingRule 2019-01-27 18:45:55 -08:00
Marcelo Fabri b49ecf7b9a Migrate JoinedDefaultParameterRule 2019-01-27 18:43:45 -08:00
Marcelo Fabri d9df6976d5 Migrate ExplicitInitRule 2019-01-27 18:42:34 -08:00
Marcelo Fabri d52eb0c64b Migrate ImplicitReturnRule 2019-01-27 18:40:56 -08:00
Marcelo Fabri 7c5c742d36 Migrate ProtocolPropertyAccessorsOrderRule 2019-01-27 18:39:08 -08:00
Marcelo Fabri 1dbd255c52 Migrate RedundantDiscardableLetRule 2019-01-27 18:38:04 -08:00
Marcelo Fabri d147ed43f4 Migrate VoidReturnRule 2019-01-27 18:35:48 -08:00
Marcelo Fabri b309dfd4ee Migrate TrailingCommaRule 2019-01-27 18:35:42 -08:00
Marcelo Fabri d6dac23bc1 Migrate UnusedControlFlowLabelRule 2019-01-27 18:35:30 -08:00
Marcelo Fabri 336fb20b48 Migrate UnusedClosureParameterRule 2019-01-27 18:35:24 -08:00
Marcelo Fabri 0ca9f6e85e Refactor WeakComputedProperyRule 2019-01-27 12:38:14 -08:00
Marcelo Fabri 5d4923f568 Add SubstitutionCorrectableRule and SubstitutionCorrectableASTRule 2019-01-27 12:32:10 -08:00
Marcelo Fabri 81ffa9b0bb Don’t trigger for stored properties with observers 2019-01-26 02:52:38 -08:00
Marcelo Fabri 757b5fb94d Add `weak_computed_property` rule
Fixes #2596
2019-01-26 02:11:35 -08:00
Marcelo Fabri 7c38722384
Merge pull request #2591 from marcelofabri/mf-deployment-target-rule
Add `deployment_target` rule
2019-01-26 00:46:05 -08:00
Marcelo Fabri a1b659aa1b
Merge pull request #2588 from dirtydanee/bugfix/explicit-type-interface-in-groups-and-stmts
Fix ExplicitTypeInterfaceRule in groups and statements
2019-01-25 13:37:44 -08:00
Marcelo Fabri 1495f62203 Use SwiftDeclarationAttributeKind 2019-01-25 01:10:53 -08:00
Marcelo Fabri 293805cf11 Remove unused import 2019-01-24 22:28:45 -08:00
Marcelo Fabri 6fadf80eae Add `deployment_target` rule
Fixes #2589
2019-01-24 21:42:11 -08:00
Marcelo Fabri 7b84e2bf66 Extract two common operations to extensions 2019-01-24 21:14:10 -08:00
Daniel Metzing 4634467644 Fix ExplicitTypeInterfaceRule in groups and statements 2019-01-24 20:37:42 +01:00
Marcelo Fabri 14ef233987 PR feedback 2019-01-23 09:57:40 -08:00
Marcelo Fabri 8cde771e9c Allow string concatenation 2019-01-23 09:32:37 -08:00
Marcelo Fabri ea4e13b9a8 Add `nslocalizedstring_key` opt-in rule 2019-01-22 23:54:04 -08:00
Marcelo Fabri 6876419552 Fix false positives in array_init rule with prefix operators
Fixes #1877
2019-01-21 23:07:21 -08:00
Kim de Vos da4d25fa8d Silence `CodingKeys` violations in `unused_private_declaration` (#2575) 2019-01-21 13:11:00 -08:00
Marcelo Fabri 2b822e8c6d Fix false positives on `trailing_closure` with anonymous closures
Fixes #2159
2019-01-18 17:43:54 -08:00
Marcelo Fabri f8dda65637 Add `only_single_muted_parameter` configuration on `trailing_closure 2019-01-17 22:02:47 -08:00
Marcelo Fabri 8f93b21543 Fix typos in examples 2019-01-17 20:38:26 -08:00
Marcelo Fabri 26e531f771 Rename rule to UnusedSetterValueRule 2019-01-17 20:37:31 -08:00
Marcelo Fabri 17906b2ac6 Handle named arguments 2019-01-17 19:25:39 -08:00
Marcelo Fabri 105f8a8710 Add unused_setter_argument rule 2019-01-17 18:51:47 -08:00
Samuel Susla 90232d542e Add `DuplicateImportsRule` (#2004) 2019-01-17 15:42:29 -08:00
JP Simard a92c6870f0
Fix false positive in identical_operands (#2565) 2019-01-17 13:57:51 -08:00
Xaver Lohmüller 7b00a110a0
Fix line_length violation a different way 2019-01-16 14:16:56 -08:00
Xaver Lohmüller 0badea7cd1
Change termination condition 2019-01-16 14:16:56 -08:00
Xaver Lohmüller 88e23a9113
Replace word break with end of line match 2019-01-16 14:16:56 -08:00
Xaver Lohmüller ed60316501
Put false positives with IdenticalOperandsRule 2019-01-16 14:16:56 -08:00
JP Simard 7d339ec782
Fix unused import correction (#2562) 2019-01-16 14:12:18 -08:00
Marcelo Fabri f8e42d81e0 Add strong_iboutlet opt-in rule
Fixes #2433
2019-01-13 20:53:12 -08:00
Kim de Vos b5c5701e90 Warn when disabling non existing rules (#2504)
* Added violations when trying to disable non valid rule

* Added violations when trying to disable non valid rule

* Add changelog enty for 'superfluous_disable_command' improvement

* Uses all rule identifiers when running nonValidSuperfluousCommandViolations

* Address feedback from jpsim

* Uses all rule identifiers when running nonValidSuperfluousCommandViolations

* Address more feedback from jpsim

* Added customRuleIdentifiers when verifying undefinedSuperfluousCommandViolations

* Catch all invalid disable commands in a region

Not just the first one.

* Rename test
2019-01-13 15:10:44 -08:00
JP Simard 0e01e07326
#2441 - Fix inaccessible custom rules in nested configurations (#2556)
* #2441 - Pass custom rules identifiers to the enableRules function to consider custom rules of a parent of a nested configuration

* #2441 - Add custom rules merge

* #2441 - Fix line length violation

* #2441 - Add nested configutaion mocks with custom rules

* #2441 - Add nested configurations tests for custom rules

* #2441 - Disable function body length check

* #2441 - Update changelog

* Move changelog to appropriate position

* Split up and refactor Configuration.init to avoid being too long

* Add tests to LinuxMain.swift

* Remove redundant protocol conformances

Hashable implies Equatable

* Fix typo in changelog entry and add another fixed issue URL
2019-01-13 15:07:27 -08:00
Marcelo Fabri 74abfc93a6
Merge pull request #2543 from BenStaveleyTaylor/issue_2538
Issue 2538: vertical_whitespace_between_cases gives false warning if blank line has whitespace
2019-01-06 12:50:08 -08:00
Ben Staveley-Taylor 09c266613d Implement review changes
Add new nonTriggeringExample for testing, with trailing spaces
2019-01-06 16:21:51 +00:00
JP Simard 0a42e64de0
Fix order in which corrections are applied
They're already ordered last to first in the file from the sorting
applied in `violationRanges(in file:)`
2019-01-05 21:33:42 -08:00
JP Simard 135a997c9c
Re-use bridged string
and inline firstToken(afterByteOffset:)
2019-01-05 21:30:58 -08:00
Marcelo Fabri 41868b35cb Improvements on unused_control_flow_label correction 2019-01-05 19:21:18 -08:00
JP Simard eb8f398683 Add shitty implementation of correction 2019-01-05 19:11:39 -08:00
Marcelo Fabri d863fc9fb7 Add unused_control_flow_label rule
Fixes #2227
2019-01-05 18:59:32 -08:00
Ben Staveley-Taylor de3a24008f Fix false positives on vertical_whitespace_between_cases
Fixes #2538
2019-01-05 16:00:32 +00:00
Marcelo Fabri 91f37afcd1 Remove unused declaration 2019-01-03 02:02:32 -08:00
Marcelo Fabri d08b3888ad Add missing ↓ on triggering example 2019-01-03 01:53:07 -08:00
Marcelo Fabri 0c92b948a9 Warn on private declaration inside @objc extension 2019-01-03 01:48:08 -08:00
Marcelo Fabri 972bb0d347 Fix false positives on `redundant_objc_attribute` rule when using nested types
Fixes #2539
2019-01-03 00:57:15 -08:00
Marcelo Fabri eafd98971d Fix false positives on sorted_first_last with Realm
Fixes #2533
2018-12-25 19:25:53 -08:00
Marcelo Fabri 4b12e08731 Fix false positives on Realm collections 2018-12-25 18:41:53 -08:00
Marcelo Fabri 506e3086ba Enable last_where on SwiftLint 2018-12-25 18:12:26 -08:00
Marcelo Fabri c17e269cee Add last_where opt-in rule 2018-12-25 01:34:42 -08:00
JP Simard 61a5daa073
Fix false positives in UnusedPrivateDeclarationRule (#2530) 2018-12-24 12:55:17 -08:00
Marcelo Fabri 0cc6ccfcf5 Remove unneeded import 2018-12-24 01:36:57 -08:00
Marcelo Fabri e6ee8f7145 Fix violations after rebase 2018-12-24 01:04:25 -08:00
Ornithologist Coder 13d51e7b4c Rebase and remove file headers 2018-12-24 01:01:12 -08:00
Ornithologist Coder 8c7a0e0499 Sets min. Swift version to 4.1 2018-12-24 01:01:12 -08:00
Ornithologist Coder 6f668a6087 Uses compactMap instead of flatMap 2018-12-24 01:01:11 -08:00
Ornithologist Coder 488488ef0d Prepare for SR-5717 apple/swift#11542 2018-12-24 01:01:11 -08:00
Ornithologist Coder fb179a9760 Uses offset/length instead of bodyOffset/bodyLength 2018-12-24 01:01:11 -08:00
Ornithologist Coder e37baf106c Handles optinals when argument is true/false 2018-12-24 01:01:11 -08:00
Ornithologist Coder 8e4e68fe13 Removes tests SwiftLint already takes care of 2018-12-24 01:01:11 -08:00
Ornithologist Coder 3c30d6f519 Renames variables 2018-12-24 01:01:11 -08:00