dart-lang / pana

Package ANAlysis for Dart
https://pub.dev/packages/pana
BSD 3-Clause "New" or "Revised" License
206 stars 44 forks source link

Pana assumes that the git root is the package directory #1224

Open tjarvstrand opened 1 year ago

tjarvstrand commented 1 year ago

Currently, Pana seems to assume that if there is a git root above the package directory, then that should be used as the base for the analysis. It then proceeds to copy this entire directory to a temporary location.

Unfortunately, this is very unsuitable for use in monorepo settings. Our repository contains 10's of thousands of files, totalling many gigabytes, making pana essentially unusable by default.

It's possible to work around this limitation by manually copying the package to a temporary location outside the git tree but at the moment there is no information that the copy operation is happening so I had to dig through the source to figure out what was going on.

There should be a way to override this behavior or, at the very least, something informing the user about the ongoing copying.

isoos commented 1 year ago

Yes, that's correct, pana does copy the content by default, because we may change a few things while running the analysis, and it is not desired to have side-effects on the original code, only on the working copy.

Can you give us more info about the project layout? E.g. how the packages depend on each other (assuming path: dependencies), or can the large files excluded with some pattern?

tjarvstrand commented 1 year ago

Yes, that's correct, pana does copy the content by default, because we may change a few things while running the analysis, and it is not desired to have side-effects on the original code, only on the working copy.

This is totally fine and understandable, but pana shouldn't automatically assume that the entire repository should be copied.

Can you give us more info about the project layout? E.g. how the packages depend on each other (assuming path: dependencies), or can the large files excluded with some pattern?

In terms of the package itself, the structure is a fairly simple Flutter plugin, with a native component. It does however live in the same Git repository as several other (non-flutter/Dart) packages and intermediate steps in the build process pull in and build large external dependencies (e.g. webRTC).

isoos commented 1 year ago

I could imagine a flag that disables the git-root detection, effectively making a copy only on the package directory. However, when the package has any path: ../other_package dependency, the analysis will fail in such cases. wdyt @jonasfj?

sigurdm commented 1 year ago

We could try to go towards not copying the package at all.

One way would be to create a stub-package in a temp-folder with a single dependency on the analyzed package and do resolution there.

We would probably have to run pub outdated --no-dev-dependencies in the analyzed project folder.