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
Addition of a document type definition for library configurations #457
Addition of a document type definition for library configurations #457
Conversation
A document type definition can help to work with corresponding files because it describes the involved data structures to some degree. https://en.wikipedia.org/wiki/Document_type_definition Such a DTD was added so that further improvements will become easier for the safe data exchange around library configurations for static source code analysis. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
A document type definition can help to work with corresponding files because it describes the involved data structures to some degree. Such a format was standardised as a basis for XML documents. Some technical challenges and limitations were noticed so that another standard like W3C XML Schema evolved. https://en.wikipedia.org/wiki/XML_Schema_%28W3C%29 Such a XML schema definition was added so that further improvements will become easier for the safe data exchange around library configurations for static source code analysis. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
I'm in favor of this. |
Suggestions:
|
I find that both file format descriptions are useful. I am curious if my suggestion fits also to your usage expectations with the CFG files. |
Having two files means we have to maintain two files. As the information is redundant, one would be sufficient. |
I hope also that a XML schema can be preferred over a document type definition. |
XSD is fine for me. So we would like to have Makefile support based on xmllint for validation? |
xsd sounds good to me too. |
Do the suggested data structure description files need any more fine-tuning? |
I fail to use the xsd file you created:
is the xsd wrong, or do I use it wrongly somehow? |
@danmar: You stumbled on an update candidate in my data description suggestion "library.xsd" which I accidentally left over. |
Can you update your pull request, fixing that issue and removing the dtd? Then we can check again. |
Should I collect any more clarifications and fixes before I would submit another pull request? |
You don't have to create a new pull-request. Just do a force-push on the branch |
Do I interpret the implementation of the member function "Library::load" in the right way that the XML element "exporter" should deal with another element and attribute with the name "prefix"? |
I don't remember well how the element "exporter" works. Its for functionality similar to what is available in Qt where functions etc can be called "behind your back" from the framework. If you want to know more about it you'll have to investigate it yourself. |
@danmar: I am surprised by your feedback. Should the element "exporter" (or "exported"?) really belong to the XML structure "format 1" for library configurations then? |
yes we should keep it. |
How do you think about to describe your addition of the markup element also in the manual? |
I suggest we move the discussion about documentation outside the XSD to another place. |
|
I would recommend to not make an endless discussion out of this, instead you should try to finish this particular pull request. Applying this does not mean that further improvements can't be done later. |
Feel free to reopen if there is any progress. |
@PKEuS: I would like to reopen this issue. Unfortunately, the corresponding button is not activated for me here. I improved my data format descriptions a bit a while ago already.
|
This pull request still contains the same dtd and xsd as it did when you opened it. So, there was no visible progress. We decided that we would like to have one scheme (xsd), not two. So far, the pull-request contains both. Additionally, both schemes don't fit to the format, as they don't support all tags and attributes that might be used inside cfg files. Yes, there are tags that are not documented, but a scheme that does not work for the cfg files that are provided with cppcheck does not help. |
I imagine that a DTD file can also help to clarify open issues here. @PKEuS: Would you dare to invest more efforts to make the preferred XSD file variant really usable? |
noreturn is not the same as return type void. No return means that the function might behave like exit() |
How should such an use case be safely expressed in a DTD and/or XSD?
I agree in principle that the other style of GitHub code commenting functionality can also be nice. I find that our clarification might work in the other way, too. |
Do such functions have got a non-void return type? |
why not? |
Does a return value become usable from a function implementation which does not return actually? |
a function could return only conditionally and exit in other cases. assert() for example. |
That is fine, of course. - Would you like to distinguish functions that will always not return from those implementations which will occasionally not return because of situations like error/exception handling? |
I don't think we should debate noreturn here. concentrate on writing a XSD that works for our CFG files thank you. If you try your code against our cfg files you will see if it works or not, and then we don't have to review and debate a non-working schema. could you please use the white-list approach to start with.. make everything in our existing cfg files allowed. then if you want to black-list some configurations we can discuss that later. then the latest and greatest work-in-progress schema will be a working schema that we can try. |
I added a rng file with 7d0f5ad that can validate all our cfg files. It's not super strict so feel free to investigate if you can make it stricter. I don't know.. do we want a XSD also/instead? |
It seems that it is still needed to clarify opinions around the combination of the elements "noreturn" and "use-retval" so that it will be found out how they should really work together.
I am not going to follow this suggestion. I find that safe data format specifications deal with some limitations and restrictions to prevent data rubbish.
Interesting addition… - Do you prefer this file format for data structure descriptions? |
EDIT: I would like to keep the existing behaviour. It is true that if use-retval is used then we can guess that the function is not noreturn so it's redundant to use noreturn. but I still like to have these as 2 separate options.
ok. do it your way but I don't like to debate when I don't get any results.
I am not an xml expert. I only used rng because I know it. as far as I have heard - but maybe I am wrong - the advantage with xsd is that tool support is better. |
noreturn and use-retval do not interact. |
I find that the specification of the element "noreturn" is unnecessary (in an use case like the function "cproj") when the element "use-retval" is also specified.
Some open issues should be clarified before further contributions will become visible, shouldn't they? |
I understand. I want it to work as it does now.
I believe we could debate for months and still see no results. I don't want to do that. if you think the schema I checked in should be made stricter in some way.. feel free to discuss it. I am open to suggestions. I am sure there are much to do. |
@PKEuS Feel free to take an extra look at the rules for container. |
I guess that we are still going to discuss various issues in the following years. ;-)
It might happen that results willl not appear with the speed you would prefer.
I suggest further considerations for corresponding fine-tuning of your addition. |
Thanks for your acknowledgement.
How do you think about to present a warning to the data validation users if a questionable element combination was specified? |
what do you mean with "questionable". If you mean "a function is noreturn and has the use-retval option", then that is a bit questionable. An information message when --check-library is used would be fine. A function that is not noreturn and has the use-retval option, as in the example, is not questionable and I don't think any message should be shown. |
Yes, exactly this special case.
|
I want it to work as it does now.
no. these are 2 separate settings I don't want to mix them anywhere. |
There is nothing to apply right now.. so I close this. |
Do any contributors care to clarify this topic again so that library configurations can be safely completed by corresponding editors? |
we have cppcheck-cfg.rng in the repo. it is recommended to use that for validation. You can use the GUI to edit the cfg files. |
Where is the specification “
Should comments be explicitly assigned to such an XML element? |
https://github.com/danmar/cppcheck/blob/master/cfg/cppcheck-cfg.rng#L409 ?! |
@elfring https://sourceforge.net/p/cppcheck/discussion/general/ is probably the better place for discussions and questions. Here only few people are going to read this. |
It would be nice if a data structure description can be achieved that is safer than the pattern “ |
The manual describes the library format in chapter 10. That can certainly be improved. |
I am curious on how further improvements can be achieved for affected documentation source files. |
A document type definition can help to work with corresponding files because it describes the involved data structures to some degree. Such a DTD can be added so that further improvements will become easier for the safe data exchange around library configurations for static source code analysis.
A DTD format was standardised as a basis for XML documents. Some technical challenges and limitations were noticed so that another standard like W3C XML Schema evolved. Such a XML schema definition can also be added so that corresponding file handling might become more consistent.