Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik samsonasik commented Jan 5, 2026

Fixes rectorphp/rector#9582

Even with --no-diffs, the total files changed should still be shown, just no diff to be shown.

With a 1 file to be changed, it shows:

Before

➜  rector-src git:(main) ✗ ./bin/rector process src/Application/FileProcessor.php --output-format=json --no-diffs --dry-run

{
    "totals": {
        "changed_files": 0,
        "errors": 0
    }
}

After

➜  rector-src git:(fix-total-changed) ./bin/rector process src/Application/FileProcessor.php --output-format=json --no-diffs --dry-run

{
    "totals": {
        "changed_files": 1,
        "errors": 0
    }
}

@samsonasik
Copy link
Member Author

Fixed 🎉 /cc @peterfox

@samsonasik samsonasik changed the title [ChangesReporting] Fix total changed result on JsonOutputFormatter [ChangesReporting] Fix total changed result on --no-diffs on JsonOutputFormatter Jan 5, 2026
@samsonasik
Copy link
Member Author

@TomasVotruba ready 👍

@peterfox
Copy link
Contributor

peterfox commented Jan 5, 2026

Amazing @samsonasik I was looking at this, my fix was way more converluted 😄. Thank you so much

@TomasVotruba TomasVotruba merged commit a5cdd61 into main Jan 5, 2026
58 checks passed
@TomasVotruba TomasVotruba deleted the fix-total-changed branch January 5, 2026 13:32
@TomasVotruba
Copy link
Member

LGTM 👍

@peterfox
Copy link
Contributor

peterfox commented Jan 5, 2026

The only thing I will add is, the way the formatter currently works, you lose the "changed_files" part of the JSON. Some might expect to still see this if the --no-diffs flag is used

    "changed_files": [
        "some/file.php"
    ],

@TomasVotruba
Copy link
Member

@peterfox Seems legit. Could you make a PR for it?

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.

--output-format=json && --no-diffs shows 0 files changed despite applying changes

4 participants