-
Notifications
You must be signed in to change notification settings - Fork 72
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
Incorrect checks applied to CSV files #203
Comments
Seems to only appy when running CodeChcker form the Moodle UI, not in github actions. |
I bet that is one of those "special" (apart from PHP_Codesniffer) checks that were added to the plugin. Lately have found myself fixing some of them. Really they don't add much, but confusion, heh. Will take a look to this case soon... |
Yeah, confirmed. That check is there since the night of times: 1d808e0e#diff-3494b45596f0f648d894a5f22070eaae01f3e0ea664be0430b8d23eb7d93e35aR220-R224 And I think it just means that no file within Moodle should be CRLF ended ever. Including CSV files. Looking to So I think it's ok to require all CSV files in codebase (some fixture, I bet?) to be LF and not CRLF. Hence, maybe this should be closed? |
I think that the point of testing is to verify that your system will work for users. Users will create CSV files by saving from Excel, so we should check that those import correctly. Therefore, test fixture CVS files are better tests if they have CR LF. Therefore we should allow it. At least, that is what I think. |
Would be ok enough to make an exception for anything under a "tests/fixtures" dir and allow everything there? Allow everything = I mean, don't verify EOLs in CSV files under "tetst/fixtures" dirs. Ciao :-) |
It might be. Or, that might just be a confusing inconsistency. My feeling is the same rules should apply to a file type everywhere. |
Yeah, the rule is / has been pretty consistent since the beginning, LOL. Don't allow CRLF files ever, point!. It's not me the one proposing to add exceptions, just wanted to restrict them to the real cases where we can effectively accept CRLF CSV files. And the only case is fixtures. If for some (strange) reason we want a CSV file elsewhere, it should be a correct LF one (for example: |
We don't allow CRLF in .php, .css, .txt,.. Obviously that is right. But, CRLF is in the definition of .csv. (https://www.rfc-editor.org/rfc/rfc4180.html). I know .csv is not massively standardised, but requiring all our example .csv files to break the standard seems a strange decision. |
In moodlehq#203 it was proposed to allow CRLF files in Moodle, because the original CSV specs say that those files should be CRLF. But in practice, nowadays hardly any file is CRLF and, specifically for Moodle, we have banned them in core since the night of the times. And we should continue not allowing them. Hence we are only allowing those CRLF CSV files within the /tests/fixtures/ directories, that way if anybody wants to test their CSV loaders with CRLF, they can have some fixtures at hand. Everywhere else, they will continue being forbidden. Fixes moodlehq#203
In moodlehq#203 it was proposed to allow CRLF files in Moodle, because the original CSV specs say that those files should be CRLF. But in practice, nowadays hardly any file is CRLF and, specifically for Moodle, we have banned them in core since the night of the times. And we should continue not allowing them. Hence we are only allowing those CRLF CSV files within the /tests/fixtures/ directories, that way if anybody wants to test their CSV loaders with CRLF, they can have some fixtures at hand. Everywhere else, they will continue being forbidden. Fixes moodlehq#203
I've created #205 that enabled the use of CRLF CSV files under the fixtures directory. I really don't see much benefit allowing them everywhere. The reality (the facto "standard") is that both work the same and we aren't going to add CRLF examples elsewhere (haven't in 20 years). I understand that we should be able to test that CRLF imports work and that's exactly what the PR provides. So, in practice, with that PR, you will be able to use those CRLF CSV fixtures and done. I think nobody is going to convince the other, LOL. Ciao :-) |
Fair enoguh. Thanks for doing it Eloy. |
https://docs.fileformat.com/spreadsheet/csv/ says "Each record is located on a separate line, delimited by a line break (CRLF)."
CodeChecker is telling me
"Windows (CRLF) line ending instead of just LF (reporting only first occurrence)"
on my CSV file. I think CodeChecker is wrong.
The text was updated successfully, but these errors were encountered: