8000 Fixed more coding standards and removed PHPMD. by AlexSkrypnyk · Pull Request #373 · drevops/behat-steps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed more coding standards and removed PHPMD. #373

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

Merged
merged 1 commit into from
Apr 30, 2025

Conversation

AlexSkrypnyk
Copy link
Member
@AlexSkrypnyk AlexSkrypnyk commented Apr 30, 2025

Summary by CodeRabbit

  • Chores

    • Removed PHP Mess Detector (PHPMD) configuration and related suppression annotations.
    • Updated linting commands and development dependencies to exclude PHPMD.
    • Adjusted file and directory export settings for distribution archives.
    • Updated file exclusion lists for build and sync operations.
  • Style

    • Improved variable naming consistency in several methods.
    • Updated step definition annotations for clarity and consistency.
  • Documentation

    • Enhanced PHPDoc comments for better method summaries and clarity.
  • Refactor

    • Renamed a method in the WaitTrait for improved naming consistency.

Copy link
coderabbitai bot commented Apr 30, 2025

Walkthrough

This update removes all integration and configuration for PHP Mess Detector (PHPMD) from the project. The PHPMD configuration file (phpmd.xml) is deleted, related suppression annotations are stripped from code and docblocks, and PHPMD commands are eliminated from the .ahoy.yml linting tasks. The PHPMD development dependency is also removed from Composer. Additional changes include minor variable renaming for consistency, adjustments to step definitions, and improvements to PHPDoc summaries for clarity. The .gitattributes and .rsync-exclude files are updated to reflect the removal of PHPMD-related files.

Changes

File(s) Change Summary
.ahoy.yml, tests/behat/fixtures/d10/composer.json, phpmd.xml Removed PHPMD integration: deleted config, removed PHPMD from lint commands and Composer dev dependencies.
src/BigPipeTrait.php, src/ParagraphsTrait.php, src/SearchApiTrait.php,
src/KeyboardTrait.php, src/MediaTrait.php, src/BlockContentTrait.php, src/BlockTrait.php, src/FileTrait.php, tests/behat/bootstrap/FeatureContextTrait.php
Removed PHPMD suppression annotations from docblocks and traits; added or updated PHPDoc summaries where relevant.
src/ContentTrait.php, src/FileTrait.php, src/MediaTrait.php Renamed loop variable from $nodeHash to $node_hash for naming consistency.
src/CookieTrait.php, steps.md Updated step definition annotation for cookie existence to use explicit phrasing.
src/WaitTrait.php Renamed method waitSeconds to waitWaitForSeconds for clarity.
.gitattributes Updated export-ignore list: reordered, added new entries, removed PHPMD references.
tests/behat/fixtures/d10/.rsync-exclude Removed phpmd.xml from rsync exclude list.

Poem

A whisk of the paw, PHPMD’s gone,
No more rules to trip upon!
Traits now lighter, code more bright,
Docblocks tidy, step names right.
Composer’s lighter, builds are swift—
In this spring-cleaned code, we rabbits lift!

