Skip to content

Commit

Permalink
Update the error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
atulgpt committed May 15, 2023
1 parent 6e25045 commit abfbbfa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ internal object IdNamingPolicy {
* Will throw [IllegalArgumentException] on invalid [ruleId] name.
*/
internal fun enforceRuleIdNaming(ruleId: String) =
require(ruleId.matches(RULE_ID_REGEX)) { "Rule id '$ruleId' must match '${RULE_ID_REGEX.pattern}'" }
require(ruleId.matches(RULE_ID_REGEX)) {
"No ktlint rule with rule id '$ruleId' has been loaded. Please check " +
"spelling of the id which has to match regexp '${RULE_ID_REGEX.pattern}'"
}

/**
* Checks provided [ruleSetId] is valid.
*
* Will throw [IllegalArgumentException] on invalid [ruleSetId] name.
*/
internal fun enforceRuleSetIdNaming(ruleSetId: String) =
require(ruleSetId.matches(RULE_SET_ID_REGEX)) { "RuleSet id '$ruleSetId' must match '${RULE_SET_ID_REGEX.pattern}'" }
require(ruleSetId.matches(RULE_SET_ID_REGEX)) {
"No ktlint rule with ruleSet id '$ruleSetId' has been loaded. Please check spelling of the id which has " +
"to match regexp '${RULE_SET_ID_REGEX.pattern}'"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class RuleKtTest {
fun `Given a rule with an unqualified rule id than the rule can not be instantiated`() {
assertThatThrownBy { creatRule("some-unqualified-rule-id") }
.isInstanceOf(IllegalArgumentException::class.java)
.hasMessage("Rule id 'some-unqualified-rule-id' must match '[a-z]+(-[a-z]+)*:[a-z]+(-[a-z]+)*'")
.hasMessage(
"No ktlint rule with rule id 'some-unqualified-rule-id' has been loaded. Please check " +
"spelling of the id which has to match regexp '[a-z]+(-[a-z]+)*:[a-z]+(-[a-z]+)*'",
)
}

@ParameterizedTest(name = "Qualified rule id: `{0}`, expected rule id: `{1}`")
Expand Down

0 comments on commit abfbbfa

Please sign in to comment.