jeremiah-c-leary / vhdl-style-guide

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

Better diagnostics when local indent rules don't match default config #1189

Open abyszuk opened 3 days ago

abyszuk commented 3 days ago

Hello,

I have my local, complete configuration (including both indent and rule groups). The problem is that often when I update VSG the upstream indent config changes in a way that's not compatible with my local config resulting in the following error:

Traceback (most recent call last):
  File "/home/adrian/.local/bin/vsg", line 8, in <module>
    sys.exit(main())
  File "/home/adrian/.local/lib/python3.10/site-packages/vsg/__main__.py", line 111, in main
    oConfig = config.New(commandLineArguments)
  File "/home/adrian/.local/lib/python3.10/site-packages/vsg/config.py", line 314, in New
    dIndent = read_indent_configuration(dConfig)
  File "/home/adrian/.local/lib/python3.10/site-packages/vsg/config.py", line 211, in read_indent_configuration
    dReturn["indent"]["tokens"][sGroup][sToken][sParameter] = dGroups[sGroup][sToken][sParameter]
KeyError: 'target'

I understand that I have to update my local config, but the problem it's time consuming because I have to manually compare the configs (or look at the VSG git diff). It would be great if VSG could print at least the name of problematic Group and/or Token. It would be even better if VSG could print a detailed description, for example:

Configuration mismatch, invalid key in local config.
Local config:
    simple_variable_assignment:
      target:
        after: current
        token: current

Upstream config
    simple_variable_assignment:
      aggregate_close_parenthesis:
        after: '-1'
        token: '-1'
      aggregate_open_parenthesis:
        after: '+1'
        token: 'current'
      simple_name:
        after: 'current'
        token: 'current'
jeremiah-c-leary commented 3 days ago

Morning @abyszuk ,

I suppose I could use a try...except on a KeyError. Then in the except, figure out which key is incorrect and report back the valid keys.

We can work through the details as I implement an update.

--Jeremy

jeremiah-c-leary commented 1 day ago

Morning @abyszuk ,

I pushed an update for this issue to the issue-1189 branch. When you get a chance could you give it a try and let me know what you think?

Thanks,

--Jeremy