Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Design a new format of suppression dtd schema to support XPath queries #4364
From my and @timurt point of view, XPath for queering AST nodes will be a good idea for the new suppression model, because:
Based on the arguments, mentioned above, we decided that we need to use XPath in the new model.
What should be done in the scope of this issue:
<suppress-xpath checks="FileLength" files="TokenTypes.java" query="xpath expression here” />
I think that this is a good idea, but from my point of view, "xpath" would be a better name for the attribute. Such approach will allow us to support two models in the same file. User will not need to rewrite the whole suppression file from scratch.
Other solution is to add a new attribute to the existing "suppress" element:
<suppression checks="FileLength" lines="1,2,3" files="TokenTypes.java" xpath="xpath expression here” />
In the second approach the influence on dtd schema will be minimal.
changed the title from
Introduce new format of suppression dtd schema to support XPath queries
Design a new format of suppression dtd schema to support XPath queries
May 20, 2017
Just my opinion,
These type of users will be rare outside our own development team. Some people probably have delved into writing their own checks, but I expect most don't.
I like this solution the best.
Again, I like this solution.
I don't see it as 2 separate models, just that we are adding a new feature onto the existing model.
The original GSoC task says that
Thus, the new model should be based on the AST structure. I could not find any better ways to refer AST structure, except for XPath. We do not change token types names very often. Thus, from my point of view, we can rely on their names in the xpath expression. I thought about other solutions, for example, in the issue #2136 it is requested to add the new attribute "methods" to suppress methods with the specified names. This approach is not good as it will require to support many arguments to suppress violations for classes, methods, variables, and other language units. In the issue #2804 you suggest suppressing by message. However, it will require writing of regular expressions and sometimes the expression may become bigger and bigger, for example in import control configuration.
That is why it is required to create suppression file generator to ease suppression configuration creation for legacy code. I will increase the priority of this task.
I was not specifically saying we shouldn't do this xpath suppression with AST, I was just stating one problem that will arise with this and break compatibility between releases.
No, as they should be handled by different filters. We will apply all filters which are in filter chain. If at least one filter denies audit event, than there is no need in filtering by others.
is handled the same as
then the combined suppression seems misleading to me as I expected all attributes to be combined together, the same way
If you are saying that even though they are combined they are handled as separately, then I see no reason to keep them together, even though I would like that way better.
Lines and Xpath should never be combined. Xpath model is opposite to line-based. Maybe you are right and it is better to add a new element to the schema (suppression-xpath) to make it clear to the user that we do not support mixing of line-based suppressions with xpath. The schema should validate that suppression-xpath element does not have lines attribute.
There can be 2 or more source files with the same class name, for example.
If you agree, lets add a new element to the schema:
<suppression-xpath checks="MethodLength" files="MyClass.java, FooBar.java" query="//ClassDef//MethodDef[foo]” />
and save the old one
<suppression checks="FileLength" lines="1,2,3" files="TokenTypes.java" />
While this is probably generally true, I don't see a downside to allowing it, but I don't know the full syntax we will support in XPath.
As discussed in chat,
You will still be using
referenced this issue
Jun 5, 2017
added a commit
Jun 6, 2017
referenced this issue
Jun 6, 2017
added a commit
Jun 7, 2017
unfortunately dtd syntax does not allow "choice" for attributes - https://www.w3.org/TR/REC-xml/#attdecls
as new schema is about to appear please make its version as experimental
I am agree of format.
@MEZk , no need. Lets make Xpath work first. If any changes happen to AST structure, user will need to relaunch suppression generator. We will think about how to ease users life when we come to this problem, we will have this problem ourself first :) (as we eat food that we produce).