jQAssistant / jqassistant

Your Software. Your Structures. Your Rules.
https://jqassistant.org/
GNU General Public License v3.0
198 stars 35 forks source link

Validate constraints only if a precondition is fulfilled #428

Open obfischer opened 8 years ago

obfischer commented 8 years ago

Sometimes a constraint is only usefull under certain preconditions. E.g. I have a global set of contraints and concepts. They are packaged in a seperate jar and declared as dependency of the jQAssistant Maven Plugin in a global parent POM.

For example I have some constraints on a specific YAML configuration file but this file does not exist in all of my projects. To handle this I could formulate a query which covers both cases. This approach is working but make writing Cypher queries more difficult and seems somehow to be wrong. In case the precondition (as part of the query) is not fulfilled the constraints will be reported as fulfilled. But how can I fulfill something what does not exist?

To handle such thinks I would like to have support for preconditions as we know them from http://www.liquibase.org/documentation/preconditions.html. If a precondition is given the constraint will be valided only if the precondition is fulfilled. If not the constraint will be skipped.

DirkMahler commented 8 years ago

I understand the idea but we need to clarify if concepts aren't already playing this role, i.e. if a concept cannot be applied then all other rules depending on it shall be skipped.

obfischer commented 8 years ago

This would hinder a user to express some constraints.

Imagine two concepts C0 and C1 and a constraint A. Contraint A requires C0 and C1. It expresses a condition in the form b1 OR b2. The term b1 requires concept C0. The termin b2 requrires concept C1.

If concept C0 xor C1 can not applied the constraint A will not be executed and possible violations found by the term not depending on the not applied constraint wouldn't be found. Therefore the execution of a constraint must not depend on a non-empty resultset of any constraint.