Repository: dotenv-linter/dotenv-linter (Rust)

Issue:
DuplicatedKey: Show check name in message
Right now the message looks like this:
```
.env:2 The FOO key is duplicated
```

Need to add the check name to the message:
```
.env:2 DuplicatedKey: The FOO key is duplicated
```


Discussion:
Hello, I would like to take this issue.
@SaMuRa1ReM1X Sure! Thanks!



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ee4e815a..efb808470 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### 🚀 Added
 
 ### 🔧 Changed
+- DuplicatedKey: Show check name in message [#138](https://github.com/mgrachev/dotenv-linter/pull/138)([@SaMuRa1ReM1X](https://github.com/SaMuRa1ReM1X))
 - IncorrectDelimiter: Show check name in the message [#146](https://github.com/mgrachev/dotenv-linter/pull/146) ([undef1nd](https://github.com/undef1nd))
 - Replaced kcov with grcov in Github Actions [#143](https://github.com/mgrachev/dotenv-linter/pull/143) ([@pmk21](https://github.com/pmk21))
 - Streamline CLI tests and split into smaller files [#137](https://github.com/mgrachev/dotenv-linter/pull/137) ([@sonro](https://github.com/sonro))
diff --git a/src/checks/duplicated_key.rs b/src/checks/duplicated_key.rs
index e71e2c2c3..214b4f708 100644
--- a/src/checks/duplicated_key.rs
+++ b/src/checks/duplicated_key.rs
@@ -3,14 +3,22 @@ use crate::common::*;
 use std::collections::HashSet;
 
 pub(crate) struct DuplicatedKeyChecker {
+    name: String,
     template: String,
     keys: HashSet<String>,
 }
 
+impl DuplicatedKeyChecker {
+    fn message(&self, key: &str) -> String {
+        return format!("{}: {}", self.name, self.template.replace("{}", &key));
+    }
+}
+
 impl Default for DuplicatedKeyChecker {
     fn default() -> Self {
         Self {
             keys: HashSet::new(),
+            name: String::from("DuplicatedKey"),
             template: String::from("The {} key is duplicated"),
         }
     }
@@ -21,10 +29,7 @@ impl Check for DuplicatedKeyChecker {
         let key = line.get_key()?;
 
         if self.keys.contains(&key) {
-            return Some(Warning::new(
-                line.clone(),
-                self.template.replace("{}", &key),
-            ));
+            return Some(Warning::new(line.clone(), self.message(&key)));
         }
 
         self.keys.insert(key);
@@ -69,7 +74,7 @@ mod tests {
                         file_path: PathBuf::from(".env"),
                         raw_string: String::from("FOO=BAR"),
                     },
-                    String::from("The FOO key is duplicated"),
+                    String::from("DuplicatedKey: The FOO key is duplicated"),
                 )),
             ),
         ];
@@ -124,7 +129,7 @@ mod tests {
                         file_path: PathBuf::from(".env"),
                         raw_string: String::from("FOO=BAR"),
                     },
-                    String::from("The FOO key is duplicated"),
+                    String::from("DuplicatedKey: The FOO key is duplicated"),
                 )),
             ),
             (
@@ -147,7 +152,7 @@ mod tests {
                         file_path: PathBuf::from(".env"),
                         raw_string: String::from("BAR=FOO"),
                     },
-                    String::from("The BAR key is duplicated"),
+                    String::from("DuplicatedKey: The BAR key is duplicated"),
                 )),
             ),
         ];
@@ -178,7 +183,7 @@ mod tests {
                         file_path: PathBuf::from(".env"),
                         raw_string: String::from("FOO=BAR"),
                     },
-                    String::from("The FOO key is duplicated"),
+                    String::from("DuplicatedKey: The FOO key is duplicated"),
                 )),
             ),
             (
diff --git a/src/common.rs b/src/common.rs
index 5dacc733e..775d5c2a9 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -91,9 +91,15 @@ mod tests {
             file_path: PathBuf::from(".env"),
             raw_string: String::from("FOO=BAR"),
         };
-        let warning = Warning::new(line, String::from("The FOO key is duplicated"));
-
-        assert_eq!(".env:1 The FOO key is duplicated", format!("{}", warning));
+        let warning = Warning::new(
+            line,
+            String::from("DuplicatedKey: The FOO key is duplicated"),
+        );
+
+        assert_eq!(
+            ".env:1 DuplicatedKey: The FOO key is duplicated",
+            format!("{}", warning)
+        );
     }
 
     mod file_entry {


Test patch:
diff --git a/tests/cli_specific.rs b/tests/cli_specific.rs
index 0c26ef341..3bf065f62 100644
--- a/tests/cli_specific.rs
+++ b/tests/cli_specific.rs
@@ -70,7 +70,7 @@ fn checks_two_specific_files() {
 
     let args = &[testfile_2.as_str(), testfile_3.as_str()];
     let expected_output = format!(
-        "{}/{}:2 The FOO key is duplicated\n{}:1 The line has spaces around equal sign\n",
+        "{}/{}:2 DuplicatedKey: The FOO key is duplicated\n{}:1 The line has spaces around equal sign\n",
         testdir.relative_path(&subdir),
         testfile_3.shortname_as_str(),
         testfile_2.shortname_as_str(),
@@ -90,7 +90,7 @@ fn checks_one_specific_file_and_one_path() {
 
     let args = &[testfile_2.as_str(), subdir.as_str()];
     let expected_output = format!(
-        "{}/{}:2 The FOO key is duplicated\n{}:2 UnorderedKey: The BAR key should go before the FOO key\n",
+        "{}/{}:2 DuplicatedKey: The FOO key is duplicated\n{}:2 UnorderedKey: The BAR key should go before the FOO key\n",
         testdir.relative_path(&subdir),
         testfile_3.shortname_as_str(),
         testfile_2.shortname_as_str(),