-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update metafiles and code style #36
Conversation
Warning Rate limit exceeded@roxblnfk has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 40 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces comprehensive configuration and code style updates across the project. The changes span multiple files, focusing on improving code consistency, updating development dependencies, and refining workflow configurations. Key modifications include adding code style fixer configurations, updating GitHub Actions workflows, adjusting Git-related files like Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/Method.php (2)
58-79
: LGTM! Robust method parsing implementation.The
parse
method provides a type-safe way to create Method instances from ReflectionMethod objects.Note: Consider adding PHPDoc for thrown exceptions to improve API documentation.
/** * Creates a new {@see Method} object from a {@see \ReflectionMethod} object. + * @throws GRPCException When the method signature is invalid */ public static function parse(\ReflectionMethod $method): Method
Line range hint
15-39
: Consider cleaning up unused error constants.Some error constants appear to be only used in private validation methods. Consider moving them closer to their usage or making them private if they're not part of the public API.
tests/Stub/TestService.php (1)
39-41
: Remove Unnecessary BracesThe braces around the
throw
statement are unnecessary and can be removed to simplify the code.Apply this diff to remove the unnecessary braces:
- { throw new \Exception("Just another exception"); - }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
.gitattributes
(1 hunks).github/workflows/cs-fix.yml
(1 hunks).gitignore
(1 hunks).php-cs-fixer.dist.php
(1 hunks)composer.json
(2 hunks)phpunit.xml
(1 hunks)psalm-baseline.xml
(1 hunks)psalm.xml
(1 hunks)src/Context.php
(1 hunks)src/Internal/Json.php
(1 hunks)src/Invoker.php
(0 hunks)src/Method.php
(1 hunks)src/ResponseHeaders.php
(0 hunks)src/Server.php
(3 hunks)src/ServiceInterface.php
(1 hunks)tests/ContextTest.php
(5 hunks)tests/InvalidInterface.php
(1 hunks)tests/MethodTest.php
(1 hunks)tests/ServerTest.php
(6 hunks)tests/ServiceWrapperTest.php
(8 hunks)tests/Stub/TestService.php
(3 hunks)
💤 Files with no reviewable changes (2)
- src/Invoker.php
- src/ResponseHeaders.php
✅ Files skipped from review due to trivial changes (9)
- .php-cs-fixer.dist.php
- src/Internal/Json.php
- tests/ContextTest.php
- tests/InvalidInterface.php
- tests/ServiceWrapperTest.php
- src/Context.php
- src/ServiceInterface.php
- psalm-baseline.xml
- tests/MethodTest.php
🧰 Additional context used
🪛 GitHub Actions: phpunit
phpunit.xml
[warning] No filter is configured, code coverage will not be processed
tests/ServerTest.php
[warning] 112-112: Risky test in testExceptionDetails: Test code or tested code closed output buffers other than its own
🔇 Additional comments (15)
src/Method.php (2)
42-42
: LGTM! Constructor style improvement.Empty constructor body has been simplified to use the constructor property promotion feature.
44-56
: LGTM! Well-designed method signature validation.The
match
method provides a clean way to validate method signatures without throwing exceptions..gitignore (1)
1-4
: LGTM! Standardized .gitignore entries.The entries have been standardized to use leading slashes, which makes the paths more explicit and prevents accidental matches in subdirectories.
.gitattributes (1)
1-10
: LGTM! Improved Git attributes configuration.The changes:
- Add proper line ending normalization with
text=auto
- Exclude development files from package exports
- Use consistent formatting for export-ignore rules
phpunit.xml (1)
3-5
: LGTM! Good improvements to the PHPUnit configuration.The changes to use local schema and enable result caching are good practices that will improve reliability and performance.
🧰 Tools
🪛 GitHub Actions: phpunit
[warning] No filter is configured, code coverage will not be processed
psalm.xml (1)
6-6
: LGTM! Good addition of Psalm baseline configuration.Adding error baseline support is a good practice that will help track and manage existing issues while preventing new ones.
composer.json (1)
54-55
: LGTM! Well-structured updates for code style tooling.The additions of code style dependencies and related scripts are well organized and align perfectly with the PR objectives. The script naming follows common conventions and provides good separation between checking (
cs:diff
) and fixing (cs:fix
) operations.Also applies to: 71-75
src/Server.php (3)
42-42
: Constructor Simplification Looks GoodThe constructor has been simplified, and the initializations appear correct.
90-90
: Confirm Exception Handling LogicCasting the exception to a string when
isDebugMode()
is true will include the stack trace in the error message. Ensure that this behavior is intended and acceptable, as it may expose sensitive information in a production environment.
115-146
: Reintroduction of Private Methods Appears CorrectThe methods
tick
,workerSend
, andworkerError
have been reintroduced and appear to be correctly implemented. They restore functionality for processing requests and handling responses.tests/Stub/TestService.php (2)
3-3
: Enabling Strict TypesThe addition of
declare(strict_types=1);
is a good practice to enforce strict type checking.
49-49
: Consistent Use of Global Namespace for Built-in FunctionsPrefacing built-in function calls with the global namespace
\
(e.g.,\error_log
,\getenv
,\getmypid
,\json_encode
) is good practice to prevent potential conflicts with user-defined functions.Also applies to: 60-60, 64-64, 68-68
tests/ServerTest.php (3)
59-62
: Use of Static Anonymous Functions and Global NamespacesAdding the
static
keyword to anonymous functions and prefixing global function calls with\
(e.g.,\base64_decode
,\json_decode
,\mb_strlen
) is a good practice that can improve performance and avoid conflicts with overridden functions.Also applies to: 81-84, 103-103, 127-128, 168-168, 173-173
145-147
: ChangingsetUp
Method Visibility to ProtectedChanging the
setUp
method from private to protected enhances test extensibility by allowing subclasses to override the setup process.
156-156
:⚠️ Potential issueInvestigate Risky Test Due to Output Buffering
The addition of
\ob_end_clean();
in thetearDown
method may be addressing output buffering issues. However, the pipeline reports a risky test intestExceptionDetails
: "Test code or tested code closed output buffers other than its own."Please verify that output buffering is properly managed within the tests. Ensure that any output buffers started during a test are appropriately closed, and avoid closing output buffers that the test did not open. Consider using PHPUnit's built-in methods for handling output buffering.
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
name: Fix Code Style | ||
|
||
jobs: | ||
cs-fix: | ||
permissions: | ||
contents: write | ||
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Using a floating reference (@master) is indeed risky
The verification confirms that:
- The repository has no tagged releases
- The workflow file receives active updates (last modified Dec 11, 2024)
- Breaking changes have occurred (e.g., removal of dry-run option in September 2024)
To ensure stability, pin the workflow to a specific commit SHA:
- uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
+ uses: spiral/gh-actions/.github/workflows/cs-fix.yml@69d50ba35b48703584c28dc0600cc283d96f2303
🔗 Analysis chain
Consider pinning the workflow version.
The workflow is well-configured, but it uses a floating reference (@master
) which could lead to unexpected behavior if the upstream workflow changes.
Consider using a specific commit SHA or tag for spiral/gh-actions
to ensure reproducible builds:
- uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
+ uses: spiral/gh-actions/.github/workflows/[email protected] # or specific SHA
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash
# Check repository and its releases
gh repo view spiral/gh-actions --json url,description,isArchived,defaultBranch
gh release list --repo spiral/gh-actions
# Check commit history of the specific workflow file
gh api -X GET /repos/spiral/gh-actions/commits \
--jq '.[] | {sha: .sha, date: .commit.committer.date, message: .commit.message}' \
-F path=.github/workflows/cs-fix.yml \
-F per_page=5 \
--repo spiral/gh-actions
Length of output: 2838
Script:
#!/bin/bash
# Check repository info
gh repo view spiral/gh-actions --json url,description,isArchived
# List releases
gh release list --repo spiral/gh-actions
# Check recent commits
gh api \
repos/spiral/gh-actions/commits \
--jq '.[] | {sha: .sha, date: .commit.committer.date, message: .commit.message}' \
-X GET \
-f path=.github/workflows/cs-fix.yml \
-f per_page=5
Length of output: 897
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
cacheResultFile="runtime/phpunit/result.cache" | ||
backupGlobals="false" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
stopOnError="false" | ||
stderr="true" | ||
backupStaticProperties="false" | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add coverage configuration to fix pipeline warning.
The pipeline is warning about missing coverage filter. This could impact code coverage reporting.
Add the following configuration:
<phpunit ...>
+ <coverage>
+ <include>
+ <directory>src</directory>
+ </include>
+ </coverage>
<testsuites>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | |
bootstrap="vendor/autoload.php" | |
cacheResultFile="runtime/phpunit/result.cache" | |
backupGlobals="false" | |
colors="true" | |
processIsolation="false" | |
stopOnFailure="false" | |
stopOnError="false" | |
stderr="true" | |
backupStaticProperties="false" | |
> | |
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | |
bootstrap="vendor/autoload.php" | |
cacheResultFile="runtime/phpunit/result.cache" | |
backupGlobals="false" | |
colors="true" | |
processIsolation="false" | |
stopOnFailure="false" | |
stopOnError="false" | |
stderr="true" | |
backupStaticProperties="false" | |
> | |
<coverage> | |
<include> | |
<directory>src</directory> | |
</include> | |
</coverage> |
🧰 Tools
🪛 GitHub Actions: phpunit
[warning] No filter is configured, code coverage will not be processed
Summary by CodeRabbit
Release Notes
Code Style
Development Dependencies
Configuration Updates
Minor Refactoring
Testing