Skip to content
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

Can we have an xsd for the checkstyle configuration xml file ? #7517

Open
debashisdeb opened this issue Jan 29, 2020 · 9 comments
Open

Can we have an xsd for the checkstyle configuration xml file ? #7517

debashisdeb opened this issue Jan 29, 2020 · 9 comments

Comments

@debashisdeb
Copy link

Use Case :

I'm planning to introduce custom checks for multiple users, in which each project owner can define their own set of checks. I also have a set of default set of checks that needs to run for every project. During the run time of Checkstyle, I want to merge the project specific checks and the default checks. Having a XSD can help me validate if the merged XML configuration file is formed correctly or not.
Since some of the checks go inside of the Checker module and many checks go inside the TreeWalker module, we need to correctly place the checks, so that the run doesn't fail at all after creating a wrong merged XML.

Question :
Is there any XSD available for validating ? Or may be an API within Checkstyle which can do the merge ?
I've seen the DTD that is present, but that doesn't help in completely validating the entire configuration file.

@debashisdeb
Copy link
Author

@romani any ideas around this ?

@romani
Copy link
Member

romani commented Jan 29, 2020

Yes, idea to migrate to xsd was around for very long time, but nobody actually willing to start this process.
here is request for XSD for reports - #5166

Is there any XSD available for validating ?

NO.
DTD do validation of xml files for structure, it is old fashion approach, but it works.
So nothing is blocking you right now to generate config file and simply use latest version of DTD (they are stored as resources in checkstyle jar) to validate it (you can see our code how we validate file before parsing it).

Or may be an API within Checkstyle which can do the merge ?

No, merge of configs is very complicated concept, we do not know how to make it for now.
#6942 , #2873

, but that doesn't help in completely validating the entire configuration file.

please explain why, we do such DTD by our code and by maven plugs to validate xml files.


Here is example on how users hacking config file to have it more modular (specific config for specific project) - #3605


if you end up in creation of xsd files (based on our DTD), please contribute them to checkstyle.

@romani
Copy link
Member

romani commented Feb 2, 2020

issue is not complete, if no activity happened till end of February, issue will be closed.

@xenoterracide
Copy link

huh, doesn't look closed, I just came wondering if this existed, would be good for autocompletion in IDE's

@romani
Copy link
Member

romani commented Nov 14, 2020

@xenoterracide , which IDE you use ?
Is dtd not enough?

@xenoterracide
Copy link

xenoterracide commented Nov 14, 2020

Intellij, I guess it's suggesting tags, but not the values of properties.

@romani
Copy link
Member

romani commented Nov 14, 2020

values of properties

good point to know ... yes I agree it would be cool.
But this will force us to have schema to be version specific and bound to checkstyle version, as new values appear all the time, new Checks appear each version. It will hard for us to keep this XSD uptoday manually, so we need generator of it.

But current DTD is stable for very long time.

All DTDs are downloadable by URL, as we have small amount of them it is manageable, with XSDs for each checkstyle version, amount will be significant, and users need update version of XSD each time they update checkstyle.

I am not sure final result cost all efforts to make it happen.
I keep issue open for ideas and discussions....

@xenoterracide
Copy link

xsd's are downloadable and you can point them at something like a latest url

@romani
Copy link
Member

romani commented Nov 14, 2020

We releasing very frequently(each month), most users use very old versions.
If somebody interested in creation of xsd, we can host it, and eventually generate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants