Skip to content

Conversation

sverweij
Copy link
Owner

@sverweij sverweij commented Oct 27, 2024

Description

  • adds an ancestor matcher

Motivation and Context

It's probably possible to do this with regular expressions and group matching, but so far I haven't found a simple way to do that.

How Has This Been Tested?

  • green ci
  • additional automated integration tests
  • additional automated unit tests
  • self-run (added a no-ancestors rule to our own .dependency-cruiser.mjs)

Screenshots

You can now do things like this:

// in the `forbidden` section of a dependency-cruiser config:
{
  name: "no-ancestor",
  comment: "don't allow importing from folders above the current one",
  severity: "error",
  from: {},
  to: { "ancestor": true }
}

Which, when run as part of a validation, would yield errors on every dependency that goes folders up in stead of down:

sample-ancestor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

@sverweij sverweij marked this pull request as draft October 27, 2024 12:54
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from dd5fedb to 43e5d79 Compare November 3, 2024 18:07
@github-actions github-actions bot added the stale label Nov 14, 2024
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 43e5d79 to 819d9f6 Compare November 14, 2024 20:51
@github-actions github-actions bot removed the stale label Nov 16, 2024
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 819d9f6 to 9b9ea4d Compare November 17, 2024 20:06
@sverweij sverweij force-pushed the main branch 7 times, most recently from 95331ab to aae6edd Compare November 22, 2024 19:26
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 9b9ea4d to befba72 Compare November 24, 2024 13:54
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch 2 times, most recently from 3499b9d to 1d495cf Compare December 1, 2024 19:30
@github-actions github-actions bot added the stale label Dec 12, 2024
@sverweij sverweij removed the stale label Dec 16, 2024
@github-actions github-actions bot added the stale label Dec 26, 2024
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 1d495cf to fcc020a Compare December 30, 2024 09:31
@sverweij sverweij removed the stale label Dec 30, 2024
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from fcc020a to 49910e8 Compare January 5, 2025 14:05
@github-actions github-actions bot added the stale label Jan 16, 2025
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 49910e8 to 7c8c6a5 Compare January 17, 2025 19:56
@github-actions github-actions bot removed the stale label Jan 18, 2025
@github-actions github-actions bot added the stale label Jan 28, 2025
@github-actions github-actions bot closed this Feb 1, 2025
@sverweij sverweij reopened this Feb 9, 2025
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from d83bb30 to 7c206b0 Compare March 22, 2025 19:54
@sverweij sverweij force-pushed the main branch 2 times, most recently from 1cba0d6 to 4b75ec0 Compare March 29, 2025 02:42
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 7c206b0 to 25b0d11 Compare March 29, 2025 13:29
@sverweij sverweij requested a review from Copilot March 31, 2025 21:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new "ancestor" matcher that allows users to flag dependencies where the target module is located in a folder above the source module. The changes include updates to type definitions and schemas, new matcher logic in the validation code, comprehensive tests, and corresponding documentation.

Reviewed Changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types/restrictions.d.mts Added the optional "ancestor" property to the to-restrictions.
tools/schema/restrictions.mjs Updated the restrictions schema with the "ancestor" property.
test/validate/matchers.spec.mjs Added tests for the ancestor matcher behavior.
test/validate/index.ancestor.spec.mjs Added integration tests for dependencies using the ancestor rule.
src/validate/matchers.mjs Implemented the new matchesAncestor() function and renamed helpers.
src/validate/match-dependency-rule.mjs Integrated matchesAncestor into the dependency rule matching.
src/schema/cruise-result.schema.mjs Updated output schema to incorporate the "ancestor" property.
src/schema/configuration.schema.mjs Updated configuration schema with the new ancestor restriction.
doc/rules-reference.md Documented the new ancestor rule.
.dependency-cruiser.mjs Added sample rules utilizing the ancestor matcher.
Files not reviewed (3)
  • .dependency-cruiser-known-violations.json: Language not supported
  • src/schema/configuration.schema.json: Language not supported
  • src/schema/cruise-result.schema.json: Language not supported

@github-actions github-actions bot added the stale label Apr 17, 2025
@github-actions github-actions bot closed this Apr 24, 2025
@sverweij sverweij reopened this Apr 24, 2025
@sverweij sverweij removed the stale label Apr 24, 2025
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 25b0d11 to e86487f Compare April 24, 2025 06:22
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from e86487f to b23e08d Compare May 7, 2025 19:09
@github-actions github-actions bot added stale and removed stale labels May 24, 2025
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 6c3d4b7 to 8c007a7 Compare June 7, 2025 11:40
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch 2 times, most recently from 0882c28 to 290fe8c Compare June 16, 2025 20:03
Repository owner deleted a comment from sonarqubecloud bot Jun 16, 2025
Repository owner deleted a comment from qlty-cloud-legacy bot Jun 16, 2025
Repository owner deleted a comment from qlty-cloud-legacy bot Jun 16, 2025
Repository owner deleted a comment from sonarqubecloud bot Jun 16, 2025
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from 290fe8c to e76e909 Compare July 26, 2025 19:52
@sverweij sverweij force-pushed the feature/adds-ancestor-matcher branch from e76e909 to 5857d81 Compare August 4, 2025 20:08
Copy link

sonarqubecloud bot commented Aug 4, 2025

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

Successfully merging this pull request may close these issues.

1 participant