-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
scc ignores files with no extension, such as libc++ header files #162
Comments
So not a bug per-say (working as intended), but certainly not what I would like to see reported. The issue is that scc uses extensions in order to know what the file type is. The exception to this rule is
It might be possible to extend the #! rules logic to include this, but I will need some assistance. I am not a C++ developer (very little experience with it) so is there some reliable way to determine that these files are headers using say the first 255 bytes of the file? It looks like If there is I can modify scc to include this check. |
I don't think there is anything that is guaranteed to be in the first 255 bytes. The Another thing to look for could be the |
Had a feeling that might be the case. Something that's best effort and not perfect might be a reasonable solution, OR rules that can be modified to suit this case. Something similar to how the remap rules work, but for identifying inside the file similar to how the generated check works. |
I think it would be enough for me to have some way to override the language for files like this with no extension. |
Interestingly I just tried to do that and may have run into a bug
Ill have a look. You should in theory be able to map every extension like this, but since it isn't working at all that is an issue. |
That looks like you have to specify a new --by-file override for every file, can I specify just one for all files without an extension? |
Not currently. It was not designed for this particular use case. I think being able to override the #! rules would work though as you could then define Still thinking about it though. |
Interesting to note that none of the other tools work in this case. Tokei, cloc, polyglot nor any other counter works in this situation and I don't see any obvious ways to achieve it with them either. So this is treading new ground. |
So thinking about this. I think that if we give you the ability to say scan the first 1000 bytes of the file looking for a specific string and let you then override the language that way might be a reasonable workaround. Its either that or expand out the #! logic, but that feels more fragile. At least with the string option you can in theory build your own language logic into things in a sense. |
So I have been thinking about this enough. Time for action. Going to add a new flag,
You will call it like so,
The only question I have is where this should happen. There are a lot of things that affect the outcome here. Just a few,
My thinking is that this is a hard remap. My expectation would be, if I were to have a file with This seems to be the most sensible option to me because it does what I would expect best. EDIT - Although this might be an issue in this case, because even the header file has the same in it... https://github.com/llvm-mirror/libcxx/blob/master/include/complex.h So it either needs to be against all files it was unable to detect, or everything... and im not sure if the former is a good idea, at least not unless there exists the second option as well. |
Thinking a bit more I think there needs to be two options. A hard remap which applies to all files with the string, and a soft remap which only looks in files which it cannot identify though extension or which would be looked at using the #! logic (IE when no extension at all) |
Yep so I think the solution is two flags
Still not sure on the names yet... remap feels wrong. Perhaps inspect? The first will apply ONLY to files that were not identified using file extension and means that scc will attempt to process every file (binary logic checks will still kick in) unless its in the explicit denylist. The latter will do everything the previous does but in addition will inspect every file it opens looking to do a remap. |
@tbodt Would it be possible for you to have a look at master and try this out? You should be able to count this correctly now,
The option you want to use is |
Closing. Pretty sure this works and I want to get the release out ASAP :) |
Describe the bug
Running scc on libcxx/include ignores most of the files in it, because they have no extension. They are C++ header files, though. I can't find any way to get it to count these files.
To Reproduce
scc --by-file libcxx/include
Expected behavior
I would expect to see files such as
vector
appear in the result, but they don't.Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: