Commit Graph

347 Commits

Author SHA1 Message Date
Josh Friend a4d32cfa67 Don't trigger ClosingBraceRule across line breaks
Closes #592
2016-04-05 14:11:10 -04:00
Erik Aigner 2c5b7a61d6 Accept variable names starting with more than one capital letter
The rule was modified to allow for names that start with multiple uppercase letters like XMLString or MIMEType.

Closes #566
2016-03-13 12:08:32 +01:00
Norio Nomura f62fe10372 Rewrite ForceUnwrappingRule
Add capture previous of "!" for:
- checking whether SyntaxKinds is comment, string, keyword or type identifier
- checking whether character is ")"
- checking whether SyntaxKinds is identifier or not
- SwiftDeclarationKind is one of some "Var*" and declaration containing "="

Add capture next of "!" for:
- checking SyntaxKinds is identifier

By applying this, the duration of linting Carthage 0.14 increase from 300ms to 380ms.
2016-02-21 22:35:56 +09:00
Norio Nomura f80373f43d Add failing false positive examples to ForceUnwrappingRule's description
#546, #547
2016-02-21 22:35:56 +09:00
Norio Nomura 704e7bde1d Add SyntaxMap.tokensIn(_:)
That returns array of SyntaxTokens intersecting with byte range.
2016-02-19 17:30:54 +09:00
Norio Nomura 32b98baf4c Exclude new line characters from trailing whitespace 2016-02-17 11:15:41 +09:00
Norio Nomura ecbfb46398 Add failing non trigger example
```swift
func abc(
  a: String,
  bcd: String
) {
}
```
2016-02-17 11:15:41 +09:00
Norio Nomura 6f17c93bd6 Add check trailing comment 2016-02-17 11:15:41 +09:00
Norio Nomura 78255e098b Add failing non trigger examples
```swift
func abc(
  a: String,  // comment
  bcd: String // comment
) {
}
```
2016-02-17 11:15:41 +09:00
Norio Nomura 8c35e1d3db Share regular expression between validateFile(_:) and correctFile(_:) in CommaRule 2016-02-17 11:15:41 +09:00
Norio Nomura 193d4ef446 Simplify the regular expression in CommaRule.validateFile(_:) 2016-02-17 11:11:47 +09:00
Norio Nomura 1b2ba7ac88 Rewrite CommaRule.correctFile(_:)
Now corrections happen only on violations.
Because `assertCorrection(_:expected:)` expects one correction for each `corrections`,
and the rule added by 93e8e12 causes two corrections on previous logic.

