-
Notifications
You must be signed in to change notification settings - Fork 42
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
Local Rule Creation Documentation #1174
Comments
Some additional questions based on my further research useful as notes to myself: is the |
Evening @Benito-E ,
The process is still the same. You can find an example under
Would you be willing to elaborate? These rules may be worth adding to VSG for others to use.
Would this be something like checking for header?
You should check out the
That is not a bad idea. I would create a directory and add the
I do not believe that token is used. I must have been a left over from a previous attempt at something. I think I was trying to solve a problem, but ended up using something else. If you have any other questions or would like to collaborate just leave me a message. Regards, --Jeremy |
Hi @jeremiah-c-leary ! Since yesterday I've made a lot of progress with rule creation, in part due to your explanations! I've created two rules: one that explicitly prohibits the use of the
rule_001.py (pseudocode):
since the header to be checked is in the config file, it can be easily modified by users to their own particular needs. This could probably turn into a much larger rule if it allowed header templates of some kind, with un-checked strings in-between like name or date or whatnot. Regardless what I have is something like what I put above, and it seems to work well.
Before I figured things out, I'd thought I could make a rule that simply checks if a custom token (a token defined by any user defined string) appeared after the parser.beginning_of_file token. I figured things out and it seems to work well so I don't necessarily need this anymore, but I figured I'd elaborate on my thought process.
I think I got ahead of myself when I said I had 'a number' of rules; the rules I've made above were the main ones I wanted to create. The only other idea I would have would be to create a set of rules whose purpose isn't to enforce a particular thing, but rather to be flexibly configurable by users to enforcer a large number of things. For example the idea I had above that included a user-defined token, for which you could check the existence of or location of. I can't pretend to imagine how a rule like that would be implemented though. --Benito |
Afternoon @Benito-E ,
I'm glad you were able to add your rules.
That is a good rule. I should have thought of that one. There are quite a few base rules that will do most of what you would want to check. That makes adding new rules fairly easy.
I like that you made the header configurable. It seems that you have a good grasp of how to create rules. Is there anything that could have been better documented to make it easier? --Jeremy |
@jeremiah-c-leary Apologies for the late reply, I'd say the only thing that really needs updating is just that This Page is out of date. From my general understanding of this page, much of what's documented there is the same, except the sorts of functions that are required for the rule to be called and run. If I'm not mistaken, in the current version of VSG, local rules can be either:
And if the latter option is chosen, the required functions are either simply:
My understanding could be somewhat incorrect but it has served me well thus far, and I would say that if my understanding is correct, the documentation page, that mentions other deprecated methods such as --Benito |
Hello!
I've been working for a little while on trying to create some local rules for vsg, but when I look through both the stable and latest docs for vsg, the page for localization is out of date... I was wondering if anyone would be able to give me a rundown on how local rule creation has changed since the docs for it were made.
There are a number of rules I'd like to try and create, but for starters I want to see if I can make a rule that enforces the existence of comments at the beginning of the file, for the sake of self documentation. Past that, If I could make vsg enforce specific templates or specific multi-line comment strings, that would be even better. But for starters I'd like to know how to create a simple rule, even perhaps recreating one that already exists built into vsg.
Thank you!
The text was updated successfully, but these errors were encountered: