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

ci: add php cs fixer config #734

Merged
merged 5 commits into from
May 26, 2024
Merged

ci: add php cs fixer config #734

merged 5 commits into from
May 26, 2024

Conversation

lotyp
Copy link
Member

@lotyp lotyp commented May 26, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a GitHub Actions workflow to enforce PHP coding standards.
  • Bug Fixes

    • Corrected comparison conditions across various commands and classes to ensure proper logic flow.
  • Code Quality

    • Improved code consistency by standardizing comparison checks and refactoring constructor placements.
  • Documentation

    • Updated internal documentation for properties within classes to improve code clarity.
  • Tests

    • Adjusted test assertions to align with updated comparison logic.

Copy link

vercel bot commented May 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
laravel-cycle-orm-adapter ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2024 11:41am

Copy link

coderabbitai bot commented May 26, 2024

Walkthrough

This update introduces a GitHub Actions workflow to enforce PHP coding standards, refines conditional checks across various PHP files for improved readability, and consolidates constructors in several entity classes. Additionally, it enhances documentation and adds new constants to interfaces and classes for better configuration and functionality.

Changes

Files/Paths Change Summary
.github/workflows/coding-standards.yml Added a GitHub Actions workflow to enforce PHP coding standards using various linting tools.
Makefile Added .yamllint.yaml configuration for yamllint.
src/Bridge/Laravel/Console/Commands/Database/ListCommand.php Adjusted condition for initializing $databases array.
src/Bridge/Laravel/Console/Commands/Database/TableCommand.php Switched comparison order in an if statement.
src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php Updated while loop condition to check if $count is greater than 0.
src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php Modified while loop condition to check if $count is greater than 0.
src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php Added a constant PENDING with a specific output message.
src/Bridge/Laravel/Providers/CycleServiceProvider.php Changed condition check from true === $warmup to $warmup === true.
src/Bridge/Laravel/Providers/Registrator.php Added new constants related to configuration keys.
src/Bridge/Laravel/Rules/Exists.php Updated comparison check from 0 === $count to $count === 0.
src/Bridge/Laravel/Rules/Unique.php Adjusted comparison condition from 0 < $count to $count > 0.
src/Bridge/Telescope/Events/Database/QueryExecuted.php Changed assignment condition for $driver.
src/Bridge/Telescope/TelescopeLogger.php Switched comparison order in an if statement.
src/Bridge/Telescope/Watchers/QueryWatcher.php Changed condition check for $caller from null !== $caller to $caller !== null.
src/Contracts/GeneratorLoader.php Added new constants GROUP_RENDER and GROUP_POSTPROCESS.
src/Schema/Compiler.php Added a constructor with a readonly property $schema and updated the isEmpty method logic.
src/Schema/Generators/GeneratorQueue.php Moved type declaration for generators property to a separate doc block.
src/Testing/Constraints/HasInDatabase.php Changed comparison logic in matches method from 0 < $count to $count > 0.
src/Testing/Constraints/NotSoftDeletedInDatabase.php Updated return statement logic in matches method from 0 < $count to $count > 0.
src/Testing/Constraints/SoftDeletedInDatabase.php Updated logic to return true when count is greater than 0.
tests/app/Entities/Footprint.php Consolidated and moved constructor method above the empty method.
tests/app/Entities/Signature.php Consolidated and moved constructor to a single location within the class.
tests/app/Entities/UserId.php Moved constructor method above the create method and removed duplicate constructor.
tests/src/Bridge/Laravel/LoggerFactoryTest.php Swapped order of comparison in an assertion related to SQL query in a test method.

In code we trust, where logic flows,
Through lines and loops, our passion shows.
With every change, a bug takes flight,
Our software gleams, in the soft moonlight.
The rabbit hops, with joy and grace,
As we perfect, this digital space.


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.

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 full the 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 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.

@github-actions github-actions bot added type: maintenance For maintenance, refactor and testing (perf, chore, style, revert, refactor, test, build, ci) type: enhancement For features and enhancements (feat) labels May 26, 2024
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 d5ac074 and 8e99911.
Files selected for processing (1)
  • .github/workflows/coding-standards.yml (1 hunks)
Additional comments not posted (7)
.github/workflows/coding-standards.yml (7)

11-11: The name of the workflow is descriptive and clear.


49-65: Markdown linting job appears to be set up correctly.


66-125: Review the composer linting job, especially the matrix strategy and the steps involved.

Verification successful

The extracted configuration for the composer-linting job matches the provided snippet and includes all necessary steps and matrix configurations. The job is correctly defined with appropriate steps for setting up PHP, checking out the codebase, validating composer files, restoring cached dependencies, and installing dependencies.

  • The matrix strategy includes os, php-version, and dependencies.
  • The steps cover setting up PHP, checking out the codebase, setting up problem matchers, validating composer files, getting the composer cache directory, restoring cached dependencies, and installing dependencies.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the composer linting job configuration.

# Test: Search for the composer linting job configuration.
rg --type yaml $'jobs: { composer-linting: { timeout-minutes: 4, runs-on: ${{ matrix.os }}, concurrency: { cancel-in-progress: true, group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}, strategy: { matrix: { os: [ubuntu-latest], php-version: ['8.2'], dependencies: [locked] }, permissions: { contents: write }, steps: [...] } } }' .github/workflows/coding-standards.yml

Length of output: 867



Script:

#!/bin/bash
# Description: Verify the composer linting job configuration.

# Test: Search for the composer linting job configuration.
rg --type yaml 'composer-linting' .github/workflows/coding-standards.yml

Length of output: 199



Script:

#!/bin/bash
# Description: Extract the full configuration of the composer linting job.

# Test: Extract the full configuration of the composer linting job.
rg -A 50 'composer-linting:' .github/workflows/coding-standards.yml

Length of output: 1850


3-9: Ensure the workflow triggers are correctly configured.


13-31: Review the configuration and settings for the commit linting job.

Verification successful

The search confirmed the presence of the commit-linting job in the .github/workflows/coding-standards.yml file. However, to fully verify the configuration and settings, we need to extract the complete job definition.


The extracted configuration for the commit-linting job matches the provided snippet and appears to be correctly set up. The job includes checking out the codebase and linting commits using "commitlint" with the specified configuration file and settings.

  • The job is configured to run on ubuntu-latest.
  • It has a timeout of 4 minutes.
  • It has read permissions for contents and pull-requests.
  • It uses actions/[email protected] to check out the codebase.
  • It uses wagoid/[email protected] for commit linting with the specified configuration file.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the commit linting job configuration.

# Test: Search for the commit linting job configuration.
rg --type yaml $'jobs: { commit-linting: { timeout-minutes: 4, runs-on: ubuntu-latest, permissions: { contents: read, pull-requests: read }, steps: [...] } }' .github/workflows/coding-standards.yml

Length of output: 429



Script:

#!/bin/bash
# Description: Verify the commit linting job configuration.

# Test: Search for the commit linting job configuration.
rg --type yaml 'jobs:\s*commit-linting:\s*timeout-minutes:\s*4\s*runs-on:\s*ubuntu-latest\s*permissions:\s*contents:\s*read\s*pull-requests:\s*read\s*steps:' .github/workflows/coding-standards.yml

Length of output: 198



Script:

#!/bin/bash
# Description: Verify the commit linting job configuration.

# Test: Search for the commit linting job configuration.
rg --type yaml 'jobs:\s*commit-linting:\s*timeout-minutes:\s*4\s*runs-on:\s*ubuntu-latest' .github/workflows/coding-standards.yml

Length of output: 131



Script:

#!/bin/bash
# Description: Verify the commit linting job configuration.

# Test: Search for the commit linting job configuration.
rg --type yaml 'commit-linting' .github/workflows/coding-standards.yml

Length of output: 88



Script:

#!/bin/bash
# Description: Extract the complete commit linting job configuration.

# Test: Extract the complete job configuration for commit-linting.
rg --type yaml -A 20 'commit-linting:' .github/workflows/coding-standards.yml

Length of output: 715


126-196: Ensure the coding standards job is correctly configured and that it effectively commits changes back to GitHub.


32-48: Check the YAML linting job for any potential issues.

Verification successful

The YAML linting job configuration in the .github/workflows/coding-standards.yml file appears to be correctly set up based on the provided script output.

  • The job is named yaml-linting.
  • It has a timeout of 4 minutes.
  • It runs on ubuntu-latest.
  • It has the necessary permissions (contents: read and pull-requests: read).
  • The steps include checking out the codebase and linting YAML files using ibiqlik/[email protected] with the specified configuration.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml $'jobs: { yaml-linting: { timeout-minutes: 4, runs-on: ubuntu-latest, permissions: { contents: read, pull-requests: read }, steps: [...] } }' .github/workflows/coding-standards.yml

Length of output: 425



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml 'yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: \'.\'\n\s+strict: true' .github/workflows/coding-standards.yml

Length of output: 93



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml 'yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: \'.\'\n\s+strict: true' .github/workflows/coding-standards.yml

Length of output: 93



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml 'yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: \'.\'\n\s+strict: true' .github/workflows/coding-standards.yml

Length of output: 93



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml "yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: \'.\'\n\s+strict: true" .github/workflows/coding-standards.yml

Length of output: 1211



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration.
rg --type yaml "yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: '.'\n\s+strict: true" .github/workflows/coding-standards.yml

Length of output: 622



Script:

#!/bin/bash
# Description: Verify the YAML linting job configuration.

# Test: Search for the YAML linting job configuration with multiline mode enabled.
rg --multiline --type yaml "yaml-linting:\n\s+timeout-minutes: 4\n\s+runs-on: ubuntu-latest\n\s+permissions:\n\s+contents: read\n\s+pull-requests: read\n\s+steps:\n\s+- name: 📦 Check out the codebase\n\s+uses: actions/[email protected]\n\s+- name: 🧐 Lint YAML files\n\s+uses: ibiqlik/[email protected]\n\s+with:\n\s+config_file: .github/.yamllint.yaml\n\s+file_or_dir: '.'\n\s+strict: true" .github/workflows/coding-standards.yml

Length of output: 850

@lotyp lotyp merged commit 3f64109 into master May 26, 2024
1 of 2 checks passed
@lotyp lotyp deleted the feat/infra-dx branch May 26, 2024 11:41
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 8e99911 and 4446383.
Files selected for processing (24)
  • .github/workflows/coding-standards.yml (1 hunks)
  • Makefile (1 hunks)
  • src/Bridge/Laravel/Console/Commands/Database/ListCommand.php (1 hunks)
  • src/Bridge/Laravel/Console/Commands/Database/TableCommand.php (1 hunks)
  • src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php (1 hunks)
  • src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php (1 hunks)
  • src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php (1 hunks)
  • src/Bridge/Laravel/Providers/CycleServiceProvider.php (1 hunks)
  • src/Bridge/Laravel/Providers/Registrator.php (1 hunks)
  • src/Bridge/Laravel/Rules/Exists.php (1 hunks)
  • src/Bridge/Laravel/Rules/Unique.php (1 hunks)
  • src/Bridge/Telescope/Events/Database/QueryExecuted.php (1 hunks)
  • src/Bridge/Telescope/TelescopeLogger.php (1 hunks)
  • src/Bridge/Telescope/Watchers/QueryWatcher.php (1 hunks)
  • src/Contracts/GeneratorLoader.php (1 hunks)
  • src/Schema/Compiler.php (2 hunks)
  • src/Schema/Generators/GeneratorQueue.php (1 hunks)
  • src/Testing/Constraints/HasInDatabase.php (1 hunks)
  • src/Testing/Constraints/NotSoftDeletedInDatabase.php (1 hunks)
  • src/Testing/Constraints/SoftDeletedInDatabase.php (1 hunks)
  • tests/app/Entities/Footprint.php (2 hunks)
  • tests/app/Entities/Signature.php (2 hunks)
  • tests/app/Entities/UserId.php (2 hunks)
  • tests/src/Bridge/Laravel/LoggerFactoryTest.php (1 hunks)
