-
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
Rules to enforce case on the shared
keyword in a shared variable declaration
#1289
Comments
Hi @urbite. Thanks for raising this issue. The You mentioned at one point that you might like to make some contributions to VSG. Would you like me to give you some pointers on how you can raise a PR yourself to resolve this issue? No problem if not, I'll be able to raise a PR for this quite quickly. Jukka |
I would definitely be interested in trying to add some of these missing keywords to VSG. So some pointers on raising the PR and fixing it myself would be welcome. I assume that many (or most) of these keyword case issues would be fixed in a similar manner. Then, some of your earlier fixes could be used as a template, in the same manner as raising an issue. I read the docs on adding a rule and it doesn't seem too difficult. Especially if I can use your earlier case enhancements as examples. Regarding the PRs and related flow, I commented on that here |
@urbite Excellent, I'd be glad to help with that. That's right, many of the rules are extremely similar, so adding a rule that closely resembles another is not challenging. Similar rules are created as objects that inherit their functionality from a common "base rule", so when creating a rule, you can usually find another similar rule and use that as a template. In this case, variable_002 is a rule that enforces the case of the Creating the ruleThe rule is at the path vsg/rules/variable/rule_002.py and if you open it up, you'll see the following # -*- coding: utf-8 -*-
from vsg import token
from vsg.rules import token_case
lTokens = []
lTokens.append(token.variable_declaration.variable_keyword)
class rule_002(token_case):
"""
This rule checks the **variable** keyword has proper case.
|configuring_uppercase_and_lowercase_rules_link|
**Violation**
.. code-block:: vhdl
VARIABLE count : integer;
**Fix**
.. code-block:: vhdl
variable count : integer;
"""
def __init__(self):
super().__init__(lTokens)
self.groups.append("case::keyword") There are a few things to observe here:
The next step is to figure out what the name of the rule needs to be. There is documentation about the rule naming process here. In this case, it's quite straightforward. This will be another So with this as our template, we can create a copy of variable/rule_002.py called rule_500.py and update the contents accordingly. If you're not sure what the token should be, you can create a test VHDL file and run the tool
which tells us that our keyword uses the token object TestingYou should again be able to copy and tweak the test files for DocumentationTo generate the documentation, you can use another helpful tool by running PROnce this is done, raise your PR and check that it passes the CI. Since this is your first PR, I think the repo owner needs to approve you or add you as a contributor or something before the full CI runs on your pull request, but you can run the checks locally to ensure that it will pass. Once the PR is ready, it is up to the repo owner to approve and merge. Hopefully, this makes sense. If anything is not clear, feel free to ask. |
@JHertz5 Excellent overview and instructions for adding a feature and creating a PR! I have forked the project, but it may be a few days before I can add the case rule for |
Hi @urbite It's been a few months, just wanted to check in. Do you see yourself ever doing this? No problem if not, just let us know and I can implement it instead. Thanks, |
Is your feature request related to a problem? Please describe.
I'd like a rule to enforce case on the shared keyword in a shared variable declaration. For example, I'd like:
corrected to:
@JHertz5 Notification alert
The text was updated successfully, but these errors were encountered: