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

Issue:
Doesn't detect multi-line values if they contain a `=` sign
Example:

```env
MULTILINE="{
    'key': 'value='
}"
```

Result:

```
Checking .env
.env:1 QuoteCharacter: The value has quote characters (', ")
.env:2 IncorrectDelimiter: The 'key': 'value key has incorrect delimiter
.env:2 LeadingCharacter: Invalid leading character detected
.env:2 LowercaseKey: The 'key': 'value key should be in uppercase
.env:2 QuoteCharacter: The value has quote characters (', ")
.env:2 UnorderedKey: The 'key': 'value key should go before the MULTILINE key
.env:3 KeyWithoutValue: The }" key should be with a value or have an equal sign
.env:3 LeadingCharacter: Invalid leading character detected

Found 8 problems
```

Pull request:
fix: detect multi-line values if they contain a `=` sign
<!--
Thank you for your pull request. Please provide a description above and review
the requirements below.

Bug fixes and new features should include tests.
-->

This one is questionable. 
I've implemented it in standard way for `env` libraries and `bash`, but maybe there is a more suitable approach for the linter 🤔  (As I already mentioned in [previous PR's ](https://github.com/dotenv-linter/dotenv-linter/pull/453#discussion_r767277007))
It works well, but I mean it makes the `QuoteCharacterChecker` a little useless.


Closes #460

<!-- _Please make sure to review and check all of these items:_ -->

#### ✔ Checklist:
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [X] Commit messages have been written in [Conventional Commits](https://www.conventionalcommits.org) format;
- [X] This PR has been added to [CHANGELOG.md](https://github.com/dotenv-linter/dotenv-linter/blob/master/CHANGELOG.md) (at the top of the list);
- [X] Tests for the changes have been added (for bug fixes / features);
- [ ] Docs have been added / updated on the [dotenv-linter.github.io](https://github.com/dotenv-linter/dotenv-linter.github.io) (for bug fixes / features).

<!-- _NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open._ -->


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1908adb..739d205 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ ### 🔧 Changed
 - Change edition to 2021 [#444](https://github.com/dotenv-linter/dotenv-linter/pull/444) ([@mgrachev](https://github.com/mgrachev))
 - Display a message on installation error [#443](https://github.com/dotenv-linter/dotenv-linter/pull/443) ([@mgrachev](https://github.com/mgrachev))
 - Fix falling on checking multi-line values [#462](https://github.com/dotenv-linter/dotenv-linter/pull/462) ([@DDtKey](https://github.com/DDtKey))
+- Detect multi-line values if they contain a `=` sign [#463](https://github.com/dotenv-linter/dotenv-linter/pull/463) ([@DDtKey](https://github.com/DDtKey))
 
 ## [v3.1.1] - 2021-08-25
 ### 🚀 Added
diff --git a/src/lib.rs b/src/lib.rs
index 91f2a61..b39b862 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -286,9 +286,6 @@ fn find_multiline_ranges(lines: &[LineEntry]) -> Vec<(usize, usize)> {
                         multiline_ranges.push((start, entry.number));
                         start_number = None;
                     }
-                } else if entry.get_value().is_some() {
-                    // if next line correct env line - then previous start-line incorrect multi-value
-                    start_number = None;
                 }
             }
         } else if let Some(trimmed_value) = entry.get_value().map(|val| val.trim()) {


Test patch:
diff --git a/tests/fixes/fixtures/complicated.env b/tests/fixes/fixtures/complicated.env
index ffea37b..62be01a 100644
--- a/tests/fixes/fixtures/complicated.env
+++ b/tests/fixes/fixtures/complicated.env
@@ -60,8 +60,8 @@ ENV18="alpha12"
 ENV19=beta13
 .F=777
 key=VALUE
-ENV21='2
-ENV22="3
+ENV21=2
+ENV22=3
 # dotenv-linter:off QuoteCharacter
 VAR_7=1234
 VAR_6=1234
@@ -89,4 +89,13 @@ M_ENV3=" #yml file
   fields:
     first: 1
     second: 2
-"
\ No newline at end of file
+"
+M_ENV5='{
+    "val": "some=1"
+}'
+
+# test QuoteCharacter
+
+Q_KEY1='VALUE
+Q_KEY2="VALUE
+ENV25=1234
\ No newline at end of file
diff --git a/tests/fixes/fixtures/complicated.env.golden b/tests/fixes/fixtures/complicated.env.golden
index d72fc48..e3b6027 100644
--- a/tests/fixes/fixtures/complicated.env.golden
+++ b/tests/fixes/fixtures/complicated.env.golden
@@ -87,4 +87,13 @@ M_ENV3=" #yml file
 "
 M_ENV4="multiline \"escaped\"
     value"
+M_ENV5='{
+    "val": "some=1"
+}'
 ZOO=BAR
+
+# test QuoteCharacter
+
+ENV25=1234
+Q_KEY1=VALUE
+Q_KEY2=VALUE
diff --git a/tests/output/check.rs b/tests/output/check.rs
index 0ab266d..b361e18 100644
--- a/tests/output/check.rs
+++ b/tests/output/check.rs
@@ -46,9 +46,11 @@ fn valid_multiline_value_test() {
         "FOO=bar\nMULTILINE_1='{\n\"first\": 1,\n\"second\": 1\n}'\nMULTILINE_2='multiline \\'escaped\\' \n value'\nZAC=baz\n",
     );
     test_dir.create_testfile(".env1", "MULTILINE=\"\n{\n'key':'value'\n}\n\"\n");
+    test_dir.create_testfile(".env2", "MULTILINE=\"[\nkey=value\n]\"\n");
 
     let expected_output = r#"Checking .env
 Checking .env1
+Checking .env2
 
 No problems found
 "#;