((\
( -.-)
o_(")(")


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 62023e1 and 1ca34f7.

📒 Files selected for processing (18)
  • .ahoy.yml (1 hunks)
  • .gitattributes (1 hunks)
  • phpmd.xml (0 hunks)
  • src/BigPipeTrait.php (0 hunks)
  • src/BlockContentTrait.php (0 hunks)
  • src/BlockTrait.php (0 hunks)
  • src/ContentTrait.php (1 hunks)
  • src/CookieTrait.php (1 hunks)
  • src/FileTrait.php (1 hunks)
  • src/KeyboardTrait.php (0 hunks)
  • src/MediaTrait.php (1 hunks)
  • src/ParagraphsTrait.php (0 hunks)
  • src/SearchApiTrait.php (0 hunks)
  • src/WaitTrait.php (1 hunks)
  • steps.md (1 hunks)
  • tests/behat/bootstrap/FeatureContextTrait.php (12 hunks)
  • tests/behat/fixtures/d10/.rsync-exclude (0 hunks)
  • tests/behat/fixtures/d10/composer.json (0 hunks)
💤 Files with no reviewable changes (9)
  • src/ParagraphsTrait.php
  • src/BigPipeTrait.php
  • src/KeyboardTrait.php
  • tests/behat/fixtures/d10/composer.json
  • src/BlockContentTrait.php
  • tests/behat/fixtures/d10/.rsync-exclude
  • src/BlockTrait.php
  • phpmd.xml
  • src/SearchApiTrait.php
✅ Files skipped from review due to trivial changes (2)
  • steps.md
  • .ahoy.yml
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/ContentTrait.php
  • src/FileTrait.php
  • src/CookieTrait.php
  • src/WaitTrait.php
  • .gitattributes
  • src/MediaTrait.php
  • tests/behat/bootstrap/FeatureContextTrait.php

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/fix-definitions branch 2 times, most recently from b1faed4 to 834e551 Compare April 30, 2025 08:11
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

🔭 Outside diff range comments (1)
tests/behat/bootstrap/BehatCliTrait.php (1)

172-178: ⚠️ Potential issue

Stray quote breaks generated Gherkin feature

behatCliWriteScenarioSteps() writes Feature: Stub feature'; (note the extra ').
When this stub is parsed by Behat it yields “unexpected string” syntax errors and the scenario won’t run.

-Feature: Stub feature';
+Feature: Stub feature

Please remove the stray quote.

🧹 Nitpick comments (4)
src/WaitTrait.php (1)

23-23: Method name changed to improve clarity.

The method was renamed from waitSeconds to waitWaitForSeconds to better align with its functionality. However, the method name now contains a redundant "Wait" term.

Consider renaming to just waitForSeconds to avoid the repetition while maintaining clarity about the method's purpose.

-public function waitWaitForSeconds(int|string $seconds): void {
+public function waitForSeconds(int|string $seconds): void {
tests/behat/bootstrap/FeatureContextTrait.php (1)

3-10: Doc block closing tag is malformed

There is an extra space before the terminating */, leaving the file-level doc-block as * */.
Some tools (e.g. phpcs, PhpStorm inspections) flag this as an “unterminated comment” and may ignore the entire header.

- *  */
+ */
tests/behat/bootstrap/BehatCliTrait.php (1)

315-332: Consider adding an explicit return type

behatCliCopyFixtures() performs copying but does not declare a return type.
For consistency with other methods in the trait (all of which declare : void) and to leverage strict-types, add it here as well:

-protected function behatCliCopyFixtures() {
+protected function behatCliCopyFixtures(): void {

This tiny change improves static-analysis coverage without altering behaviour.

tests/behat/bootstrap/BehatCliContext.php (1)

3-24: Duplicate file-level doc-blocks

Two consecutive @file headers (lines 3-7 and 10-24) describe the same purpose.
Keeping only one avoids needless noise and prevents tooling from reporting “duplicate comment”/“missing short description” issues.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b9802e and 834e551.

📒 Files selected for processing (20)
  • .ahoy.yml (1 hunks)
  • .gitattributes (1 hunks)
  • phpmd.xml (0 hunks)
  • src/BigPipeTrait.php (0 hunks)
  • src/BlockContentTrait.php (0 hunks)
  • src/BlockTrait.php (0 hunks)
  • src/ContentTrait.php (1 hunks)
  • src/CookieTrait.php (1 hunks)
  • src/FileTrait.php (1 hunks)
  • src/KeyboardTrait.php (0 hunks)
  • src/MediaTrait.php (1 hunks)
  • src/ParagraphsTrait.php (0 hunks)
  • src/SearchApiTrait.php (0 hunks)
  • src/WaitTrait.php (1 hunks)
  • steps.md (1 hunks)
  • tests/behat/bootstrap/BehatCliContext.php (3 hunks)
  • tests/behat/bootstrap/BehatCliTrait.php (8 hunks)
  • tests/behat/bootstrap/FeatureContextTrait.php (13 hunks)
  • tests/behat/fixtures/d10/.rsync-exclude (0 hunks)
  • tests/behat/fixtures/d10/composer.json (0 hunks)
💤 Files with no reviewable changes (9)
  • src/SearchApiTrait.php
  • src/BlockTrait.php
  • src/ParagraphsTrait.php
  • tests/behat/fixtures/d10/.rsync-exclude
  • tests/behat/fixtures/d10/composer.json
  • phpmd.xml
  • src/KeyboardTrait.php
  • src/BlockContentTrait.php
  • src/BigPipeTrait.php
🔇 Additional comments (8)
src/ContentTrait.php (1)

51-52: Great variable renaming

Changing $nodeHash to $node_hash improves consistency with Drupal coding standards, which prefer snake_case for local variables.

.gitattributes (1)

2-20: Export ignore list updates look good

The updates to the export-ignore list are well organized:

  • Added new configuration files like .docker, .github, docs.php, etc.
  • Removed phpmd.xml which aligns with removing PHP Mess Detector
  • Improved organization of the list entries

These changes ensure appropriate files are excluded from distribution packages.

src/FileTrait.php (1)

68-69: Good variable naming standardization

Renaming $nodeHash to $node_hash improves consistency with Drupal coding standards, which prefer snake_case for local variables.

src/MediaTrait.php (1)

72-73: Consistent variable naming improvement

Changing $nodeHash to $node_hash maintains coding standard consistency across all traits, improving code readability and adherence to Drupal's preferred snake_case naming convention for local variables.

.ahoy.yml (2)

113-113: Updated lint command to remove PHPMD.

The PHPMD configuration file (phpmd.xml) has been removed from the list of files being copied to the build directory for linting, aligning with the PR objective of removing PHPMD from the project's toolchain.


122-122: Updated lint-fix command to remove PHPMD.

Similarly, the phpmd.xml file has been removed from the configuration files copied during the lint-fix process, maintaining consistency with the removal of PHPMD from the project.

src/CookieTrait.php (1)

101-101: Standardized step definition format.

The annotation has been updated to remove the optional parentheses around "the", making the step definition more explicit and consistent with other step definitions.

steps.md (1)

335-335: Updated documentation to match code change.

The step definition in the documentation has been updated to match the annotation change in CookieTrait.php, ensuring consistency between code and documentation.

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/fix-definitions branch from 834e551 to 62023e1 Compare April 30, 2025 08:58
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: 3

🧹 Nitpick comments (2)
tests/behat/bootstrap/BehatCliContext.php (2)

3-8: Remove duplicated file-level DocBlock

The file contains two very similar @file DocBlocks (lines 3-8 and 10-24). Having duplicates makes automated tooling (e.g., API doc generators) choose one arbitrarily and confuses readers.

Please delete the first one (lines 3-8) or merge any missing details into the second to keep a single authoritative header.


17-18: Fix typo in comment

calssclass

Nit-level, but worth cleaning because this file is explicitly marked “DO NOT MODIFY … TO KEEP IT SYNCED WITH UPSTREAM!”.

- * Changes made to this calss:
+ * Changes made to this class:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 834e551 and 62023e1.

📒 Files selected for processing (19)
  • .ahoy.yml (1 hunks)
  • .gitattributes (1 hunks)
  • phpmd.xml (0 hunks)
  • src/BigPipeTrait.php (0 hunks)
  • src/BlockContentTrait.php (0 hunks)
  • src/BlockTrait.php (0 hunks)
  • src/ContentTrait.php (1 hunks)
  • src/CookieTrait.php (1 hunks)
  • src/FileTrait.php (1 hunks)
  • src/KeyboardTrait.php (0 hunks)
  • src/MediaTrait.php (1 hunks)
  • src/ParagraphsTrait.php (0 hunks)
  • src/SearchApiTrait.php (0 hunks)
  • src/WaitTrait.php (1 hunks)
  • steps.md (1 hunks)
  • tests/behat/bootstrap/BehatCliContext.php (3 hunks)
  • tests/behat/bootstrap/FeatureContextTrait.php (13 hunks)
  • tests/behat/fixtures/d10/.rsync-exclude (0 hunks)
  • tests/behat/fixtures/d10/composer.json (0 hunks)
💤 Files with no reviewable changes (9)
  • src/ParagraphsTrait.php
  • src/BigPipeTrait.php
  • src/KeyboardTrait.php
  • src/SearchApiTrait.php
  • tests/behat/fixtures/d10/composer.json
  • src/BlockContentTrait.php
  • src/BlockTrait.php
  • tests/behat/fixtures/d10/.rsync-exclude
  • phpmd.xml
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/WaitTrait.php
  • src/ContentTrait.php
  • src/MediaTrait.php
  • src/CookieTrait.php
  • src/FileTrait.php
  • .ahoy.yml
  • steps.md
  • .gitattributes
  • tests/behat/bootstrap/FeatureContextTrait.php

Comment on lines 71 to 74
* @var string
*/
private $answerString;

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Typed property $answerString is never initialised

declare(strict_types=1) + an uninitialised typed property triggers a fatal error on first access:

private string $answerString;   // uninitialised
...
if (!empty($this->answerString)) {   // Fatal Error

Initialise it to an empty string so iRunBehat() can safely access it before any interactive run.

-  private $answerString;
+  private string $answerString = '';

Comment on lines 158 to 166
public function aNoopFeature() {
$filename = 'features/bootstrap/FeatureContext.php';
$content = <<<'EOL'
Feature:
Scenario:
When this scenario executes
EOL;
$this->createFile($this->workingDir . '/' . $filename, $content);
}

/**
* Moves user to the specified path.
*
* @Given /^I am in the "([^"]*)" path$/
*
* @param string $path
*/
public function iAmInThePath($path)
{
$this->moveToNewPath($path);
$this->createFile($this->workingDir . '/' . $filename, $content);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

aNoopFeature() writes Gherkin to a .php file

The method description says “Creates a noop feature”, but it creates
features/bootstrap/FeatureContext.php and writes Gherkin text into it.
That will be interpreted as PHP by autoloaders and as a feature by none,
leading to bewildering failures.

Proposed fix: place the feature in features/noop.feature.

-    $filename = 'features/bootstrap/FeatureContext.php';
+    $filename = 'features/noop.feature';

Optionally move it under a features/ sub-directory of your choosing.

Comment on lines 258 to 265
public function iRunBehatInteractively($answerString, $argumentsString) {
$this->env['SHELL_INTERACTIVE'] = TRUE;

$this->answerString = $answerString;

$this->options = '--format-settings=\'{"timer": false}\'';
$this->iRunBehat($argumentsString);
}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Cast SHELL_INTERACTIVE to string before passing to Process

Symfony\Component\Process\Process::setEnv() expects string|null values.
Assigning a boolean (TRUE) will work today but emits a deprecation notice in Symfony 6 and becomes an InvalidArgumentException in Symfony 7.

-    $this->env['SHELL_INTERACTIVE'] = TRUE;
+    $this->env['SHELL_INTERACTIVE'] = '1';

🏁 Script executed:

#!/bin/bash
# Locate the iRunBehat method to see how $this->env is used, and search for setEnv calls
rg -n "function iRunBehat" -n tests/behat/bootstrap/BehatCliContext.php
rg -n "new Process" -n tests/behat/bootstrap/BehatCliContext.php
rg -n "setEnv" -n tests/behat/bootstrap/BehatCliContext.php

Length of output: 468


Cast SHELL_INTERACTIVE to string before passing to Process
Symfony’s Process::setEnv() only accepts string|null. Using a boolean now works but will trigger a deprecation in Symfony 6 and throw in Symfony 7.

Please update in tests/behat/bootstrap/BehatCliContext.php:

--- a/tests/behat/bootstrap/BehatCliContext.php
+++ b/tests/behat/bootstrap/BehatCliContext.php
@@ public function iRunBehatInteractively($answerString, $argumentsString) {
-    $this->env['SHELL_INTERACTIVE'] = TRUE;
+    $this->env['SHELL_INTERACTIVE'] = '1';

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/fix-definitions branch from 62023e1 to 1ca34f7 Compare April 30, 2025 09:58
Copy link
codecov bot commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.54%. Comparing base (8b9802e) to head (1ca34f7).
Report is 1 commits behind head on 3.x.

Additional details and impacted files
@@           Coverage Diff           @@
##              3.x     #373   +/-   ##
=======================================
  Coverage   81.54%   81.54%           
=======================================
  Files          31       31           
  Lines        1680     1680           
=======================================
  Hits         1370     1370           
  Misses        310      310           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlexSkrypnyk AlexSkrypnyk merged commit 11f906a into 3.x Apr 30, 2025
4 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/fix-definitions branch April 30, 2025 10:07
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.

1 participant
0