Skip to content

Keep the lint files Codacy reads to packages Codacy installs - #166

Merged
PDowney merged 4 commits into
mainfrom
codacy-config-files
Nov 25, 2026
Merged

PDowney merged 4 commits into
mainfrom
codacy-config-files

Conversation

@PDowney

@PDowney PDowney commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Codacy reads phpcs.xml, phpmd.xml, eslint.config.mjs and .stylelintrc.json (the "Configuration file" setting is on for each), but it installs no WordPress coding standards, no PHPCSExtra, no WordPress ESLint or Stylelint packages, and only PHPMD 2. Codacy's analysis log for deeb438 shows all four tools failing:

  • PHPCS: Referenced sniff "WordPress-Extra" does not exist
  • ESLint: Cannot find package '@wordpress/eslint-plugin'
  • Stylelint: Could not find "@wordpress/stylelint-config"
  • PHPMD: crashes on LongMethodName, a PHPMD 3 rule

So Codacy checked none of the plugin's PHP, JavaScript or CSS with those tools.

Each tool now has a file Codacy can run and a full file that composer, npm and CI run. The plugin's own checks are unchanged.

Tool Codacy reads Composer, npm and CI run
PHPCS phpcs.xml: the 95 rules from PHPCS's own standards and VariableAnalysis that the WordPress standards apply, with their exact settings and the 4-column tab width, plus PHPCompatibilityWP phpcs-wordpress.xml (the former phpcs.xml)
Stylelint .stylelintrc.json: the 60 plain Stylelint rules of the WordPress config stylelint-wordpress.json (the former .stylelintrc.json)
ESLint eslint.config.mjs: the project's modern-JavaScript rules eslint.wordpress.config.mjs: the WordPress set, the same rules, and the browser-support check (compat reads the browser list from package.json, which extends @wordpress/browserslist-config, also missing in Codacy). The resolved configuration is identical
PHPMD phpmd.xml phpmd.xml plus phpmd-extra.xml (LongMethodName, 50 characters)

.github/scripts/codacy-configs.py regenerates the rules in phpcs.xml and .stylelintrc.json from the full files. It reads PHPCS's loaded ruleset through .github/scripts/phpcs-ruleset-dump.php, a report class. The "Run PHPCS" and "Run Stylelint" steps fail when either copy is out of date, for example after a Dependabot update to the WordPress standards.

Codacy still can't run any WordPress-specific rule; those keep running only in CI.

Testing

  • On this branch's first commit, Codacy's log already shows PHP_CodeSniffer, PHP Mess Detector and Stylelint as success; ESLint9 then failed on the browser list, fixed in the second commit.
  • Generated phpcs.xml: no findings on the plugin. Its loaded ruleset matches phpcs-wordpress.xml for all 212 rules from Codacy-installed standards (same sniffs, properties, severities and types). Every listed sniff is in Codacy's PHPCS catalog. A test file triggers its indentation, spacing, docblock and unused-variable rules.
  • eslint --print-config output for js/admin.js, tests/js/admin.test.mjs and tests/js/helpers.mjs is byte-identical before and after with the full config. Both configs lint clean, and every rule in eslint.config.mjs is in Codacy's ESLint 9 catalog.
  • Both Stylelint configs lint clean, and the generated one flags a test file.
  • composer check-all (PHPCS, PHPMD, Psalm, PHPStan, Rector, 230 PHPUnit tests), npm run lint:js, lint:css, lint:md, npm test (21), Ruff, strict mypy, Bandit through Prospector, yamllint, actionlint, zizmor (no change) and gitleaks pass. A test file confirms LongMethodName fires through phpmd-extra.xml.

After merge, the Codacy log for the merge commit should show PHP_CodeSniffer, PHP Mess Detector, ESLint9 and Stylelint as success.

Also in this PR: the checks of Codacy's "WordPress" standard

Codacy's "WordPress" coding standard turns on checks that the plugin's own configuration didn't run. Each one that fits the WordPress style and passes on the plugin now lives in a configuration file that both CI and Codacy read. A pull request from any machine gets the same checks before Codacy sees it.

Tool File (CI and Codacy) Added
PHPCS phpcs-wordpress.xml (CI), copied into phpcs.xml (Codacy) 24 checks from PHPCS's own standards and Slevomat (slevomat/coding-standard 8.22.1, the newest release for PHPCS 3). The checks that contradict the WordPress style, such as Yoda conditions, tab indentation and no spaces inside parentheses, are listed in the file as left out, each with its reason.
ESLint eslint.config.mjs (Codacy, and included by eslint.wordpress.config.mjs) 85 rules (70 core, 15 unicorn), with Codacy's options. Deprecated rules and seven that conflict with this code (no-ternary, no-continue, test-only await patterns) are listed in the file as left out.
Stylelint stylelint-wordpress.json (CI), copied into .stylelintrc.json (Codacy) 21 rules with Codacy's settings
Biome new biome.json Codacy's 232 lint rules; npm run lint:biome runs Biome 2.5.14, the version Codacy uses
Pylint new .pylintrc Codacy's 95 checks
Bandit new bandit.yml every test (Bandit 1.9.4, as Codacy)
  • The lint job gains "Run Pylint", "Run Bandit" and "Run Biome", with entries in its step results and failure stage.
  • Pylint and Bandit are pinned in .github/lint-requirements.txt, and Biome in package.json.
  • codacy-configs.py now copies Slevomat rules into phpcs.xml, because Codacy installs Slevomat.
  • PHPMD and markdownlint already ran every check Codacy turns on, so they're unchanged. Their remaining differences (thresholds measured on this code, exclusions that conflict with WordPress naming) are deliberate and explained in the files.

