Commit Graph

1932 Commits

Author SHA1 Message Date
Paul Taykalo 6240b5a606 Added all Analyzer rules back 2020-01-16 07:57:23 +02:00
Paul Taykalo 4e01095004 Add ExplictiSelfRule 2020-01-16 07:41:52 +02:00
JP Simard 1a28275891
Migrate to use SourceKitten's new ByteCount/ByteRange types 2020-01-13 21:53:10 -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 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
Sven Münnich 72e2063531
Include functions and getters in rule `implicit_return` 2020-01-05 15:04:35 -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
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
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
JP Simard 5f66704a1a
Improve compilation time (#2965)
* Improve compilation time

Before this change, `trailingClosure` took 8.6s to type check.
After this change, it takes 31ms.

* Speed up type checking `isDecimal(number:)`

Before: 377ms
After: 2ms

* Speed up type checking testViolationMessageForExpressibleByIntegerLiteral()

Before: 285ms
After: 175ms

* Fix OSSCheck

More than just rules are in `Source/SwiftLintFramework/Rules/`

* Shim XCTUnwrap for Swift 5.0
2019-11-15 11:36:25 -08:00
Paul Taykalo 66a4193aa3
Merge pull request #2956 from realm/improvement/let-var-whitespace-rule
Speedup LetVarWhitespaceRule
2019-11-12 21:09:57 +02:00
Paul Taykalo e00a8bf11a That day when regex can be faster than code 2019-11-12 20:36:47 +02:00
Paul Taykalo 3f0db8ff13
Merge pull request #2955 from realm/improvement/own-wrappers-over-syntax-tokens
Add own wrappers for SyntaxTokens and Syntax Map
2019-11-12 20:33:12 +02:00
Max Härtwig 8c7b21dcb2 Fix trailing_comma rule violation 2019-11-12 10:47:13 +01:00
Paul Taykalo d181cb0fd2 Speedup let var whitespace rule a bit 2019-11-12 03:03:22 +02:00
Max Härtwig 76d6f6745a Import Foundation to fix error 2019-11-11 15:01:36 +01:00
Max Härtwig dcc8d6e34c Make control_statement rule substitution correctable 2019-11-11 15:01:36 +01:00
Paul Taykalo 61a6a278a5 add byterange to the dictionary and breadthfirst algorithm 2019-11-10 23:53:59 +02:00
Paul Taykalo 73802c285d Add own wrappers over syntax tokens and syntax map 2019-11-10 22:55:54 +02:00
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