Skip to content
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

feat: add support for infection and psalm #386

Merged
merged 2 commits into from
May 29, 2024
Merged

feat: add support for infection and psalm #386

merged 2 commits into from
May 29, 2024

Conversation

lotyp
Copy link
Member

@lotyp lotyp commented May 29, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced configuration for Infection mutation testing tool.
    • Added new linting and mutation testing targets.
  • Improvements

    • Enhanced type hinting and parameter checks in various methods.
    • Updated and added new development dependencies for better tooling and testing.
    • Separated API documentation into public and admin sections for better clarity.
  • Bug Fixes

    • Adjusted rate limiting logic for more accurate key determination.
    • Fixed encoding pragma settings to handle larger files.
  • Documentation

    • Added new keywords related to Laravel and boilerplate development in composer.json.
  • Chores

    • Updated scripts for static analysis tools and testing in composer.json.

@github-actions github-actions bot added the type: enhancement For features and enhancements (feat) label May 29, 2024
Copy link

coderabbitai bot commented May 29, 2024

Walkthrough

The recent changes introduce enhancements and optimizations across various components of the project. Key updates include the addition of new linting and mutation testing targets in the Makefile, expanded development dependencies in composer.json, and configuration for mutation testing with Infection. Several files saw minor but crucial adjustments to type hints, method parameters, and comments to improve code quality and maintainability. These updates collectively aim to enhance the development workflow and ensure robust code quality.

Changes

File/Path Change Summary
.pre-commit-config.yaml Added --maxkb=600 argument to fix-encoding-pragma hook.
Makefile Added linting and mutation testing targets; separated api-docs into public and admin.
app/composer.json Added new keywords and development dependencies; updated versions; added new scripts for tools.
app/infection.json.dist Introduced configuration settings for Infection mutation testing tool.
app/psalm-baseline.xml Merged alterations related to removed classes, methods, and properties.
.../Bridge/Laravel/Application.php Modified path method to check for non-empty $path before appending.
.../Bridge/Laravel/Http/Middleware/... Added // @phpstan-ignore-next-line comment before $guards assignment in handle method.
.../Bridge/Laravel/Providers/EventService... Updated type hints for $listen property.
.../Bridge/Laravel/Providers/RouteService... Replaced null coalescing operator ?: with null coalescing assignment ?? in RateLimiter::for.
.../Support/Filters/FuzzyFilter.php Changed parameter type hint to mixed and renamed loop variable inside __invoke method.

Sequence Diagram(s) (Beta)

No sequence diagrams are necessary as the changes are varied and do not introduce new features or significant modifications to control flow.

Poem

In the realm of code so bright,
New targets and tools take flight,
Lint and test, with fervor keen,
Ensuring all remains pristine.
Paths and types, refined with care,
A rabbit's touch, everywhere.
Hopping through the code we go,
Making sure it all will flow.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 4228153 and 15ca1e3.
Files ignored due to path filters (1)
  • app/composer.lock is excluded by !**/*.lock
Files selected for processing (6)
  • .pre-commit-config.yaml (1 hunks)
  • Makefile (4 hunks)
  • app/composer.json (3 hunks)
  • app/infection.json.dist (1 hunks)
  • app/psalm-baseline.xml (1 hunks)
  • app/psalm.xml (1 hunks)
Files skipped from review due to trivial changes (3)
  • .pre-commit-config.yaml
  • app/infection.json.dist
  • app/psalm.xml
Additional comments not posted (7)
app/composer.json (3)

25-42: Added new development dependencies for testing and static analysis.

Ensure that these new dependencies are compatible with the existing project setup and do not introduce version conflicts.


64-64: Enabled the infection/extension-installer plugin.

This change will facilitate the installation of extensions required by Infection, enhancing the mutation testing setup.


101-124: Added new scripts for mutation testing, static analysis, and testing coverage.

Verify that these scripts are integrated correctly in the CI/CD pipelines and that they function as expected in both local and CI environments.

Makefile (3)

251-253: Added new Makefile targets for static analysis and mutation testing.

Ensure that these targets are documented properly and that team members are aware of how to use them effectively.

Also applies to: 259-261, 263-265, 267-269, 277-279, 281-283, 285-287, 300-302, 304-306, 316-318, 320-322


316-322: Introduced new targets for generating API documentation.

This change will help in maintaining separate documentation for public and admin APIs, which can improve API governance and clarity for different user roles.


335-337: Added a new target for running database migrations.

Ensure that this target is tested thoroughly to prevent any disruptions in the production environment.

app/psalm-baseline.xml (1)

1-392: Configured Psalm baseline settings.

This configuration helps in managing the existing code issues while gradually improving the codebase. Ensure that the baseline is updated regularly as code issues are resolved.

Copy link

codecov bot commented May 29, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 48.36%. Comparing base (bb77426) to head (5ef9399).
Report is 1 commits behind head on develop.

Files Patch % Lines
app/src/Support/Filters/FuzzyFilter.php 0.00% 3 Missing ⚠️
.../Bridge/Laravel/Providers/RouteServiceProvider.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #386   +/-   ##
==========================================
  Coverage      48.36%   48.36%           
+ Complexity        49       48    -1     
==========================================
  Files             23       23           
  Lines            122      122           
==========================================
  Hits              59       59           
  Misses            63       63           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@coderabbitai coderabbitai bot left a 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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 15ca1e3 and 5ef9399.
Files ignored due to path filters (1)
  • app/composer.lock is excluded by !**/*.lock
