Skip to content
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

C++ template header detected as C #1032

Closed
dragonmux opened this issue Mar 31, 2014 · 6 comments
Closed

C++ template header detected as C #1032

dragonmux opened this issue Mar 31, 2014 · 6 comments

Comments

@dragonmux
Copy link
Contributor

I was looking at the breakdown of code in one of my repositories and noticed headers that contain purely C++ code being classified as C instead. One example header is linked below. A template class is not possible C.

https://github.com/DX-MON/IRCBot/blob/a344fa80e4d93a7eb7aa8b64983e5bb5041cfb07/ThreadedQueue.h

@dragonmux
Copy link
Contributor Author

A quick check through the sources shows that the heuristic for C vs C++ vs Objective-C is extremely bad and not really a heuristic at all.. see https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb#L41

A better check for a C++ header is to check for the inclusion of any STL headers, followed by a check for the existence of constructs like "template[ ]*<" within the header. I'm sure there's also some regex that can be used to detect a C++ class in place of anything Obj-C has. Checking for the use of template constructs would have detected ThreadedQueue here.

@pchaigno
Copy link
Contributor

pchaigno commented Apr 2, 2014

Feel free to improve it in a pull request :)

@dragonmux
Copy link
Contributor Author

The problem I've got is I don't know Ruby nor do I know how to write Regex's for it.. otherwise I would. Some pointers so I can?

@pchaigno
Copy link
Contributor

pchaigno commented Apr 2, 2014

There is an example of a regex in the heuristics file, at the end.
You will just need to change this file.
If you have any questions, I'll be happy to help you :)

@dragonmux
Copy link
Contributor Author

Pull request sent - see request #1036

@bkeepers
Copy link
Contributor

We're tracking progress for a fix in #1626. Thanks @DX-MON for all your work on this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants