-
Notifications
You must be signed in to change notification settings - Fork 593
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
Ignore Lints in the Bison/Flex Generated Files #3282
Ignore Lints in the Bison/Flex Generated Files #3282
Conversation
As for the remaining So, personally, I'd rather keep our configuration centralized and opt-out of this lint in our top-level |
@@ -217,6 +217,8 @@ keyword [[:alpha:]]* | |||
|
|||
%% | |||
|
|||
// NOLINTEND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't put it at the very end because you expect the code below to be lint-free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all the code under this line is our code, copied verbatim into the generated file.
I don't expect it to be lint free (but maybe it is). But since it's our code, these are lints that we should be fixing, and not just ignoring!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I'm fine with it in the top level one (with a comment) if we really don't care about this lint for anything else.
This PR adds
NOLINTBEGIN
andNOLINTEND
markers into the code generated by Bison (Grammar.cpp
) and Flex (Scanner.cpp
).Both Bison and Flex support special
%code top {...}
and%top {...}
directives (respectively) which can be used to insert code at the tops of their generated implementations. We're actually already using them to inject copyrights into these files.Additionally, they support a bottom section (marked by
%%
). Code in this section is copied verbatim into the generated file.Some of our files were using this section to define functions, in others I had to add this section.
I made sure to put the
NOLINTEND
above our function definitions, this means that our functions will still be linted!Some caveats:
This doesn't affect the generated
Grammar.h
file, as Bison exposes no way to generate code at the bottom of this file.My understanding is that we're already ignoring the
Grammar.h
files in our.clang-tidy
config file though.Note that there is no
Scanner.h
file to worry about.Flex allows us to generate code at the true tippy-top of it's file, but Bison does not. No matter what Bison, will generate this ahead of our
%code top {...}
:These macro definitions do trigger a lint violation about "you should use constants instead of macros here".
There is no way I can see to eliminate this. Tbf, I'm not sure that this is a lint worth checking...