Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

nifadyev
Copy link

@nifadyev nifadyev commented Sep 30, 2024

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

@nifadyev
Copy link
Author

Hey @sobolevn . Should file .env.eol be committed with \r\n line endings? Also, I don't know how to properly write the reasoning for this violation rule

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Restricts to use `/r/n` (CRLF) end-of-line.
Reasoning:
???
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing different end-of-line chars can lead to different hard-to-debug problems.

???
Solution:
Use `/n` (LF) end-of-line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, mention .gitattributes file here.

Solution:
Use `/n` (LF) end-of-line.
Example::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove this section.

@@ -35,3 +39,9 @@ def _check_value_quotes(self, node: Value) -> None:
self._add_violation(QuotedValueViolation(node, text=node.raw_text))
elif text.startswith("'") and text.endswith("'"):
self._add_violation(QuotedValueViolation(node, text=node.raw_text))

def _is_crlf_eol_used(self, node: Value) -> None:
crlf_eol = '\r'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make this a module-level final constant.

setup.cfg Outdated
@@ -65,7 +65,8 @@ addopts =
--strict-markers
--strict-config
--doctest-modules
--cov=dotenv_linter
# Disable with option to allow debugging
; --cov=dotenv_linter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, re-enable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Should it be mentioned somewhere? For example, in Development README section?

@@ -4,3 +4,4 @@
# See: https://github.com/wemake-services/dotenv-linter/issues/20
TEST=1
EMPTY=
VARIABLE_WITH_TRAILING_SLASH_R=value/r
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/r and \r are clearly not the same

@@ -0,0 +1 @@
VARIABLE_WITH_CRLF_EOL=123
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, make this test a code-only, no fixtures should be used. Since there are lots of editors / tools / etc that fix eofs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it clear - Are you suggest creating temp file inside test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

assert str(violation_class.code) in stderr


def test_lint_wrong_eol(fixture_path: Callable) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_lint_wrong_eol(fixture_path: Callable) -> None:
def test_lint_wrong_eol(fixture_path: Callable[[str], str]) -> None:

@nifadyev
Copy link
Author

Is violation name suitable? InvalidEOLViolation is the first thing that came up into my mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forbid to use \r\n for line breaks
2 participants