Skip to content

Commit

Permalink
HSEARCH-3288 Simplify concepts and constaints in the JQAssistant rules
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Nov 28, 2018
1 parent 66e244d commit 6345c21
Showing 1 changed file with 76 additions and 55 deletions.
131 changes: 76 additions & 55 deletions jqassistant/rules.xml
Expand Up @@ -7,99 +7,118 @@
-->
<jqa:jqassistant-rules xmlns:jqa="http://www.buschmais.com/jqassistant/core/analysis/rules/schema/v1.0">

<concept id="my-rules:ApiTypes">
<concept id="my-rules:Spi">
<description>
Contributes the :Api and :Public labels to API types
Contributes the :Spi label to SPI types
</description>
<cypher><![CDATA[
MATCH
(type:Type)
WHERE
NOT (type.fqn =~ ".*\\.impl\\..*")
AND NOT (type.fqn =~ ".*\\.spi\\..*")
type.fqn =~ ".*\\.spi\\..*"
SET
type:Api, type:Public
type:Spi, type:Public
RETURN
type
]]></cypher>
</concept>

<concept id="my-rules:SpiTypes">
<concept id="my-rules:Impl">
<description>
Contributes the :Spi and :Public labels to SPI types
Contributes the :Impl label to implementation types
</description>
<cypher><![CDATA[
MATCH
(type:Type)
WHERE
type.fqn =~ ".*\\.spi\\..*"
type.fqn =~ ".*\\.impl\\..*"
SET
type:Spi, type:Public
type:Impl
RETURN
type
]]></cypher>
</concept>

<concept id="my-rules:ImplTypes">
<concept id="my-rules:Test">
<description>
Contributes the :Impl label to implementation types
Contributes the :Test label to :Type nodes that exist for test purposes only.
</description>
<cypher><![CDATA[
MATCH
(type:Type)<-[:CONTAINS]-(artifact:Maven:Artifact)
WHERE
artifact.type = "test-jar"
OR artifact.name =~ "hibernate-search-integrationtest-.*"
OR artifact.name =~ "hibernate-search-util-internal-test.*"
OR artifact.name =~ "hibernate-search-util-internal-integrationtest.*"
SET
type:Test
RETURN
artifact
]]></cypher>
</concept>

<concept id="my-rules:Api">
<requiresConcept refId="my-rules:Test" />
<requiresConcept refId="my-rules:Spi" />
<requiresConcept refId="my-rules:Impl" />
<description>
Contributes the :Api label to API types
</description>
<cypher><![CDATA[
MATCH
(type:Type)
WHERE
type.fqn =~ ".*\\.impl\\..*"
NOT type:Test
AND NOT type:Impl
AND NOT type:Spi
SET
type:Impl
type:Api, type:Public
RETURN
type
]]></cypher>
</concept>

<concept id="my-rules:NonTestArtifacts">
<concept id="my-rules:HibernateSearch">
<description>
Contributes the :NonTest label to :Maven:Artifact nodes that are not supposed to contain any test type.
Contributes the :HibernateSearch label to :Maven:Artifact and :Type nodes from Hibernate Search.
</description>
<cypher><![CDATA[
MATCH
(artifact:Maven:Artifact)
(type:Type)<-[:CONTAINS]-(artifact:Maven:Artifact)
WHERE
NOT artifact.type = "test-jar"
AND NOT artifact.name =~ "hibernate-search-integrationtest-.*"
artifact.name =~ "hibernate-search-.*"
SET
artifact:NonTest
artifact:HibernateSearch,
type:HibernateSearch
RETURN
artifact
type
]]></cypher>
</concept>

<concept id="my-rules:PublicArtifacts">
<concept id="my-rules:InternalArtifacts">
<requiresConcept refId="my-rules:HibernateSearch" />
<description>
Contributes the :Public label to :Maven:Artifact nodes that may be publicly exposed.
Contributes the :Internal label to strictly internal :Maven:Artifact nodes.
</description>
<cypher><![CDATA[
MATCH
(artifact:Maven:Artifact)
(artifact:Maven:Artifact:HibernateSearch)
WHERE
NOT (
artifact.name =~ "hibernate-search-.*"
AND (
artifact.type = "test-jar"
OR artifact.name =~ ".*-integrationtest-.*"
OR artifact.name =~ ".*-internal-.*"
)
)
artifact.type = "test-jar"
OR artifact.name =~ ".*-integrationtest-.*"
OR artifact.name =~ ".*-internal-.*"
SET
artifact:Public
artifact:Internal
RETURN
artifact
]]></cypher>
</concept>

<constraint id="my-rules:PublicTypesMayNotExtendInternalTypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:ImplTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<requiresConcept refId="my-rules:Impl" />
<description>API/SPI types must not extend/implement internal types.</description>
<cypher><![CDATA[
MATCH
Expand All @@ -110,9 +129,9 @@
</constraint>

<constraint id="my-rules:PublicMethodsMayNotExposeInternalTypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:ImplTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<requiresConcept refId="my-rules:Impl" />
<description>API/SPI methods must not expose internal types.</description>
<cypher><![CDATA[
// return values
Expand All @@ -135,9 +154,9 @@
</constraint>

<constraint id="my-rules:PublicFieldsMayNotExposeInternalTypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:ImplTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<requiresConcept refId="my-rules:Impl" />
<description>API/SPI fields must not expose internal types.</description>
<cypher><![CDATA[
MATCH
Expand All @@ -150,8 +169,8 @@
</constraint>

<constraint id="my-rules:APITypesMayNotExtendSPITypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<description>API types must not extend/implement SPI types.</description>
<cypher><![CDATA[
MATCH
Expand All @@ -162,8 +181,8 @@
</constraint>

<constraint id="my-rules:APIMethodsMayNotExposeSPITypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<description>API methods must not expose SPI types.</description>
<cypher><![CDATA[
// return values
Expand All @@ -190,8 +209,8 @@
</constraint>

<constraint id="my-rules:APIFieldsMayNotExposeSPITypes">
<requiresConcept refId="my-rules:ApiTypes" />
<requiresConcept refId="my-rules:SpiTypes" />
<requiresConcept refId="my-rules:Api" />
<requiresConcept refId="my-rules:Spi" />
<description>API fields must not expose SPI types.</description>
<cypher><![CDATA[
MATCH
Expand All @@ -204,21 +223,23 @@
</constraint>

<constraint id="my-rules:TypesMayNotDependOnImplementationTypeFromOtherModules">
<requiresConcept refId="my-rules:NonTestArtifacts" />
<requiresConcept refId="my-rules:PublicArtifacts" />
<requiresConcept refId="my-rules:ImplTypes" />
<requiresConcept refId="my-rules:InternalArtifacts" />
<requiresConcept refId="my-rules:Test" />
<requiresConcept refId="my-rules:Impl" />
<description>
Types must not depend on implementation types from other modules.
SPIs must be used for such dependencies.
Exceptions are allowed only when the dependency type is in a non-public module,
or the depending type is in a test module.
Exceptions are allowed only when the dependency type is in an internal module,
or the depending type is a test type.
</description>
<cypher><![CDATA[
MATCH (artifact1:Maven:Artifact:NonTest)-[:CONTAINS]->(type1:Type)
-[:DEPENDS_ON]->
(type2:Type:Impl)<-[:CONTAINS]-(artifact2:Maven:Artifact:Public)
MATCH (artifact1:Maven:Artifact)-[:CONTAINS]->(type1:Type)-[:DEPENDS_ON]->
(type2:Type:Impl)<-[:CONTAINS]-(artifact2:Maven:Artifact)
WHERE
artifact1 <> artifact2
// Exceptions
AND NOT type1:Test
AND NOT artifact2:Internal
RETURN
artifact1, type1, artifact2, type2
]]></cypher>
Expand Down

0 comments on commit 6345c21

Please sign in to comment.