jeremiah-c-leary / vhdl-style-guide

Style guide enforcement for VHDL
GNU General Public License v3.0
179 stars 38 forks source link

Case-rule for either 'upper' or 'lower', but not a combination #1047

Closed larshb closed 7 months ago

larshb commented 8 months ago

When using the use-keyword I will sometimes import components (lowercase) and sometimes import constants (uppercase). But I can't have both without disabling use_clause_502.

I would like to be able to set enforcement of "either". Eg.

rule :
  use_clause_502:
     case: 'either'

resulting in

library mylib;
  use mylib.mypackage.C_SOME_CONSTANT; -- OK
  use mylib.mypackage.some_component; -- OK
  use mylib.mypackage.sOmEtHiNg_ElSe; -- violation

Alternatively, the prefix and suffix exceptions can be expanded to let you enforce case of the entire key. Eg. a prefix C_ enforces upper-case on the entire key, while everything else is enforced 'lower' by default.

jeremiah-c-leary commented 8 months ago

Morning @larshb ,

I added an option upper_or_lower that will check for upper or lower cases.

I pushed an update to the issue-1047 branch, when you get a chance could you check it out on your end and let me know what you think?

Thanks,

--Jeremy

jeremiah-c-leary commented 7 months ago

Morning @larshb ,

Just wanted to ping you on this issue to see if you had time to check it out.

Thanks,

--Jeremy

larshb commented 7 months ago

Hello @jeremiah-c-leary ,

Sorry for my late response. I've tested the branch and it looks good to me.

Excerpt of YAML-config

rule:
  use_clause_502:
    case: 'upper_or_lower'

Excerpt of VHDL with intentional violation

library mylib;
  use mylibrary.mypackage.my_component;
  use mylibrary.mypackage.My_Constant;

VSG output

Phase 6 of 7... Reporting
Total Rules Checked: 712
Total Violations:    1
  Error   :     1
  Warning :     0
----------------------------+------------+------------+--------------------------------------
  Rule                      |  severity  |  line(s)   | Solution
----------------------------+------------+------------+--------------------------------------
  use_clause_502            | Error      |         31 | Change "My_Constant" to "MY_CONSTANT" or "my_constant"
----------------------------+------------+------------+--------------------------------------
jeremiah-c-leary commented 7 months ago

Morning @larshb ,

Awesome, I will get this merged to master.

--Jeremy