Commit Graph
44 Commits
Author SHA1 Message Date
JP Simard 86d60400c1 Move core SwiftLint functionality to new SwiftLintCore module
Over the years, SwiftLintFramework had become a fairly massive monolith,
containing over 400 source files with both core infrastructure and
rules.

Architecturally, the rules should rely on the core infrastructure but
not the other way around. There are two exceptions to this:
`custom_rules` and `superfluous_disable_command` which need special
integration with the linter infrastructure.

Now the time has come to formalize this architecture and one way to do
that is to move the core SwiftLint functionality out of
SwiftLintFramework and into a new SwiftLintCore module that the rules
can depend on.

Beyond enforcing architectural patterns, this also has the advantage of
speeding up incremental compilation by skipping rebuilding the core
functionality when iterating on rules.

Because the core functionality is always useful when building rules, I'm
opting to import SwiftLintCore in SwiftLintFramework as `@_exported` so
that it's implicitly available to all files in SwiftLintFramework
without needing to import it directly.

In a follow-up I'll also split the built-in rules and the extra rules
into their own modules. More modularization is possible from there, but
not planned.

The bulk of this PR just moves files from `Source/SwiftLintFramework/*`
to `Source/SwiftLintCore/*`. There are some other changes that can't be
split up into their own PRs:

* Change jazzy to document the SwiftLintCore module instead of
  SwiftLintFramework.
* Change imports in unit tests to reflect where code was moved to.
* Update `sourcery` make rule to reflect where code was moved to.
* Create a new `coreRules` array and register those rules with the
  registry. This allows the `custom_rules` and
  `superfluous_disable_command` rule implementations to remain internal
  to the SwiftLintCore module, preventing more implementation details
  from leaking across architectural layers.
* Move `RuleRegistry.registerAllRulesOnce()` out of the type declaration
  and up one level so it can access rules defined downstream from
  SwiftLintCore.
