-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
#177: Forbid to use CRLF end-of-line #708
Merged
sobolevn
merged 14 commits into
wemake-services:master
from
nifadyev:feature/#177/forbid-to-use-crlf-eol
Oct 4, 2024
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5b03923
Add InvalidEOLViolation for values
nifadyev 44d2787
Add examples for new rule
nifadyev fcd8159
Add comment about pytest flag and debugging
nifadyev e35f1b9
Add test for new EOL rule
nifadyev 5ad4d9a
Fix too long comments
nifadyev 96d62f8
Add rule 302 to CHANGELOG
nifadyev 96be525
Add detailed documentation for InvalidEOFViolation
nifadyev 4891a82
Move crlf_eol to module constants
nifadyev 5636cdb
Fix invalid slash
nifadyev 1fecd63
Remove extra test fixture, create temp file in test instead
nifadyev 10ca2a4
Uncomment pytest flag
nifadyev 66a4128
Fix lint issues
nifadyev 77a6b9d
Fix type annotation
nifadyev a81dfda
Use pytest tmp_path fixture for creating temp file
nifadyev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import os | ||
import subprocess | ||
from collections.abc import Callable | ||
|
||
from dotenv_linter.violations.values import InvalidEOLViolation | ||
|
||
|
||
def test_lint_correct_fixture(fixture_path): | ||
|
@@ -74,5 +78,32 @@ def test_lint_wrong_fixture(fixture_path, all_violations): | |
|
||
assert process.returncode == 1 | ||
|
||
for violation_class in all_violations: | ||
violations_without_eol = set(all_violations) - {InvalidEOLViolation} | ||
for violation_class in violations_without_eol: | ||
assert str(violation_class.code) in stderr | ||
|
||
|
||
def test_lint_wrong_eol(fixture_path: Callable[[str], str]) -> None: | ||
"""Checks that `lint` command works for with with CRLF end-of-line.""" | ||
temp_file_path = fixture_path('.env.temp') | ||
with open(temp_file_path, mode='w') as temp_file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used tmp_path pytest fixture instead, |
||
temp_file.write('VARIABLE_WITH_CRLF_EOL=123\r\n') | ||
|
||
process = subprocess.Popen( | ||
[ | ||
'dotenv-linter', | ||
fixture_path(temp_file_path), | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
# It is important to set this to `False`, otherwise eol are normalized | ||
universal_newlines=False, | ||
encoding='utf8', | ||
) | ||
_, stderr = process.communicate() | ||
|
||
assert process.returncode == 1 | ||
|
||
assert str(InvalidEOLViolation.code) in stderr | ||
|
||
os.remove(temp_file_path) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.