Skip to content

Commit

Permalink
RuleSetProvider now implements Serializable interface.
Browse files Browse the repository at this point in the history
This is needed for better Gradle plugin support.
  • Loading branch information
Tapchicoma committed Mar 8, 2021
1 parent da8c3f6 commit 8954d4c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- New `ktlint_ignore_back_ticked_identifier` EditorConfig option for `max-line-length` rule to ignore long method names inside backticks
(primarily used in tests) ([#1007](https://github.com/pinterest/ktlint/issues/1007))
- Allow to add/replace loaded `.editorconfig` values via `ExperimentalParams#editorConfigOverride` ([#1016](https://github.com/pinterest/ktlint/issues/1003))
- `ReporterProvider` and `LintError` now implement `Serializable` interface
- `ReporterProvider`, `LintError`, `RuleSetProvider` now implement `Serializable` interface
### Fixed
- Incorrect indentation with multiple interfaces ([#1003](https://github.com/pinterest/ktlint/issues/1003))
- Empty line before primary constructor is not reported and formatted-out ([#1004](https://github.com/pinterest/ktlint/issues/1004))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.pinterest.ktlint.core

import java.io.Serializable

/**
* `ktlint` uses [ServiceLoader](http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html) to
* discover all available `RuleSetProvider`s on the classpath and so each `RuleSetProvider` must be registered using
* `META-INF/services/com.pinterest.ktlint.core.RuleSetProvider`
* (see `ktlint-ruleset-standard/src/main/resources` for an example).
*/
interface RuleSetProvider {
public interface RuleSetProvider : Serializable {

/**
* This method is going to be called once for each file (which means if any of the rules have state or
* are not thread-safe - a new RuleSet must be created).
*/
fun get(): RuleSet
public fun get(): RuleSet
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.pinterest.ktlint.ruleset.standard
import com.pinterest.ktlint.core.RuleSet
import com.pinterest.ktlint.core.RuleSetProvider

class StandardRuleSetProvider : RuleSetProvider {
public class StandardRuleSetProvider : RuleSetProvider {

// Note: some of these rules may be disabled by default. See the default .editorconfig.
override fun get(): RuleSet = RuleSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package yourpkgname
import com.pinterest.ktlint.core.RuleSet
import com.pinterest.ktlint.core.RuleSetProvider

class CustomRuleSetProvider : RuleSetProvider {
public class CustomRuleSetProvider : RuleSetProvider {

override fun get(): RuleSet = RuleSet("custom", NoVarRule())
}

0 comments on commit 8954d4c

Please sign in to comment.