qossmic / deptrac

Keep your architecture clean.
https://qossmic.github.io/deptrac
MIT License
2.59k stars 136 forks source link

Option --report-uncovered placed before --config-file makes deptrac ignore the provided configuration file #1425

Open Fractaos opened 1 month ago

Fractaos commented 1 month ago

Tested on: 2.0.1

Hello, while doing some tests on a project, I figured out that somehow, when placing the flag --report-uncovered (or --fail-on-uncovered) before specifying the configuration file through the --config-file option, this last one is ignored and deptrac tries to use the default configuration file instead.

The problem doesn't occur for the --no-cache flag for instance but I've not tested the other ones.

Examples:

Running tools/vendor/bin/deptrac analyze --config-file=deptrac_hexagonal.yaml --report-uncovered will works properly, with the following output:

 57/57 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 -------------------- ----- 
  Report                    
 -------------------- ----- 
  Violations           0    
  Skipped violations   0    
  Uncovered            0    
  Allowed              250  
  Warnings             0    
  Errors               0    
 -------------------- ----- 

But running tools/vendor/bin/deptrac analyze --report-uncovered --config-file=deptrac_hexagonal.yaml will give me an error due to deptrac.yml not being found:

In CannotLoadConfiguration.php line 12:

  Could not load deptrac.yaml. Reason: The file "deptrac.yaml" does not exist (in: "/var/www").  

For additional information, I tested the same operation on another project where qossmic/deptrac-shim:1.0.2 is installed instead and it seems to work without any issue.

gennadigennadigennadi commented 1 month ago

image The problem is that as soon as there is a not defined argument the bind will throw and stop parsing the other args.

If I remember correctly the reason for this behaviour has something to do with sharing common configs over the commands.

@dbrumann, @patrickkusebauch Am I right?

gennadigennadigennadi commented 1 month ago

A quick fix would be to use $input->getParameterOption('--config-file') instead of $input->getOption('config-file');

Maybe just revert this commit: https://github.com/qossmic/deptrac-src/commit/703b21247a620f465cb0b45dab996b3201316313 ?