question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Check if any import matches

See original GitHub issue

Context

Our codebase is moving to a new arch and I want to add a warning if a module hasn’t been migrated yet. Essentially, I want to check if a type of dependency exists.

Let’s say I want to check if all the controller modules have been migrated, which I can simplify into a check to see if they extend the new base controller, for eg:

class 'AbcController' extends 'GenericController'

Expected Behavior

I want to check if AbcController contains an import for GenericController:

    {
      name: 'no-clean-arch-controller',
      severity: 'warn',
      "from": { "path": "^src\/api\/([^/]+)\/([a-zA-Z]+Controller.ts)"},
      "to": { 
        "pathNot": "src\/framework\/GenericController.ts" 
      },
    }

with the result:

no-clean-arch-controller: src/api/x/abcController.ts → src/framework/GenericController.ts

Current Behavior

It currently tells me about all the imports that aren’t GenericControllerImpl, and nothing

no-clean-arch-controller: src/api/x/abcController.ts → src/example/some-import.ts
no-clean-arch-controller: src/api/x/abcController.ts → src/example/another-import.ts

Possible Solution

A boolean to signify that there’s no dependency from A to B would be helpful.

Considered alternatives

I tried to make it work with allowed, but it became too complex and didn’t solve my issue anyway.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
hzauncommented, Jul 6, 2020

I was using dependency-cruiser@9.9.0-beta-3, just updated to beta-4, it works as expected, thank you so much!

1reaction
sverweijcommented, Jul 5, 2020

Just a ping: I’ve done some polishing (published in beta-2, 3 and 4). Most notable change, only for the new required rules: the from attribute was renamed to module so in the future it’s possible to use the ‘from’ attribute for other useful things. E.g. to make sure each source file has an associated spec file in the unit tests folder that directly points to it:

// future feature
{
  required: [{
    name: "spec-per-source",
    comment: 'for each source file there should be at least a corresponding spec file in the test folder',
    module: {
      path: "^src/(.+)\\.js$"
    },
    from: {
      path: "^test/$1\\.spec\\.js$"
    }
  }]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

add check to allow importing of matching software so long ...
Feature request - add check to allow importing of matching software so long as supported_architectures have unshared values #1076.
Read more >
Request Matching — requests-mock 1.9.4.dev26 documentation
The most simple way to match a request is to register the URL and method that will be requested with a textual response....
Read more >
Python's Requests Library (Guide)
In this tutorial on Python's "requests" library, you'll see some of the most useful features that requests has to offer as well as...
Read more >
Understanding Client Matching Using the Data Import Tool (DIT)
Regular Matching goes through a multi-step comparison to determine a match, leveraging the Yaro-Winkler string metric for some of the fields.
Read more >
Choose when to run jobs - GitLab Docs
When a match is found, the job is either included or excluded from the pipeline, depending on the configuration. See the rules reference...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found