jraska / jraska/modules-graph-assert

Strange naming convention if applying rules with root project

Open
#339 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
640
Forks
35
Avg merge
2d 21h
Merged PRs (30d)
1

Description

Hi 👋 ,

I’m using the plugin with a setup roughly like this:

moduleGraphAssert {
    allowed = arrayOf(
        ":lib:.* -> :libraries",
        ":lib:.* -> :libraries-testing",
        ":lib:.* -> :lib:.*",
        ":feature:.* -> :libraries",
        ":feature:.* -> :libraries-testing",
        ":feature:.* -> :lib:.*",
        ":libraries-testing -> :.*",

        // Expected this to work for the root project:
        ": -> :.*",
    )

    restricted = arrayOf(
        ":lib:.* -X> :feature:.*",
        ":feature:.* -X> :feature:.*",
    )
}

The root project has dependencies on feature/lib modules.
I expected the root project to be matched as :, but the assertion failed with entries like:

'root  library' -> ':lib:authorization'
'root  library' -> ':feature:onboarding'

(note the two empty spaces here between root and library.

So I had to use this instead:

"root  library -> :.*"

The double space seems to come from moduleDisplayName():

fun Project.moduleDisplayName(): String {
  return displayName.replace("project", "")
    .replace("'", "")
    .trim()
}

For a root project display name like root project '[name]' instead of project ':[name]'.
So the root results in root [name].

Questioning the displayName here at all, because basically you want to use Project.path, no? 🤔
Anyways, another solution would be to check if its the root project (this.name == project.rootProject.name or so 🤷 ) and then return maybe just root or even :...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating moduleDisplayName() and inspect how Project.path and root-project display names are represented. Reproduce the provided root-to-module dependency setup and verify the assertion's expected root-project rule matching; done means the root project matches without requiring the double-spaced display name.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.