Commit Graph

421 Commits

Author SHA1 Message Date
JP Simard d2643db495
[Docs] Build docs using jazzy (#3016)
* Add `.jazzy.yaml` configuration file
* Update `swiftlint generate-docs` to write docs to a directory rather than a single file
* Add jazzy to the Gemfile
* Run `bundle update`
* Add CI job to run jazzy automatically and publish to GitHub Pages

![swiftlint-jazzy](https://user-images.githubusercontent.com/474794/71799038-fcf4e180-3008-11ea-81fa-3eb9cf296506.gif)
2020-01-07 20:31:29 -08:00
JP Simard 760383508e
Improve tuple handling in optional_enum_case_matching rule (#3024)
Catch previously missed violations in the `optional_enum_case_matching` rule when case expressions involved tuples. For example:

```swift
switch foo {
  case (.bar↓?, .baz↓?): break
  case (.bar↓?, _): break
  case (_, .bar↓?): break
  default: break
}
```
2020-01-07 09:36:08 -08:00
Frederick Pietschmann 601ea392c2
Merge pull request #2765 from fredpi/feature/indentation_width
Add new indentation_width rule
2020-01-06 10:47:09 +01:00
Marcelo Fabri 4fd593ff39
Add more tests for OrphanedDocCommentRule (#3017) 2020-01-05 23:34:03 -08:00
Frederick Pietschmann 35cd789ba1 Restructure indentation_width tests 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 8c245c7581 Add new indentation_width rule 2020-01-06 08:30:49 +01:00
Marcelo Fabri c2bdb589df
Add orphaned_doc_comment rule (#3014)
* Add orphaned_doc_comment rule

Fixes #2989

* Don’t trigger on lines with only “/“
2020-01-05 20:45:06 -08:00
Sven Münnich 72e2063531
Include functions and getters in rule `implicit_return` 2020-01-05 15:04:35 -08:00
timcmiller 4112816077 Added 'file_name_no_space' rule (#3008)
* Added 'file_name_no_space' rule

* Removed unused var, and added to changelog

* Remove custom suffix from 'file-name-no-space' rule

* Fixed LinuxMain

* Switched to use a CharacterSet over Regex
2020-01-03 15:45:30 -08:00
Marcelo Fabri 093370c2b3
Add opt-in `prefer_self_type_over_type_of_self` rule (#3006)
Fixes #3003
2020-01-03 12:33:04 -08:00
Max Härtwig 292d89f18b Make weak_delegate rule correctable (#2959) 2020-01-03 10:16:30 -08:00
Marcelo Fabri 2c3411dc88
Add optional_enum_case_matching rule (#3002) 2020-01-03 00:50:47 -08:00
ldindu 2ccb33b111 Add `enum_case_associated_values_count` opt-in rule 2020-01-02 23:24:06 -08:00
JP Simard 99dd894c80
Fix false positives in unused_declaration for protocol extensions (#3000) 2019-12-30 09:44:25 -08:00
JP Simard 9ecefbd969
[UnusedImportRule] Handle comments after the import statement (#2993)
* [UnusedImportRule] Handle comments after the import statement

* fixup! [UnusedImportRule] Handle comments after the import statement

* Use \s+ to capture whitespace in regex

Co-Authored-By: Dave Lee <davelee.com@gmail.com>

* Fix testDetectSwiftVersion() with Swift 5.1.3

* fixup! Fix testDetectSwiftVersion() with Swift 5.1.3

* Handle @_exported imports

* Work around SR-11099

* Unescape newline
2019-12-18 11:30:41 -08:00
a-25 e11fcd9820 Fixed false positive in opening_brace rule on anonymous closure (#2927)
* Fixed false positive in opening_brace rule on anonymous closure

* added one more triggering rule, fixed docs

* fixed anonymous closure match

* fixed anonymous closure match, more accurate
2019-12-03 10:37:47 -08:00
Dan Loman cc57ed3d69 Add ExpiringTodoRule (#2911)
* Add expiring todos rule

* Fix default dateFormat

* Fix date regex to handle 2-4 at beginning/end of string

* Clean up/improve clarity

* Add tests for ExpiringTodoRule

* Add output from make sourcery

* Add output from make sourcery

* Update documentation

* Enable updating of all configuration properties

* Add back Foundation import

* Add changelog entry

* Add 2 spaces after changelog entry

* Add return for legacy swift compatibility

* Add unwrapping to switch statement

* Use disable:next

* Add default values to severity config init; Add public delimiter init

* Add tests for various custom configurations

* Remove unused funcs

* Add extra tests to LinuxMain file

* Update File type -> SwiftLintFile

* Move Changelog entry

* Shorten changelog entry line length

* Fix changelog
2019-11-20 16:50:29 -08:00
Max Härtwig dcc8d6e34c Make control_statement rule substitution correctable 2019-11-11 15:01:36 +01:00
Paul Taykalo 3a36b6998b Fix false-positive identical operands rule 2019-11-10 21:54:34 +02:00
Paul Taykalo ac40778cb3 Use SwiftLintFile wrapper over the File 2019-11-07 15:19:17 +02:00
Paul Taykalo b901c670d4 Cache file structure dictionary 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
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 1206fd4dd4 Fixes after rebase 2019-10-20 19:19:54 -07:00
MarkoPejovic df2d2abb50 Remove ↓ from examples 2019-10-20 19:19:54 -07:00
MarkoPejovic 6bfd2567ce Update name 2019-10-20 19:19:54 -07:00
MarkoPejovic 109899c56c Implement #2888 2019-10-20 19:19:54 -07:00
Ivan Vavilov c27597e5bd Update Rules docs 2019-10-20 19:08:54 -07:00
Max Härtwig a157957df4 Make `toggle_bool` rule substitution correctable 2019-10-07 01:16:15 +02:00
Marcelo Fabri f211694e7d
Merge pull request #2885 from realm/mf-flatmap
Add `flatmap_over_map_reduce` opt-in rule
2019-09-26 11:02:58 -07:00
Marcelo Fabri 2457843c7c Generate docs with Xcode 11 2019-09-26 10:11:38 -07: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
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
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