-
-
Notifications
You must be signed in to change notification settings - Fork 255
-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Lines counts are incorrect when symlinks are present #193
Comments
Now that is an unusual one. Thanks for the excellent bug report. Will investigate whats going on soon. |
Interestingly this works as you would expect on macOS
|
On a 18.04 Ubuntu instance it is working as expected as well.
Can you try building from master and letting me know what result you get? I wonder if there is a bug in 2.12 that might be down to the version of Go I used. For the above tests I used Go 1.15. |
Interesting! I was running the snap version (2.12.0), but when I grab the source and build and use that version it works as expected (see below). Any idea what might have fixed it?
|
https://github.com/boyter/scc/projects/4 There are quite a few changes from what you were using on snap to now. I think that #173 resolved it as its the only one that seems even slightly related. Ill have a play around with that theory by trying the version just before it merged in sometime tonight after work. |
Cool, thanks. Would it make sense for |
Its one of those ones that I tend to get polarising opinions on both sides. It is one of the main reasons why the Happy to listen to arguments on either side though as I am prepared to shift ground for good reasons. |
Interesting. I haven't thought about it deeply -- what are the arguments for counting symlinked code? Particularly with symlinks that point to files under the root path, it seems like that's the definition of double counting. For example, in the juju/juju codebase, we have a directory with a single I guess my argument is this: for a tool that counts lines (and prints the estimated cost of development), it seems incorrect to count symlinked code. If that symlinked code is under the root path, you definitely haven't written twice as much, so it shouldn't be counted twice. If the symlink points outside the root path, you probably haven't written that code either, or at least don't want it to be counted as code under the root path. |
The main counter argument is that it is counting what is actually needed to deliver the program as a whole. Although some use it to determine how many lines will be processed by other tools as well which may or may not process symlinks. Although i'm going to agree with you and remove symlinks by default and make it an option to process them. |
So this was actually worse than I thought. Even with the fixed version it was inconsistent depending on where the symlink was. For example if the symlinks in the example were in the directory
You would get different results from both runs because of how the fix was implemented. So... I modified it so its consistent between runs.
Anyway the default is off, but you can turn it on, in which case it will follow the real file, although it probably breaks if you symlink a symlink, but you know what, if you are doing that you deserve the pain. Although thinking about it I think Qt does it... so I might need to fix that... something for tomorrow anyway. |
Thanks for digging in and fixing this! Minor thing (assuming it's not too late): I'd recommend using |
Nothing is ever set in stone :) Changed. Also confirmed that symlinks to symlinks will work as expected. Going to close this one as all looks OK to me now. Will make it into the next release once I get a that last feature in. |
Awesome, thank you! |
When there are one or more symlinks present in a directory,
scc
gives wildly incorrect line counts -- close, but not exactly equal to, the file size in bytes of the file in question. Runningscc -d
doesn't help, and there doesn't seem to be any--ignore-symlinks
option.To Reproduce
First create a single file,
test.py
, as follows:For the record, the output of
wc
is as follows:Then run
scc
-- it shows 7 lines as expected:Then create a symlink
link.py
pointing totest.py
, and runwc
again to check:However, now
scc
says 88 lines:I would have expected
scc
to say 14 lines, andscc -d
to say 7.As mentioned, 88 is close to but not exactly equal to the file size (87 bytes). Seems like a hint as to what the issue is (though I don't know the codebase at all).
Desktop:
The text was updated successfully, but these errors were encountered: