Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReporterProvider, LintError and RuleSetProvider now implement Serializable interface #1099

Merged
merged 3 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`, `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,5 +1,7 @@
package com.pinterest.ktlint.core

import java.io.Serializable

/**
* Lint error.
*
Expand All @@ -8,7 +10,12 @@ package com.pinterest.ktlint.core
* @param ruleId rule id (prepended with "<ruleSetId>:" in case of non-standard ruleset)
* @param detail error message
*/
data class LintError(val line: Int, val col: Int, val ruleId: String, val detail: String) {
public data class LintError(
val line: Int,
val col: Int,
val ruleId: String,
val detail: String
) : Serializable {

// fixme:
// not included in equals/hashCode for backward-compatibility with ktlint < 0.25.0
Expand All @@ -18,7 +25,7 @@ data class LintError(val line: Int, val col: Int, val ruleId: String, val detail
field = value
}

constructor(
public constructor(
line: Int,
col: Int,
ruleId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.pinterest.ktlint.core

import java.io.PrintStream
import java.io.Serializable

/**
* `ktlint` uses [ServiceLoader](http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html) to
* discover all available [ReporterProvider]s on the classpath and so each [ReporterProvider] must be registered using
* `META-INF/services/com.pinterest.ktlint.core.ReporterProvider`
* (see `ktlint-reporter-plain/src/main/resources` for an example).
*/
interface ReporterProvider {
val id: String
fun get(out: PrintStream, opt: Map<String, String>): Reporter
public interface ReporterProvider : Serializable {
public val id: String
public fun get(out: PrintStream, opt: Map<String, String>): Reporter
}
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 @@ -4,7 +4,7 @@ import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.core.ReporterProvider
import java.io.PrintStream

class BaselineReporterProvider : ReporterProvider {
public class BaselineReporterProvider : ReporterProvider {
override val id: String = "baseline"
override fun get(out: PrintStream, opt: Map<String, String>): Reporter = BaselineReporter(out)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.core.ReporterProvider
import java.io.PrintStream

class CheckStyleReporterProvider : ReporterProvider {
public class CheckStyleReporterProvider : ReporterProvider {
override val id: String = "checkstyle"
override fun get(out: PrintStream, opt: Map<String, String>): Reporter = CheckStyleReporter(out)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.core.ReporterProvider
import java.io.PrintStream

class HtmlReporterProvider : ReporterProvider {
public class HtmlReporterProvider : ReporterProvider {
override val id: String = "html"
override fun get(out: PrintStream, opt: Map<String, String>): Reporter = HtmlReporter(out)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.core.ReporterProvider
import java.io.PrintStream

class JsonReporterProvider : ReporterProvider {
public class JsonReporterProvider : ReporterProvider {
override val id: String = "json"
override fun get(out: PrintStream, opt: Map<String, String>): Reporter = JsonReporter(out)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.pinterest.ktlint.core.ReporterProvider
import com.pinterest.ktlint.reporter.plain.internal.Color
import java.io.PrintStream

class PlainReporterProvider : ReporterProvider {
public class PlainReporterProvider : ReporterProvider {

override val id: String = "plain"

Expand Down
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())
}