Commit Graph

2785 Commits

Author SHA1 Message Date
Paul Taykalo c36858f705 Test multiregex 2020-02-08 09:10:34 +02:00
John Mueller be44017675 Fix false positives when line ends with carriage return + line feed (#3061)
Fixes: #3060
2020-02-02 15:37:49 -08:00
Paul Taykalo 057bcb8921 Fixes #3066 Crash on missing (#3067) 2020-02-02 23:30:40 +02:00
Zev Eisenberg fcf848608e Add Inline test failure messages (#3040)
* Add Example wrapper in order to display test failures inline when running in Xcode.
* Stop using Swift 5.1-only features so we can compile on Xcode 10.2.
* Wrap strings in Example.
* Add Changelog entry.
* Wrap all examples in Example struct.
* Better and more complete capturing of line numbers.
* Fix broken test.
* Better test traceability.
* Address or disable linting warnings.
* Add documentation comments.
* Disable linter for a few cases.
* Limit mutability and add copy-and-mutate utility functions.
* Limit scope of mutability.
2020-02-02 10:35:37 +02:00
Paul Taykalo 25f07af7bc Merge pull request #3031 from PetteriHuusko/dev
Fix discarded_notification_center_observer false positive on arrays
2020-01-30 09:19:26 +02:00
Petteri Huusko 3bd269fdd2 Fix discarded_notification_center_observer false positive when capturing observers into an array 2020-01-29 08:32:40 +02:00
Paul Taykalo 8ac124a494 A bit faster Explicit Self rule (#3048) 2020-01-17 13:57:54 -08:00
Steven 325af44c36 Add deinitializer to type_contents_order (#3042)
Add `deinitializer` type content to `type_contents_order` rule instead of grouping it with initializers. This allows the common use case of putting the deinitializer at the end of the class.
2020-01-16 16:49:37 -08:00
JP Simard 0b1140d874 Fix typo in examples for isEmpty 2020-01-16 16:29:11 -08:00
JP Simard fe5baca7cd Migrate to use SourceKitten's new ByteCount/ByteRange types (#3037)
New APIs were introduced in SourceKitten to allow for a more typesafe distinction between integers meaning NSString-based distances and byte-based distances.

* https://github.com/jpsim/SourceKitten/pull/639
* https://github.com/jpsim/SourceKitten/pull/642

This PR migrates SwiftLint's use of those APIs.
2020-01-16 15:18:37 -08:00
iliaskarim 4a56bf56c5 Update RedundantVoidReturnRule.swift (#3039)
Single argument function types require parentheses
2020-01-14 12:58:32 -08:00
JP Simard 399f5b7df6 Fix docstring formatting issues using DrString (#3032)
Using command:
$ drstring check -i 'Source/**/*.swift' --first-letter lowercase --vertical-align
2020-01-12 11:19:33 -08:00
JP Simard 5b5314ee70 Fix documentation in Version.swift 2020-01-08 12:14:42 -08:00
JP Simard 76d44cff39 release 0.38.2 2020-01-08 10:35:08 -08:00
JP Simard 37167a8a35 Add documentation comments to all public declarations (#3027) 2020-01-08 09:47:10 -08:00
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 4388c9f899 Fix regressions in UnusedImportRule (#3025) 2020-01-07 12:43:47 -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
Frederick Pietschmann 3d0b568e2c Fix bug with no-syntax-kind lines (e. g. "[") 2020-01-06 10:24:13 +01:00
Marcelo Fabri 4fd593ff39 Add more tests for OrphanedDocCommentRule (#3017) 2020-01-05 23:34:03 -08:00
Frederick Pietschmann d283904b0a Fix rebase issues 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 98e870e726 Fix modifier order 2020-01-06 08:30:49 +01:00
Frederick Pietschmann eb92e0b3a1 Fix wrong spacesEquivalent implementation; simplify validate method 2020-01-06 08:30:49 +01:00
Frederick Pietschmann bc6396d516 Keep linting even when seeing mixed indentation 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 0bed014cba Add extensive tests for indentation_rule; fix duplicate warning avoidance mechanism 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 35cd789ba1 Restructure indentation_width tests 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 1fbb39dd50 Introduce mechanism to avoid duplicate indentation_width warnings for one single issue 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 3a8ad943c3 Add configuration option whether to consider comment lines for indentation_width rule 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
Pyry Jahkola 805b9ab3ba Add capture_group option to custom_rules
This option allows for more fine-grained placement of the location
marker for code violating a custom rule, e.g.:

```swift
print("Hello world.")
             ^~~~~
```

for this `.swiftlint.yml`:

```yaml
custom_rules:
  world_preceded_by_hello:
    name: "World Preceded by Hello"
    included: ".+\\.swift"
    message: "The word World predeced by the word hello should be capitalised."
    severity: warning
    regex: "(?i:hello)\\s+(world)"
    match_kinds: [string]
    capture_group: 1
```
2020-01-05 15:24:11 -08:00
Optional Endeavors 8fb900650b Add support for showing only correctable rules, and a switch for ignoring the width of the terminal so full configuration detail is always shown. 2020-01-05 15:19:45 -08:00
Sven Münnich 72e2063531 Include functions and getters in rule implicit_return 2020-01-05 15:04:35 -08:00
JP Simard cb325512fb Run make sourcery 2020-01-03 19:56:18 -08:00
JP Simard 6f6c9fed8c release 0.38.1 2020-01-03 19:44:27 -08:00
JP Simard 40ade98710 Update SourceKitten to 0.28.0 (#3011) 2020-01-03 16:47:18 -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
timcmiller 29bff89a29 File name console description (#3010)
* Added parameters to FileNameConfiguration.consoleDescription

* Added bugfix to CHANGELOG

* Fix indentation

Co-authored-by: JP Simard <jp@jpsim.com>
2020-01-03 14:00:17 -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
JP Simard 20ba18c820 Indent 2020-01-03 10:17:01 -08:00
Max Härtwig 292d89f18b Make weak_delegate rule correctable (#2959) 2020-01-03 10:16:30 -08:00
Sven Münnich fb5361e37b Fix parsing of rule disable comments containing a URL (#2985) 2020-01-03 09:36:16 -08:00
Marcelo Fabri 2c3411dc88 Add optional_enum_case_matching rule (#3002) 2020-01-03 00:50:47 -08:00
Marcelo Fabri fbbd3fc08e Add AutomaticTestableRule conformance to EnumCaseAssociatedValuesLengthRule (#3005) 2020-01-03 00:34:29 -08:00
ldindu 2ccb33b111 Add enum_case_associated_values_count opt-in rule 2020-01-02 23:24:06 -08:00
Max Härtwig 44b04f377d Allow SubstitutionCorrectableRule to return nil instead of a correction to indicate that a suitable correction couldn't be found for a specific case (#2958) 2020-01-02 23:15:40 -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
JP Simard 8dc3e81193 release 0.38.0 2019-12-03 10:50:21 -08:00