Files skipped from review due to trivial changes (9)
  • Makefile
  • src/Bridge/Laravel/Console/Commands/Database/ListCommand.php
  • src/Bridge/Laravel/Providers/CycleServiceProvider.php
  • src/Bridge/Telescope/Watchers/QueryWatcher.php
  • src/Contracts/GeneratorLoader.php
  • src/Schema/Generators/GeneratorQueue.php
  • tests/app/Entities/Footprint.php
  • tests/app/Entities/Signature.php
  • tests/src/Bridge/Laravel/LoggerFactoryTest.php
Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/coding-standards.yml
Additional comments not posted (21)
src/Bridge/Laravel/Providers/Registrator.php (7)

10-10: LGTM! The constant CFG_KEY_DATABASE is clearly defined.


12-12: LGTM! The constant CFG_KEY_TOKENIZER is clearly defined.


14-14: LGTM! The constant CFG_KEY_ATTRIBUTES is clearly defined.


16-16: LGTM! The constant CFG_KEY_MIGRATIONS is clearly defined.


18-18: LGTM! The constant CFG_KEY_SCHEMA is clearly defined.


20-20: LGTM! The constant CFG_KEY_WARMUP is clearly defined.


22-22: LGTM! The constant CFG_KEY_RELATIONS is clearly defined.

src/Bridge/Telescope/Events/Database/QueryExecuted.php (1)

16-16: LGTM! The conditional assignment to $driver ensures it is prefixed correctly or defaults to 'CycleORM'.

tests/app/Entities/UserId.php (1)

14-17: LGTM! The constructor is correctly defined as private, ensuring controlled instantiation through the static methods.

src/Bridge/Laravel/Rules/Unique.php (1)

34-34: LGTM! The updated comparison logic correctly triggers the failure message when a duplicate is found.

src/Bridge/Laravel/Rules/Exists.php (1)

34-34: LGTM! The updated comparison logic correctly triggers the failure message when the value does not exist.

src/Schema/Compiler.php (2)

20-22: LGTM! The constructor correctly initializes the schema property with a readonly modifier, ensuring immutability.


37-37: LGTM! The isEmpty method now correctly checks for multiple conditions to determine if the schema is empty.

src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php (1)

36-36: The change in the loop condition improves readability by using a more conventional comparison order. Ensure all related logic correctly interprets this change.

src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php (1)

19-19: The addition of the PENDING constant is a good practice for maintainability and clarity in displaying the status of migrations.

src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php (1)

35-35: The change in the loop condition improves readability by using a more conventional comparison order. Ensure all related logic correctly interprets this change.

src/Testing/Constraints/HasInDatabase.php (1)

40-40: The change in the comparison logic is a minor improvement in readability and does not affect the functionality.

src/Testing/Constraints/SoftDeletedInDatabase.php (1)

45-45: The change in the comparison logic is a minor improvement in readability and does not affect the functionality.

src/Testing/Constraints/NotSoftDeletedInDatabase.php (1)

45-45: The change in the comparison logic is a minor improvement in readability and does not affect the functionality.

src/Bridge/Telescope/TelescopeLogger.php (1)

24-24: Refined conditional check to trigger event only when log level is 'info' and 'elapsed' context is set.

src/Bridge/Laravel/Console/Commands/Database/TableCommand.php (1)

229-229: Refined conditional check to append type information specifically for 'decimal' abstract type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation type: enhancement For features and enhancements (feat) type: maintenance For maintenance, refactor and testing (perf, chore, style, revert, refactor, test, build, ci)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant