Repository: cqfn/diKTat
Pull request #408 (2020-10-16 08:20:51)

ENUM_VALUE styles support: snakeCase/pascalCase
## Which rule and warnings did you add?

I've added config value for ENUM_VALUE.
Not everyone prefer snake case: https://discuss.kotlinlang.org/t/enum-constants-uppercase-or-camecase/13984
So there should be a possibility to choose what you prefer

## Actions checklist
* [x] Implemented Rule, added Warnings
* [x] Added tests on checks
* [x] Added tests on fixers
* [x] Updated diktat-analysis.yml
* [x] Updated available-rules.md

## Fixme
Not sure how can I use different warning for each case


codecov[bot]: # [Codecov](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=h1) Report
> Merging [#408](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=desc) into [master](https://codecov.io/gh/cqfn/diKTat/commit/687284388e2e0314f6cbb8595618931eb1b6fef2?el=desc) will **decrease** coverage by `0.56%`.
> The diff coverage is `85.71%`.

[![Impacted file tree graph](https://codecov.io/gh/cqfn/diKTat/pull/408/graphs/tree.svg?width=650&height=150&src=pr&token=P2quRDffpt)](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=tree)

```diff
@@             Coverage Diff              @@
##             master     #408      +/-   ##
============================================
- Coverage     83.16%   82.59%   -0.57%     
- Complexity     1331     1343      +12     
============================================
  Files            65       65              
  Lines          3249     3292      +43     
  Branches       1027     1053      +26     
============================================
+ Hits           2702     2719      +17     
- Misses          176      177       +1     
- Partials        371      396      +25     
```

| Flag | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| #unittests | `82.59% <85.71%> (-0.57%)` | `1343.00 <0.00> (+12.00)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9JZGVudGlmaWVyTmFtaW5nLmt0) | `81.45% <84.61%> (-1.74%)` | `76.00 <0.00> (+4.00)` | :arrow_down: |
| [...tlin/org/cqfn/diktat/ruleset/constants/Warnings.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9jb25zdGFudHMvV2FybmluZ3Mua3Q=) | `97.11% <100.00%> (ø)` | `9.00 <0.00> (ø)` | |
| [...fn/diktat/common/config/rules/RulesConfigReader.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LWNvbW1vbi9zcmMvbWFpbi9rb3RsaW4vb3JnL2NxZm4vZGlrdGF0L2NvbW1vbi9jb25maWcvcnVsZXMvUnVsZXNDb25maWdSZWFkZXIua3Q=) | `35.71% <0.00%> (-7.15%)` | `4.00% <0.00%> (ø%)` | |
| [.../ruleset/rules/BracesInConditionalsAndLoopsRule.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9CcmFjZXNJbkNvbmRpdGlvbmFsc0FuZExvb3BzUnVsZS5rdA==) | `84.61% <0.00%> (-4.68%)` | `29.00% <0.00%> (ø%)` | |
| [...g/cqfn/diktat/ruleset/utils/FunctonASTNodeUtils.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC91dGlscy9GdW5jdG9uQVNUTm9kZVV0aWxzLmt0) | `69.23% <0.00%> (-3.85%)` | `0.00% <0.00%> (ø%)` | |
| [.../ruleset/rules/LongNumericalValuesSeparatedRule.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9Mb25nTnVtZXJpY2FsVmFsdWVzU2VwYXJhdGVkUnVsZS5rdA==) | `91.52% <0.00%> (-3.39%)` | `24.00% <0.00%> (ø%)` | |
| [...kotlin/org/cqfn/diktat/ruleset/rules/LineLength.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9MaW5lTGVuZ3RoLmt0) | `84.15% <0.00%> (-2.98%)` | `75.00% <0.00%> (+1.00%)` | :arrow_down: |
| [...diktat/ruleset/rules/comments/HeaderCommentRule.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9jb21tZW50cy9IZWFkZXJDb21tZW50UnVsZS5rdA==) | `86.25% <0.00%> (-2.50%)` | `36.00% <0.00%> (ø%)` | |
| [...tlin/org/cqfn/diktat/ruleset/utils/KotlinParser.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC91dGlscy9Lb3RsaW5QYXJzZXIua3Q=) | `85.10% <0.00%> (-2.13%)` | `18.00% <0.00%> (ø%)` | |
| [...cqfn/diktat/ruleset/rules/comments/CommentsRule.kt](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree#diff-ZGlrdGF0LXJ1bGVzL3NyYy9tYWluL2tvdGxpbi9vcmcvY3Fmbi9kaWt0YXQvcnVsZXNldC9ydWxlcy9jb21tZW50cy9Db21tZW50c1J1bGUua3Q=) | `97.95% <0.00%> (-2.05%)` | `19.00% <0.00%> (ø%)` | |
| ... and [16 more](https://codecov.io/gh/cqfn/diKTat/pull/408/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=footer). Last update [6872843...833c97f](https://codecov.io/gh/cqfn/diKTat/pull/408?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

akuleshov7: Yeah, agree with you, it should be configurable. But are you really using enums not in UPPER_SNAKE_CASE?
PhilipDukhov: > Awesome, thanks!!! <3
> Yeah, agree with you, it should be configurable. But are you really using enums not in UPPER_SNAKE_CASE?

Well, I came to Android development from iOS, and UPPER_SNAKE_CASE for me looks crazy 😁

Patch:
diff --git a/diktat-analysis.yml b/diktat-analysis.yml
index 0591b7ff..e3f311d5 100644
--- a/diktat-analysis.yml
+++ b/diktat-analysis.yml
@@ -10,7 +10,8 @@
   configuration: {}
 - name: ENUM_VALUE
   enabled: true
-  configuration: {}
+  configuration:
+    enumStyle: snakeCase
 - name: EXCEPTION_SUFFIX
   enabled: true
   configuration: {}
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
index 726fc187..582d570d 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/constants/Warnings.kt
@@ -28,7 +28,7 @@ enum class Warnings(private val canBeAutoCorrected: Boolean, private val warn: S
     CONSTANT_UPPERCASE(true, "<val> properties from companion object or on file level mostly in all cases are constants - please use upper snake case for them"),
     VARIABLE_HAS_PREFIX(true, "variable has prefix (like mVariable or M_VARIABLE), generally it is a bad code style (Android - is the only exception)"),
     IDENTIFIER_LENGTH(false, "identifier's length is incorrect, it should be in range of [2, 64] symbols"),
-    ENUM_VALUE(true, "in the same way as constants, enum values should be in UPPER_CASE snake format"),
+    ENUM_VALUE(true, "enum values should be in selected UPPER_CASE snake/PascalCase format"),
     GENERIC_NAME(true, "generic name should contain only one single capital letter, it can be followed by a number"),
     FUNCTION_NAME_INCORRECT_CASE(true, "function/method name should be in lowerCamelCase"),
     FUNCTION_BOOLEAN_PREFIX(true, "functions that return the value of Boolean type should have <is> or <has> prefix"),
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt
index eae39cb6..aa0a981c 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/IdentifierNaming.kt
@@ -10,7 +10,9 @@ import com.pinterest.ktlint.core.ast.ElementType.FUNCTION_TYPE
 import com.pinterest.ktlint.core.ast.ElementType.TYPE_REFERENCE
 import com.pinterest.ktlint.core.ast.ElementType.VALUE_PARAMETER_LIST
 import com.pinterest.ktlint.core.ast.prevCodeSibling
+import org.cqfn.diktat.common.config.rules.RuleConfiguration
 import org.cqfn.diktat.common.config.rules.RulesConfig
+import org.cqfn.diktat.common.config.rules.getRuleConfig
 import org.cqfn.diktat.ruleset.constants.Warnings.BACKTICKS_PROHIBITED
 import org.cqfn.diktat.ruleset.constants.Warnings.CLASS_NAME_INCORRECT
 import org.cqfn.diktat.ruleset.constants.Warnings.CONSTANT_UPPERCASE
@@ -45,6 +47,7 @@ import org.cqfn.diktat.ruleset.utils.removePrefix
 import org.cqfn.diktat.ruleset.utils.toLowerCamelCase
 import org.cqfn.diktat.ruleset.utils.toPascalCase
 import org.cqfn.diktat.ruleset.utils.toUpperSnakeCase
+import org.cqfn.diktat.ruleset.utils.Style
 import org.jetbrains.kotlin.builtins.PrimitiveType
 import org.jetbrains.kotlin.com.intellij.lang.ASTNode
 import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
@@ -291,10 +294,20 @@ class IdentifierNaming(private val configRules: List<RulesConfig>) : Rule("ident
     private fun checkEnumValues(node: ASTNode): List<ASTNode> {
         val enumValues: List<ASTNode> = node.getChildren(null).filter { it.elementType == ElementType.IDENTIFIER }
         enumValues.forEach { value ->
-            if (!value.text.isUpperSnakeCase()) {
+            val configuration = IdentifierNamingConfiguration(configRules.getRuleConfig(ENUM_VALUE)?.configuration
+                    ?: mapOf())
+            val validator = when (configuration.enumStyle) {
+                Style.PASCAL_CASE -> String::isPascalCase
+                Style.SNAKE_CASE -> String::isUpperSnakeCase
+            }
+            val autofix = when (configuration.enumStyle) {
+                Style.PASCAL_CASE -> String::toPascalCase
+                Style.SNAKE_CASE -> String::toUpperSnakeCase
+            }
+            if (!validator(value.text)) {
                 ENUM_VALUE.warnAndFix(configRules, emitWarn, isFixMode, value.text, value.startOffset, value) {
                     // FixMe: add tests for this
-                    (value as LeafPsiElement).replaceWithText(value.text.toUpperSnakeCase())
+                    (value as LeafPsiElement).replaceWithText(autofix(value.text))
                 }
             }
 
@@ -378,4 +391,19 @@ class IdentifierNaming(private val configRules: List<RulesConfig>) : Rule("ident
         val prevCatchKeyWord = parentValueParamList?.prevCodeSibling()?.elementType == CATCH_KEYWORD
         return node.text == "e" && node.findParentNodeWithSpecificType(CATCH) != null && prevCatchKeyWord
     }
+
+    class IdentifierNamingConfiguration(config: Map<String, String>) : RuleConfiguration(config) {
+        private val Style.isEnumStyle: Boolean
+            get() = listOf(Style.PASCAL_CASE, Style.SNAKE_CASE).contains(this)
+
+        val enumStyle = config["enumStyle"]?.let { styleString ->
+            val style = Style.values().firstOrNull {
+                it.name == styleString.toUpperSnakeCase()
+            }
+            if (style == null || !style.isEnumStyle) {
+                error("$styleString is unsupported for enum style")
+            }
+            style
+        } ?: Style.SNAKE_CASE
+    }
 }
diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt
index c776d21f..9974d515 100644
--- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt
+++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt
@@ -158,3 +158,8 @@ private fun convertUnknownCaseToUpperSnake(str: String): String {
 
 private fun String.getFirstLetterOrDigit() =
         indexOfFirst { it.isLetterOrDigit() }
+
+enum class Style {
+    PASCAL_CASE,
+    SNAKE_CASE,
+}
diff --git a/info/available-rules.md b/info/available-rules.md
index 9c1f022e..4847da44 100644
--- a/info/available-rules.md
+++ b/info/available-rules.md
@@ -15,7 +15,7 @@
 |    1 |      1.6 | CONSTANT_UPPERCASE                      | Check: warns if CONSTANT (treated as const val from companion object or class level) is in non UPPER_SNAKE_CASE<br>Fix: name is changed to UPPER_SNAKE_CASE| yes | no |Recursively update usages of this identifier in the project|
 |    1 |      1.5 | VARIABLE_HAS_PREFIX                     | Check: warns if variable has prefix (like mVariable or M_VARIABLE), generally it is a bad code style (Android - is the only exception<br>Fix: no fix as we are not able to imagine good name by machine| no | no |may be we can fix it, but I do not see any sense for it|
 |    1 |      1.2 | IDENTIFIER_LENGTH                       | Check: identifier length should be in range [2,64] except names that used in industry like {i, j} and 'e' for catching exceptions.<br>Fix: no fix as we are not able to imagine good name by machine          | no | no |May be make this rule configurable (length)|
-|    1 |      1.4 | ENUM_VALUE                              | Check:  warns if enum value is in non UPPER_SNAKE_CASE<br>Fix: automatically converting case to UPPER_SNAKE_CASE                                                             | yes | no |Recursively update usages of this identifier in the project|
+|    1 |      1.4 | ENUM_VALUE                              | Check: warns if enum value is in non UPPER_SNAKE_CASE or non PascalCase depending on the config, UPPER_SNAKE_CASE by default<br>Fix: automatically converting case to selected case| yes | enumStyle: snakeCase, pascalCase |Recursively update usages of this identifier in the project|
 |    1 |      1.2 | GENERIC_NAME                            | Check: warns if generic name contains more than 1 letter (capital). It can be followed by numbers, example: T12, T<br>Fix:                                                   | yes | no |Recursively update usages of this identifier in the project|
 |    1 |      1.5 | FUNCTION_NAME_INCORRECT_CASE            | Check: function/method name should be in lowerCamelCase:<br>Fix:                                                                                                             | yes | no |Recursively update usages of this function in the project|
 |    1 |      1.5 | FUNCTION_BOOLEAN_PREFIX                 | Check: functions/methods that return boolean should have special prefix like "is/should/e.t.c"<br>Fix:                                                                       | yes | no |Recursively update usages of this function in the projectAggressive fix - what if new name will not be valid|


Test patch:
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/EnumValueCaseTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/EnumValueCaseTest.kt
index 3af85e43..3a88b2c5 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/EnumValueCaseTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/EnumValueCaseTest.kt
@@ -1,16 +1,51 @@
 package org.cqfn.diktat.ruleset.chapter1
 
 import generated.WarningNames
+import org.cqfn.diktat.common.config.rules.RulesConfig
+import org.cqfn.diktat.common.config.rules.getRuleConfig
+import org.cqfn.diktat.ruleset.constants.Warnings
 import org.cqfn.diktat.ruleset.rules.IdentifierNaming
 import org.cqfn.diktat.util.FixTestBase
 import org.junit.jupiter.api.Tag
 import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.assertThrows
 
 class EnumValueCaseTest : FixTestBase("test/paragraph1/naming", ::IdentifierNaming) {
+    private val rulesConfigSnakeCaseEnum: List<RulesConfig> = listOf(
+            RulesConfig(Warnings.ENUM_VALUE.name, true,
+                    mapOf("enumStyle" to "snakeCase"))
+    )
+
+    private val rulesConfigPascalCaseEnum: List<RulesConfig> = listOf(
+            RulesConfig(Warnings.ENUM_VALUE.name, true,
+                    mapOf("enumStyle" to "pascalCase"))
+    )
+
+    private val rulesConfigEnumUnknownStyle: List<RulesConfig> = listOf(
+            RulesConfig(Warnings.ENUM_VALUE.name, true,
+                    mapOf("enumStyle" to "otherCase"))
+    )
+
+    @Test
+    @Tag(WarningNames.ENUM_VALUE)
+    fun `incorrect enum snake case value fix`() {
+        fixAndCompare("enum_/EnumValueSnakeCaseExpected.kt", "enum_/EnumValueSnakeCaseTest.kt", rulesConfigSnakeCaseEnum)
+    }
+
+    @Test
+    @Tag(WarningNames.ENUM_VALUE)
+    fun `incorrect enum pascal case value fix`() {
+        fixAndCompare("enum_/EnumValuePascalCaseExpected.kt", "enum_/EnumValuePascalCaseTest.kt", rulesConfigPascalCaseEnum)
+    }
 
     @Test
     @Tag(WarningNames.ENUM_VALUE)
-    fun `incorrect enum value fix`() {
-        fixAndCompare("enum_/EnumValueCaseExpected.kt", "enum_/EnumValueCaseTest.kt")
+    fun `incorrect enum unknown style`() {
+        assertThrows<IllegalStateException> {
+            IdentifierNaming.IdentifierNamingConfiguration(
+                    rulesConfigEnumUnknownStyle.getRuleConfig(Warnings.ENUM_VALUE)
+                            ?.configuration ?: mapOf()
+            )
+        }
     }
 }
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingFixTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingFixTest.kt
index 6f1d527a..c52f1b47 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingFixTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingFixTest.kt
@@ -30,7 +30,7 @@ class IdentifierNamingFixTest : FixTestBase(
     @Test
     @Tag(WarningNames.ENUM_VALUE)
     fun `incorrect enum values case fix`() {
-        fixAndCompare("enum_/EnumValueCaseExpected.kt", "enum_/EnumValueCaseTest.kt")
+        fixAndCompare("enum_/EnumValueSnakeCaseExpected.kt", "enum_/EnumValueSnakeCaseTest.kt")
     }
 
     @Test
diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt
index 48c3709a..7b852e2e 100644
--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt
+++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter1/IdentifierNamingWarnTest.kt
@@ -2,6 +2,7 @@ package org.cqfn.diktat.ruleset.chapter1
 
 import com.pinterest.ktlint.core.LintError
 import generated.WarningNames
+import org.cqfn.diktat.common.config.rules.RulesConfig
 import org.cqfn.diktat.ruleset.constants.Warnings
 import org.cqfn.diktat.ruleset.constants.Warnings.BACKTICKS_PROHIBITED
 import org.cqfn.diktat.ruleset.constants.Warnings.CLASS_NAME_INCORRECT
@@ -206,14 +207,38 @@ class IdentifierNamingWarnTest : LintTestBase(::IdentifierNaming) {
         val code =
                 """
                   enum class TEST_ONE {
-                    first_value, secondValue, thirdVALUE
+                    first_value, secondValue, thirdVALUE, FourthValue
                   }
                 """.trimIndent()
         lintMethod(code,
                 LintError(1, 12, ruleId, "${CLASS_NAME_INCORRECT.warnText()} TEST_ONE", true),
                 LintError(2, 3, ruleId, "${ENUM_VALUE.warnText()} first_value", true),
                 LintError(2, 16, ruleId, "${ENUM_VALUE.warnText()} secondValue", true),
-                LintError(2, 29, ruleId, "${ENUM_VALUE.warnText()} thirdVALUE", true)
+                LintError(2, 29, ruleId, "${ENUM_VALUE.warnText()} thirdVALUE", true),
+                LintError(2, 41, ruleId, "${ENUM_VALUE.warnText()} FourthValue", true)
+        )
+    }
+
+    @Test
+    @Tags(Tag(WarningNames.ENUM_VALUE), Tag(WarningNames.CLASS_NAME_INCORRECT))
+    fun `check case for pascal case enum values (check - negative)`() {
+        val code =
+                """
+                  enum class TEST_ONE {
+                    first_value, secondValue, thirdVALUE, FOURTH_VALUE
+                  }
+                """.trimIndent()
+        val rulesConfigPascalCaseEnum: List<RulesConfig> = listOf(
+                RulesConfig(ENUM_VALUE.name, true,
+                        mapOf("enumStyle" to "pascalCase"))
+        )
+        lintMethod(code,
+                LintError(1, 12, ruleId, "${CLASS_NAME_INCORRECT.warnText()} TEST_ONE", true),
+                LintError(2, 3, ruleId, "${ENUM_VALUE.warnText()} first_value", true),
+                LintError(2, 16, ruleId, "${ENUM_VALUE.warnText()} secondValue", true),
+                LintError(2, 29, ruleId, "${ENUM_VALUE.warnText()} thirdVALUE", true),
+                LintError(2, 41, ruleId, "${ENUM_VALUE.warnText()} FOURTH_VALUE", true),
+                rulesConfigList = rulesConfigPascalCaseEnum
         )
     }
 
diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseExpected.kt
new file mode 100644
index 00000000..551e568f
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseExpected.kt
@@ -0,0 +1,10 @@
+package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_
+
+enum class EnumValuePascalCaseTest {
+    PaScSalL,
+    PascAslF,
+    StartPsaaaDfe,
+    NameMyaSayR,
+    NameMyaSayR
+}
+
diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseTest.kt
new file mode 100644
index 00000000..5da4f6c6
--- /dev/null
+++ b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValuePascalCaseTest.kt
@@ -0,0 +1,10 @@
+package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_
+
+enum class EnumValuePascalCaseTest {
+    paSC_SAl_l,
+    PascAsl_f,
+    START_PSaaa_DFE,
+    _NAme_MYa_sayR,
+    NAme_MYa_sayR_
+}
+
diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseExpected.kt
similarity index 82%
rename from diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseExpected.kt
rename to diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseExpected.kt
index 24e28c09..d628cf3d 100644
--- a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseExpected.kt
+++ b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseExpected.kt
@@ -1,6 +1,6 @@
 package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_
 
-enum class EnumValueCaseTest {
+enum class EnumValueSnakeCaseTest {
     PA_SC_SAL_L,
     PASC_ASL_F,
     START_PSAAA_DFE,
diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseTest.kt
similarity index 81%
rename from diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseTest.kt
rename to diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseTest.kt
index 8d7cf8d4..01fac4ea 100644
--- a/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueCaseTest.kt
+++ b/diktat-rules/src/test/resources/test/paragraph1/naming/enum_/EnumValueSnakeCaseTest.kt
@@ -1,6 +1,6 @@
 package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_
 
-enum class EnumValueCaseTest {
+enum class EnumValueSnakeCaseTest {
     paSC_SAl_l,
     PascAsl_f,
     START_PSaaa_DFE,