Skip to content

Conversation

@ShotaroMuraoka
Copy link
Contributor

Overview

By default, it recursively scans the current directory for composer.json and composer.lock.
When "files" are specified in the configuration, the scan should start from those directories, but it was also scanning the current directory.
This behavior has been fixed to scan from the specified directories when files are defined, and from the current directory when they are not.
Related issues: #463 #510

Result

.phpmetrics.json

{
  "includes": [
    "app"
  ],
  "exclude": [
    "tests",
    "vendor",
    "docker"
  ],
  "report": {
    "html": "./tmp/php-metrics/report/",
    "csv": "./tmp/php-metrics/report.csv",
    "json": "./tmp/php-metrics/report.json",
    "violations": "./tmp/php-metrics/violations.xml"
  }
}

Before Fix

% ./vendor/bin/phpmetrics --config=./.phpmetrics.json


Executing system analyzes...

Executing composer analyzes, requesting https://packagist.org...PHP Fatal error:  Uncaught UnexpectedValueException: RecursiveDirectoryIterator::__construct(./docker): Failed to open directory: Permission denied in ...

After Fix

% ./vendor/bin/phpmetrics --config=./.phpmetrics.json


Executing system analyzes...

Executing composer analyzes, requesting https://packagist.org...

LOC
    Lines of code                               8
    Logical lines of code                       8
    Comment lines of code                       0
    Average volume                              0
    Average comment weight                      0
    Average intelligent content                 0
    Logical lines of code by class              8
    Logical lines of code by method             8
...
Done

@Halleck45
Copy link
Collaborator

Hi @ShotaroMuraoka ,

That makes perfect sense. Thanks a lot for your contribution!

@Halleck45 Halleck45 merged commit 336ce35 into phpmetrics:master Sep 17, 2025
13 checks passed
@ShotaroMuraoka ShotaroMuraoka deleted the fix/scanning-invalid-directories branch September 18, 2025 05:58
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.

2 participants