Commit Graph

44 Commits

Author SHA1 Message Date
JP Simard 2bcea4b04d Add ability for SwiftLint to lint files with full type-checked AST awareness (#2379)
* Add LintableFilesVisitor

* Move LintCommand logic into LintOrAnalyzeCommand

to prepare for the upcoming analyze command

* Add AnalyzeCommand (not fully implemented yet in SwiftLintFramework)

* Add analyzerRules configuration member

* Add AnalyzerRule protocol

* Pass compiler arguments to validate/correct

* Add requiresFileOnDisk member to RuleDescription

This will be used by AnalyzerRules because they need a file on disk
to pass in the compiler arguments to SourceKit.

* Exclusively run AnalyzerRules when the Linter has compiler arguments

* Enable testing AnalyzerRules in TestHelpers

* Add ExplicitSelfRule

* Update documentation

* Fix `analyze --autocorrect`

* Improve performance of CompilerArgumentsExtractor

* Fix lint command actually running analyze

* Move File operations in TestHelpers into a private extension

* Add analyzer column to rules command and markdown documentation

* Use a Set literal

* Make AnalyzerRule inherit from OptInRule

* Mention analyzer_rules in readme

* Mention that analyzer rules are slow
2018-09-02 00:13:27 -07:00
JP Simard 6799b06f1b Refactor TestHelpers (#2378) 2018-09-01 13:52:02 -07:00
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00
Marcelo Fabri 5231f6c9a5 Support min Swift version in Rule description 2018-04-08 21:52:45 -07:00
Marcelo Fabri d21262d1bc Ignore SwiftLint commands in file_header rule
Fixes #1810
2017-09-30 00:29:23 -03:00
Marcelo Fabri 4fed36c772 Force using optional init 2017-08-20 23:34:24 +02:00
JP Simard 3fb9f8ec4a remove superfluous 'disable' commands 2017-08-20 23:27:48 +02:00
Stéphane Copin f86a99ee66 Split ConfigurationTests.swift file in multiple files 2017-08-02 13:06:08 -07:00
Stéphane Copin 9f1f454cf9 Refactor the way Configuration objects are created with regards to rules 2017-08-02 13:05:26 -07:00
Ornithologist Coder 83c47cc493 Update tests not to trigger xctfail_message_rule 2017-08-02 14:52:36 +02:00
Marcelo Fabri d79f642c43 Make file_header rule ignore doc comments.
Fixes #1719
2017-08-01 13:51:31 +02:00
Marcelo Fabri f6a28d9c33 Run tests against all rules 2017-07-26 10:20:02 +02:00
Marcelo Fabri c01f4bd19f Enable extension_access_modifier rule 2017-07-21 21:08:52 +02:00
JP Simard 99d13d14a3 remove workaround for SR-3448/SR-3449
as they were fixed in the 3.1 release
2017-05-25 07:58:04 -07:00
Samuel Susla 32e7963b68 Merge branch 'master' of https://github.com/realm/SwiftLint into trailing-comma-autocorrect 2017-04-09 20:31:02 +02:00
JP Simard 4881ce968e update testParseInvalidStringThrows for Yams 0.3.1 2017-04-06 13:22:29 -07:00
Samuel Susla 5c1336c81b Fix build on linux 2017-03-28 09:02:25 +01:00
Jeremy David Giesbrecht 491a6167a7 Fixed index processing in test infrastructure. 2017-03-25 17:19:22 -06:00
Marcelo Fabri d9eda655bf PR feedback 2017-01-02 17:49:54 -02:00
Marcelo Fabri a5683fa393 PR feedback 2017-01-02 16:21:10 -02:00
Marcelo Fabri 2e9e016723 Running "disable" tests on all aliases 2017-01-02 16:21:10 -02:00
Marcelo Fabri 55f7b04a6f Fixing existing violations 2016-12-26 18:44:37 -02:00
Marcelo Fabri 34f8538bfe Add changelog and bug tickets numbers 2016-12-18 01:46:09 -02:00
Marcelo Fabri fc13714f9a Testing multi-byte offsets in corrections 2016-12-18 01:07:51 -02:00
Marcelo Fabri d4d8d6dc19 Disabling tests on Linux 2016-12-18 01:07:51 -02:00
Marcelo Fabri 7665b04568 Add offset tests with multi-byte strings 2016-12-18 01:07:51 -02:00
Marcelo Fabri 1351fdb643 Fix violations for void_return rule 2016-12-13 10:41:08 -02:00
JP Simard 0faf567931 use bridge() rather than explict or implicit casts
this is a step in aligning the code to compile on both Darwin and
Linux
2016-12-11 13:47:44 -08:00
Marcelo Fabri 439040d74d Make swift test 2016-12-08 18:29:57 -02:00
Marcelo Fabri 13b0cfe623 Fixing inconsistencies 2016-12-08 18:29:57 -02:00
Marcelo Fabri 9f1294abfc Make it green 2016-12-08 18:29:57 -02:00
JP Simard 576e1a5d4d remove unnecessary .lowercased() calls
now that ViolationSeverity is already lowercase.
2016-12-01 22:29:09 -08:00
JP Simard 19fad01b29 make all enum members lowercase to comply with Swift 3 API Guidelines 2016-12-01 22:16:21 -08:00
Norio Nomura cc24409391 Apply reviews 2016-12-01 12:09:12 +09:00
Norio Nomura 6ba6be24fa Avoid line_length violation 2016-12-01 09:24:04 +09:00
Norio Nomura 523711061b Remove surplus assertions from triggeringExamples
Removed:
- Comparing total count of violations and expected locations from all triggering examples
- Comparing count of violations and expected locations on each triggering examples
- Order based comparison between violations and expected locations
2016-12-01 09:24:04 +09:00
Norio Nomura 76fd4b50a4 Produce detailed log when expected location of triggeringExample is not violated at.
e.g.
> /Users/norio/github/SwiftLint/Tests/SwiftLintFramework/TestHelpers.swift:180: error: -[SwiftLintFrameworkTests.RulesTests testMissingDocs] : failed - triggeringExample did not violate at expected location:
> ```
> public func a↓() {}
> ```
2016-12-01 09:22:58 +09:00
Norio Nomura ae14c90ba2 Produce detailed log when triggeringExample violated at unexpected location
e.g.
> /Users/norio/github/SwiftLint/Tests/SwiftLintFramework/TestHelpers.swift:173: error: -[SwiftLintFrameworkTests.RulesTests testMissingDocs] : failed - triggeringExample violate at unexpected location:
> ```
> public func a↓() {}
>        ^ warning: Missing Docs Violation: Public declarations should be documented. (missing_docs)
> ```
2016-12-01 09:22:58 +09:00
Norio Nomura 9436e67968 Produce detailed log when triggeringExample without expected location does not violate
e.g.
> /Users/norio/github/SwiftLint/Tests/SwiftLintFramework/TestHelpers.swift:159: error: -[SwiftLintFrameworkTests.RulesTests testValidDocs] : failed - triggeringExample did not violate:
> ```
> /// docs
> public func no() -> (Int, Int) {return (1, 2)}
> ```
2016-12-01 09:22:58 +09:00
Norio Nomura 1beed4b201 Produce detailed log of generated violations from nonTriggeringExamples
e.g.
> /Users/norio/github/SwiftLint/Tests/SwiftLintFramework/TestHelpers.swift:136: error: -[SwiftLintFrameworkTests.RulesTests testMissingDocs] : failed - nonTriggeringExample violated:
> ```
> /// docs
> public func a() {}
>        ^ warning: Missing Docs Violation: Public declarations should be documented. (missing_docs)
> ```
2016-12-01 09:22:58 +09:00
Norio Nomura 7593deff3f Merge commit 'b591ec71085572825616e9ac0ed15450198b52bb' into swift3.0
* commit 'b591ec71085572825616e9ac0ed15450198b52bb':
  minor Tests comment formatting
  ValidIBInspectableRule formatting
  fix typo in OverriddenSuperCallRule file name

# Conflicts:
#	Source/SwiftLintFramework/Rules/ValidIBInspectableRule.swift
2016-11-30 17:14:40 +09:00
Norio Nomura abecb87672 Merge commit 'aa520f35481c7a83f9c94f217d48919bd37432fa' into swift3.0
* commit 'aa520f35481c7a83f9c94f217d48919bd37432fa':
  make minor changes to tests for ACL or reusing existing constants

# Conflicts:
#	Tests/SwiftLintFrameworkTests/TestHelpers.swift
2016-11-30 13:01:00 +09:00
Norio Nomura aaf008c527 Merge commit '8f140ffdfe13c4f17398aa2d1256e2ed95bfdfe6' into swift3.0
* commit '8f140ffdfe13c4f17398aa2d1256e2ed95bfdfe6':
  improve debugging failing tests due to mismatched violation locations
  fix MarkRule edge cases

# Conflicts:
#	Source/SwiftLintFramework/Rules/MarkRule.swift
2016-11-30 12:54:47 +09:00
Norio Nomura 121d19b941 Support Swift Package Manager on macOS 2016-11-08 20:35:30 +09:00