-
Notifications
You must be signed in to change notification settings - Fork 39
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
Feature. Ktlint rule wrapper #744
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd6e597
feature/ktlint-rule-wrapper(#606)
aktsay6 84cf9d4
* feature/ktlint-rule-wrapper(#606)
aktsay6 019ea91
* feature/ktlint-rule-wrapper(#606)
aktsay6 a5d178e
feature/ktlint-rule-wrapper(#606)
aktsay6 988ed05
feature/ktlint-rule-wrapper(#606)
aktsay6 6ab619b
feature/ktlint-rule-wrapper(#606)
aktsay6 d72624f
feature/ktlint-rule-wrapper(#606)
aktsay6 b79fd2e
feature/ktlint-rule-wrapper(#606)
aktsay6 59b993d
feature/ktlint-rule-wrapper(#606)
aktsay6 b847b98
feature/ktlint-rule-wrapper(#606)
aktsay6 004a54b
feature/ktlint-rule-wrapper(#606)
aktsay6 aeb3242
feature/ktlint-rule-wrapper(#606)
aktsay6 66663ec
Merge branch 'master' into feature/ktlint-rule-wrapper(#606)
aktsay6 240d4a7
feature/ktlint-rule-wrapper(#606)
aktsay6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||
package org.cqfn.diktat.ruleset.rules | ||||||
|
||||||
import com.pinterest.ktlint.core.Rule | ||||||
import org.cqfn.diktat.common.config.rules.RulesConfig | ||||||
import org.cqfn.diktat.common.config.rules.isRuleEnabled | ||||||
import org.cqfn.diktat.ruleset.constants.EmitType | ||||||
import org.cqfn.diktat.ruleset.utils.log | ||||||
import org.jetbrains.kotlin.com.intellij.lang.ASTNode | ||||||
|
||||||
typealias DiktatConfigRule = org.cqfn.diktat.common.config.rules.Rule | ||||||
|
||||||
abstract class DiktatRule(id: String, val configRules: List<RulesConfig>, val rules: List<DiktatConfigRule>): Rule(id) { | ||||||
var isFixMode: Boolean = false | ||||||
lateinit var emitWarn: EmitType | ||||||
|
||||||
override fun visit(node: ASTNode, autoCorrect: Boolean, emit: EmitType) { | ||||||
emitWarn = emit | ||||||
isFixMode = autoCorrect | ||||||
|
||||||
if (check()) return | ||||||
else { | ||||||
try { | ||||||
logic(node) | ||||||
} catch (e: Exception) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
log.error("Internal error has occurred in $id. Please make an issue on this bug at https://github.com/cqfn/diKTat/.\n Error: ${e.message}") | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
private fun check(): Boolean { | ||||||
return rules.none { configRules.isRuleEnabled(it) } | ||||||
} | ||||||
abstract fun logic(node: ASTNode) | ||||||
} |
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it used only in this file?