Commit Graph

115 Commits

Author SHA1 Message Date
Danny Mösch d730e0b3fa Let all example verification tests be generated by Sourcery (#4076) 2022-08-10 22:49:28 +02:00
Danny Mösch 449190d324 Verify examples in rules by default and enforce explicit exclusion (#4065)
A rule must conform to ManuallyTestedExamplesRule to skip generation of a test for its examples.
2022-08-09 22:32:09 +02:00
Ryan Cole 43c84146db Add accessibility_label_for_image rule (#3862)
Warns if a SwiftUI Image does not have an accessibility label and is not hidden from accessibility. When this is the case, the image's accessibility label defaults to the name of the image file causing a poor UX.
2022-04-18 10:40:51 +02:00
Jan-Otto Kröpke 874cacbd1f Add codeclimate reporter (#3425) 2020-11-11 10:29:00 -08:00
Paul Taykalo 693ee2cae9 Add Isnot Empty extension in the Swift Framework (#3387) 2020-11-07 18:42:55 -05:00
Marcelo Fabri f8ef7d649c Enable legacy_multiple and prefer_self_type_over_type_of_self in our codebase 2020-08-05 01:11:17 -07:00
Alexander Chapliuk ef4a37ee1e JUnit reporter for GitLab artifact:report:junit (#3177)
* Add JUnit reporter for GitLab artifact:report:junit

* Added CHANGELOG entry

Co-authored-by: Alexander Chapliuk <2318002+krin-san@users.noreply.github.com>
2020-04-12 17:14:52 +03:00
JP Simard b744cf08f1 Temporarily remove all SwiftSyntax rules and support (#3107)
The new rules introduced in 0.39.0 that depend on SwiftSyntax have been temporarily removed as we work out release packaging issues.

* `prohibited_nan_comparison`
* `return_value_from_void_function`
* `tuple_pattern`
* `void_function_in_ternary`

See https://github.com/realm/SwiftLint/issues/3105 for details.
2020-02-11 13:40:04 -08:00
Marcelo Fabri 8d9c501cb8 Add optional return_value_from_void_function rule using SwiftSyntax (#3054)
* Add optional return_value_from_void_function rule using SwiftSyntax

* Use Script/bootstrap in CI

* Make SwiftSyntax optional

* Make SwiftSyntax optional in SPM

* Fix Package.swift

* Try again

* Add minSwiftVersion

* Fix thread sanitizer issue

* Take 2

* Fix false positive on nested computed variables

* Remove support for Xcode 10.x

* Fix rule description

* Enable opt-in rule in configuration file

* Extract code into `SyntaxRule` protocol

* nit: make property private

* Missing docs

* Fix MasterRuleList.swift

* Update CHANGELOG

* Remove unused imports

* Use Example type

* Change rule kind to .idiomatic

* Update CHANGELOG

* Bump deployment target to macOS 10.12

* Simplify SyntaxRule.validate(file:visitor)

* Make TSan happy

* Use script/bootstrap in the README
2020-02-08 02:43:40 -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
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 40ade98710 Update SourceKitten to 0.28.0 (#3011) 2020-01-03 16:47:18 -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
Paul Taykalo a52a94c987 Use Generic Dictionary Traversing for multiple cases 2019-11-09 13:29:43 -08:00
Paul Taykalo 523b2618c1 Update SubstitutionCorrectableASTRule for using inout array when traversing dictionaries 2019-11-09 13:29:42 -08:00
Paul Taykalo dfe61fab8d Faster dictionaries traversing for AST rules 2019-11-09 13:29:42 -08:00
Paul Taykalo ac40778cb3 Use SwiftLintFile wrapper over the File 2019-11-07 15:19:17 +02:00
Paul Taykalo b1cdc119ec Use swift enums instead of raw values 2019-11-07 11:05:19 +02:00
Paul Taykalo b901c670d4 Cache file structure dictionary 2019-11-07 08:50:50 +02:00
Paul Taykalo 8c963d2c15 Working solution with SouceKittenDictionary wrapper 2019-11-07 08:50:50 +02:00
Norio Nomura 80d3813214 Add GitHub Actions Logging reporter (github-actions-logging)
Use [GitHub Actions Logging](https://help.github.com/en/github/automating-your-workflow-with-github-actions/development-tools-for-github-actions#logging-commands) same as https://github.com/norio-nomura/action-swiftlint does.
2019-11-04 19:36:25 +09:00
Elliott Williams 3d5239429e Add AnyCollectingRule and isCollecting
All CollectingRules implement AnyCollectingRule, which is used to check
whether a linter will perform any collections and only print the
"Collecting" log message if so.
2019-07-18 14:59:42 -07:00
Elliott Williams f277fbe5d2 Make RuleStorage have dictionary semantics and check for collected info inside Rule 2019-07-18 14:59:42 -07:00
Elliott Williams ddee9c8e6b Refactor spacing, indenting, and rename collect to collectInfo 2019-07-18 14:59:42 -07:00
Elliott Williams 01ea736a46 Add CollectingRule to support arbitrary pre-lint collection 2019-07-18 14:59:42 -07:00
JP Simard 18c78684b0 Remove unused declarations (#2816) 2019-07-18 13:52:57 -07:00
Marcelo Fabri 51d47d492c contains_over_first_not_nil rule now also checks for firstIndex(where:)
Fixes #2678
2019-04-09 10:53:42 -07:00
Marcelo Fabri 5a0bf55f74 PR feedback 2019-01-27 14:04:24 -08:00
Marcelo Fabri a174126f28 Add missing import 2019-01-27 12:44:52 -08:00
Marcelo Fabri 5d4923f568 Add SubstitutionCorrectableRule and SubstitutionCorrectableASTRule 2019-01-27 12:32:10 -08:00
Marcelo Fabri 4b12e08731 Fix false positives on Realm collections 2018-12-25 18:41:53 -08:00
JP Simard 0e862ca9c4 Enable vertical whitespace rules in SwiftLint
and fix violations
2018-12-02 14:01:23 -08:00
Dani Vela b58c4e35bb Add markdown reporter (#2486) 2018-11-27 12:31:12 -08:00
Marcelo Fabri 1f121b1ef7 Enable static_operator opt-in rule in SwiftLint 2018-09-16 20:33:28 -07:00
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
Yusuke Ohashi a941b2f242 added SonarQube reporter. 2018-08-16 15:02:47 +09:00
Marcelo Fabri 8aadb802fb Split RulesTests into several test cases, generating them automatically 2018-07-21 17:23:08 -07:00
JP Simard 2eed8d469d Apply Marcelo Fabri's patch 2018-05-06 10:33:33 -07:00
John Szumski b03b4f0891 Added a new computed property that identifies whether a rule should treat multiple violations at the same location as only one violation. 2018-05-06 10:33:33 -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
Norio Nomura 2a0ac455bc 'flatMap' is deprecated: renamed to 'compactMap(_:)' 2018-04-08 13:28:09 +09:00
Tom Quist 9d75e39b3c * Added documentation for validate method in CallPairRule
* Made CallPairRule internal
* Fixed indentation of guard bodies
2017-11-07 08:41:40 +01:00
Tom Quist 7997192a70 Refactored ContainsOverFirstNotNilRule, FirstWhereRule and SortedFirstLastRule into new protocol CallPairRule to decrease code duplication 2017-11-07 00:23:10 +01:00
JP Simard a49835728b Speed up equality checks for [Rule] values 2017-10-19 22:28:04 -07:00
Marcelo Fabri be341f90b9 Introduce queuedFatalError
`fatalError` prints the full path of the file, which leaks filesystem information from the machine that built the binary. Now that we release via CocoaPods, this is more critical.
2017-09-30 15:07:23 -03:00
Marcelo Fabri c01f4bd19f Enable extension_access_modifier rule 2017-07-21 21:08:52 +02:00
JP Simard e54dcae5b7 enable let_var_whitespace rule in SwiftLint itself
and refactor code in a few places to conform to the rule
2017-07-10 15:42:55 -07:00
JP Simard f639ae95f1 add CacheDescriptionProvider protocol
to provide more complete descriptions for cache invalidation
purposes.
2017-05-18 14:31:33 -07:00
Marcelo Fabri ac4ea29150 Navigate substructure even for different kinds 2017-02-06 22:04:05 -02:00