Fix #466
2016-02-17 11:11:47 +09:00
Norio Nomura 8539953c09 Add failing correction example from #466 to CommaRule
https://github.com/realm/SwiftLint/issues/466#issuecomment-184474925
2016-02-17 11:11:47 +09:00
Norio Nomura 669fbf09d0 Refine ForceUnwrappingRule
Fix #535
The duration of `ForceUnwrappingRule` on linting Carthage 0.14 is reduced from 1415ms to 339ms by Instruments.
2016-02-14 23:07:18 +09:00
Norio Nomura 0b1d54246a Add examples to nonTriggeringExamples of ForceUnwrappingRule 2016-02-14 23:00:37 +09:00
Norio Nomura e09418add7 Add failing test from #535 to ForceUnwrappingRule 2016-02-14 23:00:37 +09:00
JP Simard 601470ab8f expand some instances of "config" to "configuration" 2016-02-12 10:53:36 -08:00
JP Simard 4ffb9358d0 rename CustomRulesConfig to CustomRulesConfiguration 2016-02-12 10:53:36 -08:00
JP Simard 144495306b rename rule configurations to expand "Config" to "Configuration" 2016-02-12 10:53:36 -08:00
JP Simard b2d954f655 rename ConfigType to ConfigurationType 2016-02-12 10:53:36 -08:00
JP Simard 5ad4e88ac0 move RuleConfigs to RuleConfigurations 2016-02-12 10:53:36 -08:00
JP Simard 7e07e813ca rename RuleConfig to RuleConfiguration 2016-02-12 10:53:36 -08:00
JP Simard 6befe7e5a4 expand many instances of "config" to "configuration" 2016-02-12 10:53:36 -08:00
JP Simard d9cd1d670a rename Rule.init(config:) to Rule.init(configuration:) 2016-02-12 10:53:36 -08:00
JP Simard db71448c47 rename Rule.configDescription to Rule.configurationDescription 2016-02-12 10:53:36 -08:00
JP Simard 3f4b993847 rename ConfigProviderRule to ConfigurationProviderRule 2016-02-12 10:53:36 -08:00
JP Simard c662407c17 fix #522 2016-02-10 16:11:24 -08:00
JP Simard 7d0afb190b rename matchAndTokensPattern to rangesAndTokensMatching
also align regex pattern comments & fix indentation
2016-02-10 15:42:07 -08:00
Norio Nomura 83c008507b Improve performance of ColonRule
The duration of `ColonRule` on linting Carthage 0.13 is reduced from 1673ms to 515ms by Instruments.
2016-02-10 15:16:21 -08:00
Norio Nomura 03b237ecb2 Improve performance of FunctionParameterCountRule
The duration of `FunctionParameterCountRule` on linting Carthage 0.13 is reduced from 787ms to 208ms by Instruments.
2016-02-11 00:48:29 +09:00
JP Simard 31dc6b0a59 only correct legacy constructors if they're tokenized as identifiers 2016-02-08 14:22:02 -08:00
JP Simard 368ee9544a fold ConfigurableRule into Rule 2016-02-08 13:08:51 -08:00
JP Simard b7b4177dda Merge pull request #508 from realm/jp-improve-rules-table-configuration-description
make RulesCommand show a configuration description for all rules
2016-02-08 13:08:16 -08:00
JP Simard 3ccfa5780d Merge pull request #499 from realm/jp-fix-statement-position
fix inconsistencies between violations & corrections in StatementPositionRule
2016-02-07 15:50:30 -08:00
JP Simard 71135c6a4b make RulesCommand show a configuration description for all rules 2016-02-07 10:40:51 -08:00
JP Simard f3b6cc08f7 minor style change replacing '{ }' with '{}'
to stay consistent with other empty functions
2016-02-07 10:21:43 -08:00
JP Simard f4105b4502 fix inconsistencies between violations & corrections in StatementPositionRule 2016-02-07 10:13:27 -08:00
Ankit Aggarwal 41f59d6004 Ignore case of keywords for valid_docs 2016-02-07 22:29:19 +05:30
JP Simard 422b4a0b0b fix wording for function parameter count rule
fixes #504
2016-02-06 18:55:16 -08:00
Norio Nomura 3e3bb7bb90 Optimize excludingPattern in violatingOpeningBraceRanges()
Fix #491
By applying this, on linting KeychainAccess:
from(0.8.0):
```
swiftlint lint --config ~/.swiftlint-test.yml  29.61s user 0.18s system 98% cpu 30.175 total
```
to:
```
swiftlint lint --config ~/.swiftlint-test.yml  1.92s user 0.06s system 91% cpu 2.160 total
```
2016-02-06 16:16:15 +09:00
JP Simard b2a7b707ab print rule configuration 2016-02-03 10:31:53 -08:00
Scott Hoyt a723e146b4 Added corrections for if and multi-line if to OpeningBraceRule. 2016-02-02 17:16:13 -08:00
Scott Hoyt a8ba805f19 Added more triggering and non-triggering examples for OpeningBraceRule. 2016-02-02 17:16:13 -08:00
Scott Hoyt 9c910862b1 Modified exclusion regex for OpeningBraceRule. 2016-02-02 17:15:00 -08:00
Scott Hoyt 0ee04c3fa3 Added exclusion pattern for matching patterns in a file. Added Array and NSRange extensions to support. Used this in OpeningBraceRule. 2016-02-02 17:15:00 -08:00
Denis Lebedev a87253b5bf Measure complexity of nested functions separately 2016-02-02 16:18:27 -08:00
Denis Lebedev 22668504db Do not use 1 as initial value for Cyclomatic complexity 2016-02-02 15:56:37 -08:00
Denis Lebedev 71db85724e Improve switch statement complexity measure 2016-02-02 15:56:33 -08:00
Daniel Beard 5667ab889c Handle multiple groups 2016-02-02 10:37:49 -08:00
Daniel Beard 4e7325fbd4 Fix trailing_semicolon autocorrect to handle more than one violation per line 2016-02-02 10:29:10 -08:00