Skip to content

[#3328] Failed linting on debug calls left in custom code. - #3335

Merged
AlexSkrypnyk merged 5 commits into
mainfrom
feature/3328-lint-debug-calls
Nov 15, 2026
Merged

AlexSkrypnyk merged 5 commits into
mainfrom
feature/3328-lint-debug-calls

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Closes #3328

Summary

ahoy lint-be now fails with an error on var_dump(), print_r() and dump(), and on the Devel helpers (dpm(), dsm(), kint(), ddm() and the rest), anywhere PHPCS scans: custom modules and themes, web/sites/default, tests and scripts. ahoy lint-fe fails on debugger in custom module and theme JS, next to the existing no-console rule. The same rules apply to the .vortex/installer and .vortex/tests PHPCS configs and to the docs site's ESLint config.

Drupal.Functions.DiscouragedFunctions, part of the Drupal standard, already listed the Devel helpers, but it reports them as warnings and has no entry for plain PHP or Symfony debug output, so a var_dump() left in a custom module passed lint. no-debugger was only on through js.configs.recommended, and the docs site's ESLint config had neither rule.

Each phpcs.xml sets error to true on Drupal.Functions.DiscouragedFunctions and extends its forbiddenFunctions list with extend="true", so the 23 upstream entries stay and 3 are added. That also makes eval() and fnmatch() errors, and no linted path calls either. Method calls such as File::dump() are still ignored. Contrib and core aren't scanned, because the PHPCS <file> list and the ESLint targets never included them. The docs site allows console.warn() and console.error() so its player can still report load failures.

Before / After

BEFORE                                         AFTER
──────                                         ─────
var_dump($x) in web/modules/custom             var_dump($x) in web/modules/custom
  └─ not in any list ── lint passes              └─ ERROR  DiscouragedFunctions.Found

dpm($x) in web/modules/custom                  dpm($x) in web/modules/custom
  └─ WARNING  DiscouragedFunctions               └─ ERROR  DiscouragedFunctions.Found
     .Discouraged

debugger; in custom JS                         debugger; in custom JS
  └─ error via js.configs.recommended            └─ error  no-debugger (stated in config)

.vortex/installer, .vortex/tests               .vortex/installer, .vortex/tests
  └─ Devel helpers warn, var_dump passes         └─ same ERROR rule as the template

.vortex/docs ESLint                            .vortex/docs ESLint
  └─ no no-console, no no-debugger               └─ no-console (warn/error allowed)
                                                    no-debugger

Changes

PHPCS

  • phpcs.xml, .vortex/installer/phpcs.xml and .vortex/tests/phpcs.xml configure Drupal.Functions.DiscouragedFunctions with error set to true and add var_dump, print_r and dump to its forbiddenFunctions list.
  • The root phpcs.xml now reads in this order: description, <arg> and <config> entries, <file> targets and global <exclude-pattern>s, then rules, with Drupal.Functions.DiscouragedFunctions last. The move changes no entry.
  • AssertTrait::assertArrayContainsString() and EnvironmentSettingsTest build their failure messages with var_export($x, TRUE) instead of print_r($x, TRUE).

ESLint

  • The root and theme eslint.config.mjs files set no-debugger to error next to no-console.
  • .vortex/docs/eslint.config.mjs adds no-console (allowing warn and error) and no-debugger.

Functional tests (AhoyWorkflowTest)

  • subtestAhoyLintBeDebugCalls() adds debug calls to sw_base.deploy.php and star_wars.theme and asserts that ahoy lint-be fails with Drupal.Functions.DiscouragedFunctions.Found errors for the 3 added functions and for dpm() and kint() from the upstream list, and that nothing is reported as .Discouraged. A second substep puts var_dump() in a contrib module and in web/core and asserts that phpcs passes.
  • subtestAhoyLintFeDebugCalls() adds console.log() and debugger to a custom module JS file, then to a custom theme JS file, and asserts that ahoy lint-fe fails with no-console and no-debugger each time.

Docs

  • phpcs.mdx lists Drupal.Functions.DiscouragedFunctions with its error level and added functions, and shows how to forbid another function.
  • eslint.mdx adds no-debugger to the rules table. cspell.json accepts kint.

Fixtures

  • Installer snapshots regenerated for the changed template files.

@AlexSkrypnyk AlexSkrypnyk added the A1 Board worker 1 label Nov 15, 2026
@github-project-automation github-project-automation Bot moved this to BACKLOG in Vortex 1.x Nov 15, 2026
@AlexSkrypnyk AlexSkrypnyk added this to the 1.43.0 milestone Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

PHP and JavaScript lint configurations reject selected debug calls. Ahoy workflow tests check the rules against custom module and theme code. Documentation describes the rules, and two test failure messages replace print_r with var_export.

Changes: Debug-call lint enforcement

Layer / File(s) Summary
Configure debug-call lint rules
.vortex/installer/phpcs.xml, .vortex/tests/phpcs.xml, phpcs.xml, eslint.config.mjs, .vortex/docs/eslint.config.mjs, web/themes/custom/your_site_theme/eslint.config.mjs, .vortex/docs/content/development/code-quality/*, .vortex/docs/cspell.json
PHPCS treats var_dump, print_r, and dump as errors. The root PHPCS configuration also updates scan settings and exclusions. ESLint rejects debugger statements; the .vortex ESLint configuration also rejects console calls other than console.warn and console.error. Documentation describes the rules and how to extend the PHPCS forbidden-function list.
Exercise lint rules in Ahoy workflow
.vortex/tests/phpunit/Functional/AhoyWorkflowTest.php, .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait.php, tests/phpunit/Drupal/EnvironmentSettingsTest.php, web/modules/custom/ys_base/tests/src/Traits/AssertTrait.php
The workflow checks that backend lint rejects selected debug calls in custom PHP files and frontend lint rejects console.log and debugger in custom JavaScript files. Two test failure messages use var_export instead of print_r; their assertions remain unchanged.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Low

Merge Risk: Minimal · up to dd496

This change adds lint rules that reject debug calls in custom code, with tests and docs. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Out of Scope Changes check Inconclusive Changes that connect to #3328 or support it:

- phpcs.xml files (root, .vortex/installer, .vortex/tests): the debug-function rule and forbiddenFunctions entries.
- eslint.config.mjs files (root and th…
Confirm against the merge base (4f5cc6e) whether the root phpcs.xml settings for PHP-extension scanning, the sp report, parallel processes, PHP 8.4 compatibility and the build, font, image, node_modules and minified exclusions already exis…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the core change: failing lint on debug calls left in custom code. The changeset adds PHPCS and ESLint rules that flag debug calls in custom code, and adds tests for them. The title mat…
Linked Issues check Passed Issue #3328 has four coding acceptance criteria. The PR addresses each one.

1. [#3328] PHP debug calls fail lint in custom code. The PR sets Drupal.Functions.DiscouragedFunctions to error in phpcs.xm…
Full details: Title check

Explanation

The title names the core change: failing lint on debug calls left in custom code. The changeset adds PHPCS and ESLint rules that flag debug calls in custom code, and adds tests for them. The title matches the main change, so it passes. The title does not mention the specific tools, but that detail is not required.

Full details: Linked Issues check

Explanation

Issue #3328 has four coding acceptance criteria. The PR addresses each one.

  1. [#3328] PHP debug calls fail lint in custom code. The PR sets Drupal.Functions.DiscouragedFunctions to error in phpcs.xml, .vortex/installer/phpcs.xml and .vortex/tests/phpcs.xml. It adds var_dump, print_r and dump to forbiddenFunctions. The upstream Devel helpers (dpm, dsm, kint, ddm) are reported as errors. AhoyWorkflowTest::subtestAhoyLintBeDebugCalls asserts these failures.
  2. [#3328] console.log and debugger fail lint in custom JS. The root and theme eslint.config.mjs files set no-debugger to error beside the existing no-console rule. subtestAhoyLintFeDebugCalls asserts both failures in a custom module and a custom theme.
  3. [#3328] Contrib and core are not scanned. The PHPCS file list and ESLint targets exclude them. The test places var_dump in a contrib module and in web/core and asserts that phpcs passes.
  4. [#3328] Snapshots are updated. Installer snapshots are regenerated for the changed template files.

The issue suggests Generic.PHP.ForbiddenFunctions. The PR uses Drupal.Functions.DiscouragedFunctions with extend="true". The issue lists these as details. Its acceptance criteria are behavioral, and the PR meets them. The PR applies the rule to all PHPCS-scanned paths, which include custom code plus tests, scripts and web/sites/default. None of these are contrib or core.

Limits: no repository inspection was possible in this review. The conclusions rely on the PR description and the change summary. The XML and config contents were not read directly.

Full details: Out of Scope Changes check

Explanation

Changes that connect to #3328 or support it:

  • phpcs.xml files (root, .vortex/installer, .vortex/tests): the debug-function rule and forbiddenFunctions entries.
  • eslint.config.mjs files (root and theme): no-debugger beside no-console.
  • AssertTrait::assertArrayContainsString() and EnvironmentSettingsTest: print_r() replaced with var_export() so the test code passes the new rule.
  • AhoyWorkflowTest and SubtestAhoyTrait: tests for the new lint behaviour.
  • Docs (phpcs.mdx, eslint.mdx), cspell.json (kint), and the .vortex/docs ESLint config: documentation and rules for the new behaviour.
  • Installer snapshots: required by acceptance criterion 4.

Unresolved: the change summary of root phpcs.xml (+29/-17) also describes non-debug settings. These are a PHP-extension scan list, the sp report, 10 parallel processes, PHP 8.4 compatibility, and exclusions for theme build, font, image, node_modules and minified assets. The PR description does not mention them. The summary does not state whether they are new in this PR or already present at the merge base. Those settings do not implement #3328, so they would be out of scope if this PR added them. The commit message describes only a reorder of phpcs.xml. No repository inspection was possible, so this could not be resolved.

Resolution

Confirm against the merge base (4f5cc6e) whether the root phpcs.xml settings for PHP-extension scanning, the sp report, parallel processes, PHP 8.4 compatibility and the build, font, image, node_modules and minified exclusions already existed. If this PR added them, either justify them in the PR description with a link to a related issue or remove them from this PR.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fbc350f and dd4961e.

Files ignored due to path filters: 14

  • .vortex/installer/tests/Fixtures/handler_process/_baseline/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_acquia/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/theme_claro/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/theme_olivero/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/theme_stark/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_behat/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_no_theme/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_no_theme/phpcs.xml is excluded by !.vortex/installer/tests/Fixtures/**
Files selected for processing: 1

  • phpcs.xml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6afa32d016ae5988a27b7556--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@codecov

codecov Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.65%. Comparing base (4f5cc6e) to head (dd4961e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3335   +/-   ##
=======================================
  Coverage   92.65%   92.65%           
=======================================
  Files         114      114           
  Lines        5091     5091           
  Branches       49       49           
=======================================
  Hits         4717     4717           
  Misses        374      374           

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (233/233)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (233/233)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Nov 15, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit 4758c31 into main Nov 15, 2026
51 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/3328-lint-debug-calls branch November 15, 2026 23:08
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A1 Board worker 1 Needs review Pull request needs a review from assigned developers

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Fail linting on debug calls left in custom code

1 participant