2023-04-26 21:10:19 -04:00
JP Simard 4c04cdafa7 Introduce SwiftLintTestCase
To consistently set up rules before tests
2023-04-25 12:28:50 -04:00
Danny MöschandGitHub 3d15419adb Fix warnings in Swift 5.8/Xcode 14.3 (#4850) 2023-03-31 22:13:20 +02:00
Martin RedingtonandGitHub ca43d2359b Fix unit test configuration (#4847) 2023-03-30 22:46:31 +02:00
Danny Mösch 06578e5d91 Get rid of some more disabled commands 2023-03-12 00:03:02 +01:00
Danny Mösch e64e82d80d Get rid of periods finishing rule descriptions 2023-01-10 22:29:13 +01:00
Marcelo FabriandGitHub db2721f78e Require Swift 5.0 in runtime (#3886)
* Require Swift 5.0 in runtime

* Fix violation

* Enable legacy_rule by default

* Update changelog

* Fix changelog after rebase

* More cleanup
2022-03-11 14:01:27 -08:00
Frederick Pietschmann 4c5a3f0577 Add remote, parent & child configuration features 2020-11-20 23:08:37 +01:00
Dalton ClaybrookandGitHub d305e03905 Add inclusive_language rule (#3243)
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
2020-11-07 22:03:08 -05:00
Marcelo Fabri 1f5ee4d9fd Run tests on Xcode 12 as well 2020-08-04 02:45:42 -07:00
JP SimardandGitHub 345933ebb1 Run CI on Linux Swift 5.2 (#3199)
* Run CI on Linux Swift 5.2

* fixup! Run CI on Linux Swift 5.2

* Move SwiftVersion tests to its own file
2020-05-06 14:16:17 -07:00
JP SimardandGitHub bc4b7d2962 Update CI to run jobs with Xcode 11.0 to 11.4 (#3168)
* Update CI to run jobs with Xcode 11.0 to 11.4

In the process, remove CI jobs running with Swift 5.0.x and indicate
in the changelog that the next release will be the last one to support
building with Swift 5.0.x.

* fixup! Update CI to run jobs with Xcode 11.0 to 11.4

* fixup! Update CI to run jobs with Xcode 11.0 to 11.4

* fixup! Update CI to run jobs with Xcode 11.0 to 11.4

* fixup! Update CI to run jobs with Xcode 11.0 to 11.4

* Disable Swift 5.2 tests on Linux due to SR-12500

* Update ruby gems

Mostly to get jazzy 0.13.2 with Swift 5.2 bug fixes.
2020-04-03 18:06:22 -07:00
JP SimardandGitHub c201ae43e6 Simplify regex (#3145)
* Simplify regex

`\w` already includes `_`

* Fix test
2020-03-18 16:23:52 -07:00
Marcelo FabriandGitHub c47db1b093 Fix testDetectSwiftVersion with Swift 5.2 (#3093) 2020-02-09 16:20:52 -08:00
Marcelo FabriandGitHub 0991ede1ed Fix tests on Linux (#3084) 2020-02-08 02:05:35 -08:00
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 SimardandGitHub beaa2a8a87 Update Commandant and SourceKitten, drop Result (#2947) 2019-11-07 10:59:16 -08:00
Marcelo Fabri 31ca623eb0 Fix unit test 2019-10-13 23:43:07 -07:00
JP SimardandGitHub 3a0c2b0c05 Migrate LinterCache to use Codable models (#2799)
* Migrate LinterCache to use Codable models

improving performance and type safety

* Fix Linux

* Avoid creating a Decoder if it won't be used

For example if the file doesn't exist or can't be read.

* Use corelibs plist coder if available

It's available in the Swift 5.1 branch: https://github.com/apple/swift-corelibs-foundation/pull/1849

* Remove unused error case
2019-07-07 00:35:10 -07:00
Marcelo Fabri 596bf8dbc8 Detect parameter attribute in vertical_parameter_alignment
Fixes #2792
2019-07-04 10:42:11 -07:00
Marcelo FabriandJP Simard 3a36212b94 Swift 5 support (#2720)
* Update project to compile with Xcode 10.2

* Fix explicit_acl with Swift 5

* Update macOS VM image

* Fix ConfigurationTests on Swift 5

* Update Podspec

* Workaround SR-10486 to fix validation tests

* Fix testDetectSwiftVersion on Swift 5

* Update specs repo when validating CocoaPods spec

* Fix redundant_set_access_control tests

* Manually update Package.resolved

* Use .upToNextMinor

* [Azure Pipelines] Add `sw_vers`

* Relax expecting conditions for crashing output in `testSimulateHomebrewTest()`

Because TSAN makes `swiflint` to produce additional output on crashing.

* Add CHANGELOG entry

* Ignore extensions in explicit ACL rules

* Work around SR-10486 for Sourcery
2019-04-28 21:10:06 -07:00
JP Simard 0e862ca9c4 Enable vertical whitespace rules in SwiftLint
and fix violations
2018-12-02 14:01:23 -08:00
Norio Nomura 093b99bea7 Fix LinterCacheTests.testDetectSwiftVersion for Swift 4.2 2018-07-20 08:30:25 +09:00
Norio Nomura 6bcabfe5f8 Detect swift-4.1.2 2018-05-13 21:39:57 +09: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 878d9d3bff Fix identifier_name violation 2018-04-08 13:28:09 +09:00
Norio Nomura c592538856 Add 4.1.0, 4.1.1 and 4.2.0 to Swift version detection 2018-04-05 10:29:54 +09:00
Marcelo Fabri ae0e21f0f8 Fix crash when saving cache
Fixes #2032
2018-03-24 21:23:14 -07:00
Norio Nomura d460c6d124 Invalidate cache when Swift patch version changes 2017-11-16 11:03:08 +09:00
JP Simard cc9e61830a Fix testSwiftVersionChangedRemovedCausesAllFilesToBeReLinted()
since it was assuming to be running in Swift 3 mode
2017-08-21 13:05:39 -07:00
Marcelo Fabri 0a07628d8c Invalidate cache when Swift version changes 2017-08-21 00:19:04 +02:00
J Cheyo JimenezandMarcelo Fabri e72d09bc31 added fileprivateRule 2017-07-03 01:09:42 +02:00
Marcelo FabriandMarcelo Fabri fd231b607d Fix existing violations 2017-06-13 16:12:58 +02:00
JP Simard 25a92c4e03 automatically generate LinuxMain.swift using Sourcery
This adds 6 tests that were accidentally not being run on Linux:

* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresComments
* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresFunctionDeclarations
* LineLengthConfigurationTests.testLineLengthConfigurationThrowsOnBadConfigValues
* LineLengthRuleTests.testLineLengthWithIgnoreCommentsEnabled
* LineLengthRuleTests.testLineLengthWithIgnoreFunctionDeclarationsEnabled
* RegionTests.testSeveralRegionsFromSeveralCommands
2017-06-02 14:28:37 -07:00
Marcelo Fabri 9a5e30e794 Split cache into read cache and write cache 2017-05-24 17:03:51 +02:00
JP Simard 186231e1a4 rewrite cache tests 2017-05-18 14:53:39 -07:00
JP Simard 690b567421 simplify serialized cache structure 2017-05-18 14:40:40 -07:00
Víctor PimentelandJP Simard 5ed010c9c0 Change LinterCache to use file modification dates instead of hashing files with a weak algorithm. 2017-05-18 13:39:05 -07:00
JP Simard 41251d8bb1 run LinterCacheTests on Linux 2017-01-10 15:47:45 -08:00
Marcelo Fabri 94f48f4ebd PR feedback 2017-01-10 13:09:18 -02:00
Marcelo Fabri 3d376241be Moving cache usage to the linter 2016-12-31 00:26:05 -02:00
Marcelo Fabri a47385a64f Ignore cache if configuration has changed 2016-12-31 00:24:54 -02:00
Marcelo Fabri 9d42a73d26 Add more tests 2016-12-31 00:24:54 -02:00
Marcelo Fabri b1f62e2b63 Add some tests 2016-12-31 00:24:54 -02:00