scc
scc copied to clipboard
CSV format is broken
Describe the bug
If filename contains ,
character, it is not properly quoted in CSV.
To Reproduce
Clone this repo and run scc: https://github.com/freeCodeCamp/freeCodeCamp
The offending file name is curriculum/challenges/italian/08-data-analysis-with-python/numpy/accessing-and-changing-elements,-rows,-columns.md
.
Expected behavior
Put filename in quotes ("filename"
) if needed. The quote "
characters should be also escaped as ""
,
example: if filename is Hello, "world"
, it should be output as "Hello, ""world"""
.
Also take care for newlines, tabs and everything else in filenames.
Desktop (please complete the following information):
- OS: Linux
- Version 3.0.0.
Another issue: it outputs one extra empty line at the end.
Thats odd... I was using the standard library CSV stuff in Go which I would have thought would solve this.
I checked this right now on the Free Code camp repository and my testing one, and the quoting seems to work properly:
Language,Location,Filename,Lines,Code,Comments,Blanks,Complexity,Bytes
Python,"dir,with,quotes/another,comma,.py","another,comma,.py",1,1,0,0,0,17
Python,",name,with,commas.py",",name,with,commas.py",1,1,0,0,0,17
Neat perhaps that's the trick then.
When I get some time ill have another look at this. Unless someone wants to solve it before then :)
Not fixed.
For example, see https://github.com/anthraxx/linux-hardened/tree/master/drivers/staging/mt7621-pci
It has a file, named mediatek,mt7621-pci.txt
And the scc
output is:
Plain Text,anthraxx/linux-hardened/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt,mediatek,mt7621-pci.txt,104,87,0,17,0,3327
The invocation is as follows: ~/go/bin/scc --format csv-stream
I looked into the code and csv-stream
, unlike the cvs
format, does
not allocate any memory, so it does not use the standard CSV library.
There was a bug with that, which was fixed by e77be1ae. But it hasn't
been released yet.
Yep. I am still working on getting the walking to respect all ignore files properly first, once thats done I can come along and clean up a lot of these issues.