Testing

  • phpcs-wordpress.xml and the regenerated phpcs.xml report nothing; phpcs.xml matches the full ruleset for every rule from a Codacy-installed standard.
  • Biome, Pylint (10.00/10) and Bandit report nothing. Each Codacy pattern was first run separately on all four plugins.
  • composer check-all (230 tests), markdownlint, Ruff, strict mypy, yamllint, actionlint, zizmor (no change) and gitleaks pass.

🤖 Generated with Claude Code

Codacy reads phpcs.xml, phpmd.xml, eslint.config.mjs, and
.stylelintrc.json, but it installs no WordPress coding standards, no
PHPCSExtra, no WordPress ESLint or Stylelint packages, and only PHPMD 2.
Every analysis failed for all four tools, so Codacy checked nothing.

Each tool now has a file Codacy can run and a full file that composer,
npm, and CI run, so the plugin's own checks are unchanged:

- PHPCS: phpcs-wordpress.xml is the former phpcs.xml. phpcs.xml holds the
  95 rules from PHPCS's own standards and VariableAnalysis that the
  WordPress standards apply, with their settings and the tab width,
  plus PHPCompatibilityWP.
- Stylelint: stylelint-wordpress.json is the former .stylelintrc.json.
  .stylelintrc.json holds its 60 plain Stylelint rules.
- ESLint: eslint.config.mjs exports the project's rules;
  eslint.wordpress.config.mjs puts the WordPress set between them, so
  the resolved configuration is unchanged.
- PHPMD: LongMethodName, a PHPMD 3 rule, moves to phpmd-extra.xml;
  composer and CI pass both files.

.github/scripts/codacy-configs.py regenerates phpcs.xml's rules and
.stylelintrc.json from the full files, and CI fails when they are out
of date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies security automation testing labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to EngineScript Site Exporter!

Before we review:

  • Have you tested your changes with WordPress 7.0+?
  • Are your changes compatible with PHP 8.3+?
  • Have you followed WordPress coding standards?
  • Did you update the CHANGELOG.md if needed?

Security Reminder
This plugin creates site export archives, so please ensure:

  • All user input is properly sanitized
  • All output is properly escaped
  • No security vulnerabilities are introduced

We'll review your PR soon.

@codacy-production

codacy-production Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 44 complexity · 0 duplication

Metric Results
Complexity 44
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3fca069) 2612 534 20.44%
Head commit (18ab931) 2612 (+0) 534 (+0) 20.44% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#166) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

PDowney and others added 2 commits November 25, 2026 02:42
Codacy's ESLint loaded eslint.config.mjs but stopped on
eslint-plugin-compat, which reads the browser list from package.json,
and that list extends @wordpress/browserslist-config, which Codacy does
not install. The compat block moves to eslint.wordpress.config.mjs; it
covers js/ only, so the resolved configuration stays the same.

The generator script's subprocess call and its XML-escaping import get
nosemgrep notes beside their nosec notes: Codacy's Opengrep reported the
same two false positives as Bandit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codacy's "WordPress" coding standard turns on checks that the plugin's
own configuration did not run. Each one that fits the WordPress style
and passes on the plugin is now in a configuration file that both CI and
Codacy read, so a pull request gets the same checks before Codacy runs:

- PHPCS: 24 checks join phpcs-wordpress.xml (PHPCS's own standards and
  Slevomat, now a dev dependency); codacy-configs.py copies Slevomat
  into phpcs.xml.
- ESLint: 85 rules (70 core, 15 unicorn) join eslint.config.mjs, which
  Codacy reads and the full configuration includes.
- Stylelint: 21 rules join stylelint-wordpress.json; codacy-configs.py
  copies them into .stylelintrc.json.
- Biome: biome.json turns on Codacy's 232 lint rules; npm run lint:biome
  runs it with Biome 2.5.14, the version Codacy uses.
- Pylint: .pylintrc turns on Codacy's 95 checks.
- Bandit: bandit.yml runs every test.

Checks that contradict the WordPress style or this code (such as Yoda
conditions, tab indentation, or no-ternary) and deprecated ESLint rules
are listed in the files as left out, each with its reason. The lint job
runs Pylint, Bandit, and Biome, which lint-requirements.txt and
package.json pin. PHPMD and markdownlint already ran every check Codacy
turns on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PDowney
PDowney merged commit 7c2ecb2 into main Nov 25, 2026
29 checks passed
@github-actions
github-actions Bot deleted the codacy-config-files branch November 25, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant