-
-
Notifications
You must be signed in to change notification settings - Fork 158
feat: Add check for values that require surrounding quotes #521
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
Conversation
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.
@tabfugnic 👋
Thank you for your contribution 👍
I have left some comments. Please take a look at them 👀
|
@dotenv-linter/core Hey! |
Codecov Report
@@ Coverage Diff @@
## master #521 +/- ##
==========================================
+ Coverage 98.92% 98.94% +0.02%
==========================================
Files 41 43 +2
Lines 2705 2757 +52
==========================================
+ Hits 2676 2728 +52
Misses 29 29
Continue to review full report at Codecov.
|
When evaluating variables, values with spaces will only evaluate the first word/character before a space and ignore the rest. This is especially bad because this fails silently in most cases and can lead to confusing scenarios. This ensures that any value that contains a space must have quotes surrounding it so that it is valid. This does not consider any value that has a leading or trailing space since that is managed by other checks/fixes. Further Fixes: dotenv-linter#343
Add line for needing quotes feature
| if val.contains(char::is_whitespace) | ||
| && !(val.starts_with('\'') && val.ends_with('\'')) | ||
| && !(val.starts_with('\"') && val.ends_with('\"')) |
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.
JFYI: Actually there may be false-positive check results
For example, here are also valid ENV vars:
A=B' 'C # => B C
B=SOME" text will be here" # => SOME text will be hereBut I think your PR cover a good issue and it's already enough to catch mistakes/guhs. For such "unusual" cases users always can use special-comments (# dotenv-linter:off ValueWithoutQuotes) 👍
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.
Oh, I didn't know about that 😅
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.
Looks reasonable, I vote for this PR 👍
|
@tabfugnic Thanks a lot 🔥 |
When evaluating variables, values with spaces will only evaluate the first word/character before a space and ignore the rest. This is especially bad because this fails silently in most cases and can lead to confusing scenarios.
This ensures that any value that contains a space must have quotes surrounding it so that it is valid.
This does not consider any value that has a leading or trailing space since that is managed by other checks/fixes.
Further Fixes: #343
✔ Checklist: