<commit_before>[[structure:Default]]
[role=group,includesConstraints="dependency:PackageCycles(minor), dependency:WrongDirection(critical)"]
- Package cycles
- <<dependency:WrongDirection>>

[[package:PackageLevel]]
.Set the level property of a package, e.g. 1 for de, 2 for de.kontext_e and so on.
[source,cypher,role=concept,requiresConcepts="dependency:Package"]
----
MATCH
    (p:Java:Package)
WITH
    SPLIT(p.fqn,".") AS splitted, p
SET
    p.level=SIZE(splitted)
RETURN
    splitted, SIZE(splitted);
----

[[dependency:TransitivePackageDependencies]]
.Add a DEPENDS_ON relationship to parents of a package P from other packages up to the same level of the source package.
[source,cypher,role=concept,requiresConcepts="package:PackageLevel"]
----
MATCH
    (p:Java:Package)-[:DEPENDS_ON]->(p2:Java:Package),
    (parent:Java:Package)-[:CONTAINS*]->(p2:Java:Package)
WHERE
    p.level <= parent.level
CREATE UNIQUE
    (p)-[:DEPENDS_ON]->(parent)
RETURN
    p.fqn, parent.fqn;
----

[[documented:TechnicalDebt]]
.Creates a relationship between two Packages for Technical Debt.
[source,cypher,role=concept]
----
match (a:Asciidoc:Table)-[:BODY]->(body)
where a.title='Unwantend Module Dependencies'
with body
match (c1:Asciidoc:Cell {colnumber: 0})<-[:CONTAINS_CELLS]-(body)-[:CONTAINS_CELLS]->(c2:Asciidoc:Cell {colnumber: 1})
with c1, c2
MATCH
    (m1:Java:Package), (m2:Java:Package)
WHERE
    m1.fqn = c1.text
AND
    m2.fqn = c2.text
MERGE
    (m1)-[:TECHNICAL_DEBT]->(m2)
RETURN
    m1, m2;
----

[[dependency:WrongDirection]]
.Finds package dependencies which are in the wrong direction according to the documentation.
[source,cypher,role=constraint,requiresConcepts="dependency:TransitivePackageDependencies, documented:TechnicalDebt",severity=critical]
----
MATCH
    (p1:PlantUml:Package)-[:MAY_DEPEND_ON]->(p2:PlantUml:Package),
    (p3:Java:Package)-[:DEPENDS_ON]->(p4:Java:Package)
WHERE
    p1.fqn = p4.fqn
    AND p2.fqn = p3.fqn
    AND NOT (p3)-[:TECHNICAL_DEBT]->(p4)
RETURN
    p3.fqn + "-->" + p4.fqn AS WrongDirection;
----
<commit_msg>fixed jqa query after update to newest jQA + plugins releases<commit_after>[[structure:Default]]
[role=group,includesConstraints="dependency:PackageCycles(minor), dependency:WrongDirection(critical)"]
- Package cycles
- <<dependency:WrongDirection>>

[[package:PackageLevel]]
.Set the level property of a package, e.g. 1 for de, 2 for de.kontext_e and so on.
[source,cypher,role=concept,requiresConcepts="dependency:Package"]
----
MATCH
    (p:Java:Package)
WITH
    SPLIT(p.fqn,".") AS splitted, p
SET
    p.level=SIZE(splitted)
RETURN
    splitted, SIZE(splitted);
----

[[dependency:TransitivePackageDependencies]]
.Add a DEPENDS_ON relationship to parents of a package P from other packages up to the same level of the source package.
[source,cypher,role=concept,requiresConcepts="package:PackageLevel"]
----
MATCH
    (p:Java:Package)-[:DEPENDS_ON]->(p2:Java:Package),
    (parent:Java:Package)-[:CONTAINS*]->(p2:Java:Package)
WHERE
    p.level <= parent.level
CREATE UNIQUE
    (p)-[:DEPENDS_ON]->(parent)
RETURN
    p.fqn, parent.fqn;
----

[[documented:TechnicalDebt]]
.Creates a relationship between two Packages for Technical Debt.
[source,cypher,role=concept]
----
    MATCH
        (a:Asciidoc:Table)-[:BODY]->(body)
    WHERE
        a.title='Unwantend Module Dependencies'
    WITH
        body
    MATCH
        (c1:Asciidoc:Cell {colnumber: 0})<-[:CONTAINS_CELLS]-(body)-[:CONTAINS_CELLS]->(c2:Asciidoc:Cell {colnumber: 1})
    WITH
        c1, c2
    MATCH
        (m1:Java:Package), (m2:Java:Package)
    WHERE
        m1.fqn = c1.text
    AND
        m2.fqn = c2.text
    MERGE
        (m1)-[:TECHNICAL_DEBT]->(m2)
    RETURN
        m1, m2
----

[[dependency:WrongDirection]]
.Finds package dependencies which are in the wrong direction according to the documentation.
[source,cypher,role=constraint,requiresConcepts="dependency:TransitivePackageDependencies, documented:TechnicalDebt",severity=critical]
----
MATCH
    (p1:PlantUml:Package)-[:MAY_DEPEND_ON]->(p2:PlantUml:Package),
    (p3:Java:Package)-[:DEPENDS_ON]->(p4:Java:Package)
WHERE
    p1.fullName = p4.fqn
    AND p2.fullName = p3.fqn
    AND NOT (p3)-[:TECHNICAL_DEBT]->(p4)
RETURN
    p3.fqn + "-->" + p4.fqn AS WrongDirection;
----

{'fraction_non_alphanumeric': 0.153306847394251, 'fraction_numerical': 0.014956765599439122, 'mean_word_length': 4.480153649167733, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6243701', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1517, 'n_words': 305}