-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing customizations of KTlint as much as possible from diktat to …
…be able to move the project in separate repo. (#4) ### What's done: 1) Mainly rules-config.json handling was changed. Now it is integrated in code and should not be passed as separate config. 2) Tests were change, readme updated.
- Loading branch information
Showing
27 changed files
with
316 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 27 additions & 10 deletions
37
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
package org.cqfn.diktat.ruleset.rules | ||
|
||
import com.pinterest.ktlint.core.KtLint | ||
import com.pinterest.ktlint.core.Rule | ||
import com.pinterest.ktlint.core.RuleSet | ||
import com.pinterest.ktlint.core.RuleSetProvider | ||
import org.cqfn.diktat.common.config.rules.RulesConfig | ||
import org.cqfn.diktat.common.config.rules.RulesConfigReader | ||
|
||
class DiktatRuleSetProvider : RuleSetProvider { | ||
override fun get(): RuleSet = RuleSet( | ||
"diktat-ruleset", | ||
KdocComments(), | ||
KdocMethods(), | ||
KdocFormatting(), | ||
FileNaming(), | ||
PackageNaming(), | ||
IdentifierNaming() | ||
) | ||
/** | ||
* this constant will be used everywhere in the code to mark usage of Diktat ruleset | ||
*/ | ||
const val DIKTAT_RULE_SET_ID = "diktat-ruleset" | ||
|
||
class RuleSetDiktat(val rulesConfig: List<RulesConfig>, vararg rules: Rule) : RuleSet(DIKTAT_RULE_SET_ID, *rules) | ||
|
||
fun KtLint.Params.getDiktatConfigRules(): List<RulesConfig> { | ||
return (this.ruleSets.find { it.id == DIKTAT_RULE_SET_ID } as RuleSetDiktat).rulesConfig?: listOf() | ||
} | ||
|
||
class DiktatRuleSetProvider(private val jsonRulesConfig: String = "rules-config.json") : RuleSetProvider { | ||
override fun get(): RuleSet { | ||
return RuleSetDiktat( | ||
RulesConfigReader().readResource(jsonRulesConfig)?: listOf(), | ||
KdocComments(), | ||
KdocMethods(), | ||
KdocFormatting(), | ||
FileNaming(), | ||
PackageNaming(), | ||
IdentifierNaming() | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.