Files selected for processing (6)
  • app/composer.json (4 hunks)
  • app/src/Bridge/Laravel/Application.php (1 hunks)
  • app/src/Bridge/Laravel/Http/Middleware/RedirectIfAuthenticated.php (1 hunks)
  • app/src/Bridge/Laravel/Providers/EventServiceProvider.php (1 hunks)
  • app/src/Bridge/Laravel/Providers/RouteServiceProvider.php (1 hunks)
  • app/src/Support/Filters/FuzzyFilter.php (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/src/Bridge/Laravel/Http/Middleware/RedirectIfAuthenticated.php
Additional Context Used
GitHub Check Runs (1)
codecov/patch failure (3)

app/src/Bridge/Laravel/Providers/RouteServiceProvider.php: [warning] 30-30: app/src/Bridge/Laravel/Providers/RouteServiceProvider.php#L30
Added line #L30 was not covered by tests


app/src/Support/Filters/FuzzyFilter.php: [warning] 22-22: app/src/Support/Filters/FuzzyFilter.php#L22
Added line #L22 was not covered by tests


app/src/Support/Filters/FuzzyFilter.php: [warning] 28-29: app/src/Support/Filters/FuzzyFilter.php#L28-L29
Added lines #L28 - L29 were not covered by tests

Additional comments not posted (6)
app/src/Bridge/Laravel/Application.php (1)

15-15: The updated path construction logic in path method is clear and prevents unnecessary directory separators when $path is empty.

app/src/Support/Filters/FuzzyFilter.php (2)

22-22: The addition of mixed type hint for $value in __invoke method enhances flexibility in handling different types of filter values.


28-29: Renaming $value to $item inside the loop improves clarity and avoids confusion with the outer scope variable.

app/src/Bridge/Laravel/Providers/EventServiceProvider.php (1)

16-16: The change in type hint for $listen property from class-string to string increases flexibility but may reduce type safety.

app/src/Bridge/Laravel/Providers/RouteServiceProvider.php (1)

30-30: The use of the null coalescing assignment operator ?? in the rate limiter logic simplifies and clarifies the intention.

app/composer.json (1)

7-20: The updates to dependencies and scripts in composer.json are well-aligned with the PR's objectives to enhance testing and static analysis capabilities.

Also applies to: 32-54, 76-76, 113-136

Comment on lines +22 to +29
public function __invoke(Builder $query, mixed $value, string $property): Builder
{
$query->where(function (Builder $query) use ($value): void {
foreach ($this->fields as $field) {
$values = (array) $value;

foreach ($values as $value) {
$query->orWhere($field, 'LIKE', "%{$value}%");
foreach ($values as $item) {
$query->orWhere($field, 'LIKE', "%{$item}%");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The search results indicate that there are no direct tests for the index method in CategoryControllerTest.php, which suggests that the changes in the __invoke method of FuzzyFilter are not covered by tests.

  • No direct tests for the __invoke method in FuzzyFilter.
  • No direct tests for the index method in CategoryControllerTest.php.
Analysis chain

The changes in __invoke method are not covered by tests.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if new changes in FuzzyFilter are covered by tests.

# Test: Search for test cases covering the `__invoke` method.
rg --type php "test.*FuzzyFilter.*__invoke"

Length of output: 45



Script:

#!/bin/bash
# Description: Verify if the FuzzyFilter class and its methods are covered by tests.

# Test: Search for any test cases related to the FuzzyFilter class.
rg --type php "FuzzyFilter"

# Test: Search for any usage of the __invoke method in the codebase.
rg --type php "->__invoke"

Length of output: 755



Script:

#!/bin/bash
# Description: Verify if the FuzzyFilter class and its methods are covered by tests.

# Test: Search for any usage of the __invoke method in the codebase.
rg --type php "__invoke"

# Test: Search for any test cases related to the IndexQuery class.
rg --type php "IndexQuery"

Length of output: 640



Script:

#!/bin/bash
# Description: Verify if the FuzzyFilter class and its methods are covered by tests.

# Test: Search for any test cases related to the CategoryController class.
rg --type php "CategoryController"

Length of output: 412



Script:

#!/bin/bash
# Description: Verify if the FuzzyFilter class and its methods are covered by tests.

# Test: Check the contents of CategoryControllerTest for tests related to the index method.
rg --type php "index" app/tests/Bridge/Laravel/Admin/Category/Controllers/CategoryControllerTest.php

Length of output: 100

@@ -27,7 +27,7 @@
public function boot(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
return Limit::perMinute(60)->by($request->user()?->id ?? $request->ip());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The searches did not yield any results, indicating that there are no direct or indirect test cases covering the rate limiter logic in RouteServiceProvider.

  • The rate limiter logic changes are not covered by tests.
Analysis chain

The changes in the rate limiter logic are not covered by tests.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if new changes in RouteServiceProvider are covered by tests.

# Test: Search for test cases covering the rate limiter logic.
rg --type php "test.*RouteServiceProvider.*RateLimiter"

Length of output: 57



Script:

#!/bin/bash
# Description: Broaden the search for test cases covering the rate limiter logic in RouteServiceProvider.

# Search for any references to the rate limiter logic in the test files.
rg --type php "RateLimiter" tests/

# Search for any references to RouteServiceProvider in the test files.
rg --type php "RouteServiceProvider" tests/

Length of output: 172



Script:

#!/bin/bash
# Description: Locate the test directory and search for test cases covering the rate limiter logic in RouteServiceProvider.

# Locate the test directory.
test_dir=$(fd --type d --name tests)

# If the test directory is found, search for references to the rate limiter logic and RouteServiceProvider.
if [ -n "$test_dir" ]; then
  rg --type php "RateLimiter" "$test_dir"
  rg --type php "RouteServiceProvider" "$test_dir"
else
  echo "Test directory not found."
fi

Length of output: 367



Script:

#!/bin/bash
# Description: Locate the test directory and search for test cases covering the rate limiter logic in RouteServiceProvider.

# Locate the test directory.
test_dir=$(fd --type d tests)

# If the test directory is found, search for references to the rate limiter logic and RouteServiceProvider.
if [ -n "$test_dir" ]; then
  rg --type php "RateLimiter" "$test_dir"
  rg --type php "RouteServiceProvider" "$test_dir"
else
  echo "Test directory not found."
fi

Length of output: 153



Script:

#!/bin/bash
# Description: Search for any indirect references or related test cases covering the rate limiter logic in RouteServiceProvider.

# Search for any references to rate limiting in the test directory.
rg --type php "rate limit" app/tests/

# Search for any references to user ID or IP address in the test directory, as these are used in the rate limiter logic.
rg --type php "user()->id" app/tests/
rg --type php "request->ip" app/tests/

Length of output: 120

@lotyp lotyp merged commit b424af4 into develop May 29, 2024
6 of 7 checks passed
@lotyp lotyp deleted the feat/laravel-11 branch May 29, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement For features and enhancements (feat)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant