Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jtbandes
Copy link
Contributor

@jtbandes jtbandes commented Aug 11, 2025

Adding a language grammar for ROS interfaces (messages, services, and actions).

Resolves #5619

image

Description

Checklist:

@jtbandes jtbandes requested a review from a team as a code owner August 11, 2025 23:40
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three of these extensions are very generic and match a lot more non-ROS files then they do ROS based on your search queries. This will mean there's a very likely chance more files will be incorrectly classified as ROS.

IFF you can come up with a heuristic that will 100% only match ROS files, you can add the extension to generic.yml and add a heuristic - this needs to be a linear an PCRE2 compatible regex. If you can't, it's best not to add the extension and heuristic.

.msg already exists in generic.yml and already has a good regex so you only need to add a heuristic for this extension.

.action does not meet out usage requirements so I'd advise against including it at this time. User can use an override until it's popular enough for inclusion.
.msg al

@jtbandes
Copy link
Contributor Author

@lildude thanks for the feedback! I've updated with some heuristics.

.action does not meet out usage requirements

Curious what the requirements are – the one I saw in the template was "used in hundreds of repositories"?

It's true that both .srv and .action are less commonly used than .msg, but they are equally first-class citizens in ROS (and the syntax is basically identical so the same heuristics mostly apply). Is there any way to do something like "if the repository also has ROS .msg files, then assume the .action files in the same repo are ROS too"?

Both .srv and .action files also have a requirement that they must have at least one "---" line, which I think gives us a pretty good chance of matching correctly with heuristics. Because the syntax is minimal I was also able to add a negative_pattern which should filter out most non-ROS files.

@jtbandes
Copy link
Contributor Author

I'm also not quite sure what is wrong with the current test failures...do I need to add more samples?

@lildude
Copy link
Member

lildude commented Aug 13, 2025

Curious what the requirements are – the one I saw in the template was "used in hundreds of repositories"?

linguist/CONTRIBUTING.md

Lines 109 to 110 in 4a1a14c

In most cases we prefer that each new file extension be in use in at least 200 unique `:user/:repo` repositories before supporting them in Linguist
(but see [#5756][] for a temporary change in the criteria).

Note the issue referenced.

I'm also not quite sure what is wrong with the current test failures...do I need to add more samples?

The failures indicate your heuristic regular expressions don't match the content of your samples. This will be because they're not valid (unescaped /). They're also vulnerable to ReDos attack. Please fix these and make your regexes PCRE2 compliant (I plan to make this a requirement soon).

@jtbandes
Copy link
Contributor Author

jtbandes commented Aug 13, 2025

Thanks for the tips. I believe I've fixed the redos issue, although couldn't quite figure out how to get codeql up and running in my local working copy to verify, but I did check against https://makenowjust-labs.github.io/recheck/playground/. As for PCRE2 compatibility, I believe they already were and still are compatible according to https://regex101.com, but let me know if you're seeing otherwise.

@jtbandes jtbandes requested a review from lildude August 13, 2025 21:22
@jtbandes
Copy link
Contributor Author

Here are some search queries using the actual heuristic regexes I'm adding: msg, srv, action

@lildude lildude changed the title Add ROS Interface language grammar Add ROS Interface Aug 14, 2025
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

Important

The changes in this PR will not appear on GitHub until the next release has been made and deployed. See here for more details.

@lildude lildude added this pull request to the merge queue Aug 14, 2025
Merged via the queue into github-linguist:main with commit f7e5ac0 Aug 14, 2025
5 checks passed
@jtbandes jtbandes deleted the add-rosmsg branch August 14, 2025 17:24
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

Successfully merging this pull request may close these issues.

Add ROS message (msg, srv, action)
2 participants