Allow a level to inherit from multiple levels
tdenewiler opened this issue · 5 comments
It would be nice to have a base level for Python, C++, documentation, Java, etc and then have another level inherit from all of those base levels. Currently the inherits_from
flag is expected to be a string instead of a list. We could update that to allow the new feature.
I have a working version of being able to have a level inherit from multiple levels. The big downside is that any previous instances of inherits_from
were defined in yaml as strings but now they need to be a list. You can compare the changes to see several examples (link at bottom of comment). It is simple to fix the configuration files but is also a breaking change. We could
- merge as-is and bump the next release to a new minor version while adding an entry in the CHANGELOG,
- when accessing that field we can check if it is a string type and handle it differently than if it is a list while adding a deprecation warning when a string is found,
- something more clever to handle both cases elegantly (I do not consider checking the type to be elegant).
I really like the functionality, but am hesitant to open a PR as-is. Any thoughts/preferences?
If you want to try the development branch yourself this is a pretty good one. This assumes you have the NTRTSim repository cloned to ~/src/NTRTSim
and that you locally edit profile.yaml
to have the default level set to combined
.
./statick ~/src/NTRTsim/ --output-directory /tmp/x --log info --config config-list.yaml
You should see:
- the level say
combined
, - tools from all 3 levels (C, Python, documentation) run
- both the
print_to_console
andwrite_jenkins_warnings_ng
plugins run
another option that is more explicit, but possibly less elegant is to just have a new config option inherits_from_list
, then users would have to manually move to the new option. you could keep the deprecation warning on the old option, and then some time in the future switch the new one to inherits_from
and remove the string option.
i'm not sure i like this more than checking the type though. that one seems easier on the users.
@xydesa that's a pretty interesting idea. It's close to what I was looking for, but in the end I agree it puts too much burden on users. In the development branch I have created a new method that gets called if the inherits_from
flag is a string. That method is marked as deprecated with a removal slated for v0.8 (next minor release) and instructions on how to update to a list. The README and most unit test configuration files were modified to use the list approach.
I'm open to more discussion on the current approach.