Improve PHPStan config#230
Conversation
Summary of ChangesHello @BrianHenryIE, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the project's static analysis and code quality enforcement by refining the PHPStan configuration and related Composer scripts. It elevates the strictness of PHPStan analysis to its maximum level, integrates automatic code style fixing into the change analysis process, and streamlines the PHPStan setup by removing an unnecessary bootstrap file and configuring error reporting more precisely. These changes lay the groundwork for more robust continuous integration, as indicated by the intent to integrate with GitHub Actions for error annotation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request improves the PHPStan configuration by updating the analysis level to max, removing an unused bootstrap file, and cleaning up the configuration. It also refactors some composer scripts for running code style checks. The changes are generally good, but there are opportunities to further improve the composer scripts by reducing duplication and simplifying complex shell commands. I've added a couple of suggestions to address this.
| ], | ||
| "analyze-changes-strict": [ | ||
| "updated_files=$(echo $(git diff --name-only `git merge-base origin/master HEAD` | grep php | tr '\\n' '\\0' | xargs -0 ls -1df 2>/dev/null)); if [ -n \"$updated_files\" ]; then echo \"Found: $updated_files\"; phpstan analyse --memory-limit=-1 $updated_files --level 9 --verbose || true; else echo \"No modified php files for phpstan.\"; fi;" | ||
| "updated_files=$(echo $(git diff --name-only `git merge-base origin/master HEAD` | grep php | tr '\\n' '\\0' | xargs -0 ls -1df 2>/dev/null)); if [ -n \"$updated_files\" ]; then echo \"Found: $updated_files\"; phpstan analyse --memory-limit=-1 $updated_files --level max --verbose || true; else echo \"No modified php files for phpstan.\"; fi;" |
There was a problem hiding this comment.
This long command to get updated files is repeated in multiple scripts and can be simplified. The part echo $(... | grep php | tr ...) is a complex way to filter for existing PHP files. You can achieve the same result more cleanly using git diff's built-in filtering capabilities.
This simplification can be applied to analyze-changes, analyze-changes-strict, cs-changes, and cs-changes-strict scripts.
"updated_files=$(git diff --name-only --diff-filter=ACMRTUXB \`git merge-base origin/master HEAD\` -- '**/*.php'); if [ -n \"$updated_files\" ]; then echo \"Found: $updated_files\"; phpstan analyse --memory-limit=-1 $updated_files --level max --verbose || true; else echo \"No modified php files for phpstan.\"; fi;"
Add a GitHub Actions workflow to annotate errors to max level, and fail on the level specified in
phpstan.neon(currently level 7).TODO: modify the badge displayed in the README to be gray with a red X when the workflow is failing. (I have this in another repo somewhere)