1
1
Fork
You've already forked ecformat
0

EditorConfig: Support end_of_line #23

Manually merged
BaumiCoder merged 37 commits from feature/4-end_of_line into main 2025年09月30日 16:19:54 +02:00

Resolves #4

User perspective

Include the end_of_line property into the check and fix command.

Developer perspective

This Pull request adds the implementation for end_of_line property, the second one which is supported by ecformat. Therefore, some refactoring potential become visible to avoid duplicated code with the first supported property. These refactorings are also part of this Pull Request. Furthermore, reading the files as strings with the configured charset is also introduced with this Pull request, as the handler for this property is the first one that needs this. If no charset is set, the fallback is UTF-8 as that should be the most common encoding nowadays.

Resolves #4 ### User perspective Include the `end_of_line` property into the `check` and `fix` command. ### Developer perspective This Pull request adds the implementation for `end_of_line` property, the second one which is supported by ecformat. Therefore, some refactoring potential become visible to avoid duplicated code with the first supported property. These refactorings are also part of this Pull Request. Furthermore, reading the files as strings with the configured `charset` is also introduced with this Pull request, as the handler for this property is the first one that needs this. If no `charset` is set, the fallback is UTF-8 as that should be the most common encoding nowadays.
To make sure it is equaly handled in all working copies,
which is relevant for the test data later on.
Move test_utils module into the route to allow usage also in other tests
and to have all this similar functions (iteration over files
in a directory) in the same module to share code between them.
Extract one helper function form existing test to avoid duplicated code.
New helper function allows to use proper typed variable
for charsets from the file name.
Currently failing for UTF-16 at the Euro-sign (€) fix in next commit.
Wrong direction of the bit shift leads to 0x00 for the higher byte.
Refactor some function in the test_utils to avoid duplicated code
for the function for the end_of_line tests.
A seperate function increases the testability of the code.
Currently failing with CRLF on CRLF-LF.md, becauce check still found
errors afterwards. Fix in next commit.
Previous implementation could not find the error, which was found
by the Integration Test for the fix command. It does not performe
any checks, as the single chars inside the strings were not extracted
correctly. Now, it works on the chars and consider the different cases
of how the line endings can be replaced.
Test fails for the previous implementation because it replace the CR
or the LF inside CRLF when CRLF is the expected end of line.
Run the REUSE commands in the current working directory and
do not cd to the diretory of the justfile.
All methods to access the test files in a struct TestFileHelper,
which holds the name of the subdirectory with the requested test fields.
Currently, create the struct only from EditorConfig Property,
but later maybe also from other sources like a general string.
Use the TestFileHelper to reduce the number of parameter for helper
function and load the test_utils module for the Integration Tests
on a central place (only one place with the file path).
As each Integration Test module is its own crate, not every crate uses
every helper function (e.g., the charset.rs have no need
for the functions in the end_of_line module in test_utils).
This unused states in this separate crates lead to warnings
which can be ignored as the code is used from some other crate.
Assert equal on the list of expect and detected files with errors
to detect also if too much files with errors were found.
Furthermore, a panic message would now contain the whole list of
expected and detected files.
Only some small parts extracted to keep flexibility for test specific
code if necessary for further tests.
The helper function for the handler structs are only used in them.
Therefore, it seems more logical to me to have them as private function
/ methods inside the structs.
For a more consistant code and to see the exact type (incl. the type
of the vector elements) in a code editor / IDE.
Author
Owner
Copy link

As the test files need to have the expected end of lines, independent of the operating system, I configured with .gitattributes that git should not handle the end of lines for these files. To be sure that it works with operating systems with different native end of line style, I run cargo test beside my main system with Manjaro Linux (CR end of lines) also on a system with Windows 11 (CRLF end of lines) and the tests passed at both.

As the test files need to have the expected end of lines, independent of the operating system, I configured with `.gitattributes` that git should not handle the end of lines for these files. To be sure that it works with operating systems with different native end of line style, I run `cargo test` beside my main system with Manjaro Linux (CR end of lines) also on a system with Windows 11 (CRLF end of lines) and the tests passed at both.
BaumiCoder manually merged commit 10904254bc into main 2025年09月30日 16:19:54 +02:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Compat/Breaking
Breaking change that won't be backward compatible
EditorConfig
0.17.2
Issues to support version 0.17.2 of the EditorConfig specification
Kind
Bug
Something is not working
Kind
Chore
Some tasks maintainig tasks
Kind
Documentation
Documentation changes
Kind
Enhancement
Improve existing functionality
Kind
Feature
New functionality
Kind
Testing
Issue or pull request related to testing
Packaging
About packaging the project for some platform
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
WIP
Work in progress (Assignee is working on this issue)
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
BaumiCoder/ecformat!23
Reference in a new issue
BaumiCoder/ecformat
No description provided.
Delete branch "feature/4-end_of_line"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?