Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
# Codacy configuration
#
# With each tool's "Configuration file" setting on, Codacy reads phpcs.xml, phpmd.xml, and
# .markdownlint.json. Codacy installs no WordPress standards or packages, so those files hold only
# what it can run; CI runs the full configurations (phpcs-wordpress.xml, phpmd.xml with phpmd-extra.xml).
# See CONTRIBUTING.md.
# With each tool's "Configuration file" setting on, Codacy reads phpcs.xml, phpmd.xml,
# .markdownlint.json, biome.json, .pylintrc, and bandit.yml. Codacy installs no WordPress standards
# or packages, so those files hold only what it can run; CI runs the full configurations
# (phpcs-wordpress.xml, phpmd.xml with phpmd-extra.xml) and the same Biome, Pylint, and Bandit
# files. See CONTRIBUTING.md.

engines:
# Lizard reads the lock files as source code and reports their length.
Expand Down
2 changes: 2 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
/package.json
/package-lock.json
/phpcs.xml
/bandit.yml
/biome.json
/phpcs-wordpress.xml
/phpmd.xml
/phpmd-extra.xml
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
/package.json export-ignore
/package-lock.json export-ignore
/phpcs.xml export-ignore
/bandit.yml export-ignore
/.pylintrc export-ignore
/biome.json export-ignore
/phpcs-wordpress.xml export-ignore
/phpmd.xml export-ignore
/phpmd-extra.xml export-ignore
Expand Down
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ testing:
- any-glob-to-any-file: tests/**/*
- any-glob-to-any-file: phpunit.xml
- any-glob-to-any-file: phpcs.xml
- any-glob-to-any-file: bandit.yml
- any-glob-to-any-file: .pylintrc
- any-glob-to-any-file: biome.json
- any-glob-to-any-file: phpcs-wordpress.xml
- any-glob-to-any-file: phpmd.xml
- any-glob-to-any-file: phpmd-extra.xml
Expand Down
2 changes: 2 additions & 0 deletions .github/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Linters that the lint job of wp-compatibility-test.yml installs.
# Renovate keeps the versions current.
actionlint-py==1.7.12.25
bandit==1.9.4
mypy==2.4.1
pylint==4.1.4
ruff==0.17.5
yamllint==1.38.0
zizmor==1.32.0
12 changes: 11 additions & 1 deletion .github/scripts/codacy-configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@

# PHPCS standards that Codacy installs. PHPCompatibilityWP is referenced as a whole standard in
# phpcs.xml's hand-written part, so its sniffs are not listed one by one.
CODACY_PHPCS_STANDARDS = ("Generic", "PEAR", "PSR1", "PSR2", "PSR12", "Squiz", "Zend", "VariableAnalysis")
CODACY_PHPCS_STANDARDS = (
"Generic",
"PEAR",
"PSR1",
"PSR2",
"PSR12",
"Squiz",
"Zend",
"SlevomatCodingStandard",
"VariableAnalysis",
)
BEGIN = " <!-- BEGIN GENERATED RULES: python .github/scripts/codacy-configs.py phpcs -->"
END = " <!-- END GENERATED RULES -->"
# A message code (Standard.Category.Sniff.Code) has three dots; a sniff code has two.
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/wp-compatibility-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,17 @@ jobs:
# .mypy.ini names the files and sets the strict mode.
run: mypy

- name: Run Pylint
id: run_pylint
# .pylintrc turns on the checks Codacy's Pylint runs; Codacy reads the same file.
run: pylint --rcfile=.pylintrc .github/scripts/*.py

- name: Run Bandit
id: run_bandit
# bandit.yml runs every test; Codacy reads the same file. Bandit's default exclusions also
# match .github, so -x replaces them.
run: bandit --configfile bandit.yml -x node_modules .github/scripts/*.py

- name: Run markdownlint
id: run_markdownlint
run: |
Expand All @@ -1252,6 +1263,11 @@ jobs:
# A run that found no files must not pass.
grep -Eq '^Linting: [1-9][0-9]* file' "$RUNNER_TEMP/markdownlint.txt"

- name: Run Biome
id: run_biome
# biome.json turns on the lint rules Codacy's Biome runs; Codacy reads the same file.
run: npm run --silent lint:biome

- name: Preserve diagnostic summary
id: preserve_diagnostics
if: ${{ always() }}
Expand All @@ -1267,7 +1283,10 @@ jobs:
run_zizmor=${{ steps.run_zizmor.outcome }}
run_ruff=${{ steps.run_ruff.outcome }}
run_mypy=${{ steps.run_mypy.outcome }}
run_pylint=${{ steps.run_pylint.outcome }}
run_bandit=${{ steps.run_bandit.outcome }}
run_markdownlint=${{ steps.run_markdownlint.outcome }}
run_biome=${{ steps.run_biome.outcome }}
run: |
mkdir -p "$RUNNER_TEMP/es-optimizer-diagnostics"
printf '%s\n' "$STEP_RESULTS" > "$RUNNER_TEMP/es-optimizer-diagnostics/steps.txt"
Expand Down Expand Up @@ -1308,7 +1327,7 @@ jobs:
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FAILURE_STAGE: ${{ steps.checkout_code.outcome == 'failure' && 'checkout_code' || steps.setup_node.outcome == 'failure' && 'setup_node' || steps.install_npm_dependencies.outcome == 'failure' && 'install_npm_dependencies' || steps.install_python_linters.outcome == 'failure' && 'install_python_linters' || steps.run_yamllint.outcome == 'failure' && 'run_yamllint' || steps.run_actionlint.outcome == 'failure' && 'run_actionlint' || steps.run_zizmor.outcome == 'failure' && 'run_zizmor' || steps.run_ruff.outcome == 'failure' && 'run_ruff' || steps.run_mypy.outcome == 'failure' && 'run_mypy' || steps.run_markdownlint.outcome == 'failure' && 'run_markdownlint' || 'unknown_or_canceled' }}
FAILURE_STAGE: ${{ steps.checkout_code.outcome == 'failure' && 'checkout_code' || steps.setup_node.outcome == 'failure' && 'setup_node' || steps.install_npm_dependencies.outcome == 'failure' && 'install_npm_dependencies' || steps.install_python_linters.outcome == 'failure' && 'install_python_linters' || steps.run_yamllint.outcome == 'failure' && 'run_yamllint' || steps.run_actionlint.outcome == 'failure' && 'run_actionlint' || steps.run_zizmor.outcome == 'failure' && 'run_zizmor' || steps.run_ruff.outcome == 'failure' && 'run_ruff' || steps.run_mypy.outcome == 'failure' && 'run_mypy' || steps.run_pylint.outcome == 'failure' && 'run_pylint' || steps.run_bandit.outcome == 'failure' && 'run_bandit' || steps.run_markdownlint.outcome == 'failure' && 'run_markdownlint' || steps.run_biome.outcome == 'failure' && 'run_biome' || 'unknown_or_canceled' }}
NODE_VERSION: '24'
RUN_ID: ${{ github.run_id }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
Expand Down
105 changes: 105 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Pylint settings: the checks that Codacy's Pylint runs on the automation scripts. Codacy reads
# this file, and the lint job of wp-compatibility-test.yml runs Pylint with it. Ruff and mypy
# check the same scripts with their own, wider rule sets.

[MAIN]
py-version = 3.12

[MESSAGES CONTROL]
disable = all
enable =
C0123,
C0200,
E0100,
E0101,
E0102,
E0103,
E0104,
E0105,
E0106,
E0107,
E0108,
E0110,
E0112,
E0113,
E0114,
E0115,
E0117,
E0202,
E0203,
E0211,
E0236,
E0238,
E0239,
E0240,
E0241,
E0301,
E0302,
E0601,
E0603,
E0604,
E0701,
E0702,
E0704,
E0710,
E0711,
E0712,
E1003,
E1102,
E1111,
E1120,
E1121,
E1123,
E1124,
E1125,
E1126,
E1127,
E1132,
E1200,
E1201,
E1205,
E1206,
E1300,
E1301,
E1302,
E1303,
E1304,
E1305,
E1306,
R0202,
R0203,
W0101,
W0102,
W0104,
W0105,
W0106,
W0107,
W0108,
W0109,
W0120,
W0122,
W0123,
W0124,
W0150,
W0199,
W0221,
W0222,
W0233,
W0404,
W0410,
W0601,
W0602,
W0604,
W0611,
W0612,
W0622,
W0702,
W0705,
W0711,
W1300,
W1301,
W1302,
W1303,
W1305,
W1306,
W1307
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ enginescript-site-optimizer/
|-- phpstan.neon # PHPStan configuration
|-- phpmd.xml # PHPMD configuration (Codacy reads it with PHPMD 2)
|-- phpmd-extra.xml # PHPMD 3 rules (composer phpmd and CI pass both files)
|-- biome.json # Biome lint rules (npm run lint:biome, CI, Codacy)
|-- .pylintrc # Pylint checks for .github/scripts (CI, Codacy)
|-- bandit.yml # Bandit settings for .github/scripts (CI, Codacy)
|-- psalm.xml # Psalm configuration
|-- phpunit.xml # PHPUnit configuration
|-- .distignore # Files left out of the release package
Expand All @@ -109,7 +112,7 @@ enginescript-site-optimizer/

The release package holds the main plugin file, `uninstall.php`, `readme.txt`, `LICENSE`, `includes/`, and `languages/`. When you add a top-level file or directory, add it to `.distignore` and `.gitattributes` unless it must ship; `.github/scripts/check-plugin-package.py` fails when the package lists disagree.

Codacy reads `phpcs.xml`, and `phpmd.xml`, but it installs no WordPress coding standards, no PHPCSExtra, and only PHPMD 2. Keep those files to what Codacy installs; the full configurations add the rest. After changing `phpcs-wordpress.xml`, or updating their packages, regenerate the Codacy copies with `python .github/scripts/codacy-configs.py phpcs`. CI fails when they are out of date.
Codacy reads `phpcs.xml`, and `phpmd.xml`, but it installs no WordPress coding standards, no PHPCSExtra, and only PHPMD 2. Keep those files to what Codacy installs; the full configurations add the rest. After changing `phpcs-wordpress.xml`, or updating their packages, regenerate the Codacy copies with `python .github/scripts/codacy-configs.py phpcs`. CI fails when they are out of date. Codacy also reads `biome.json`, `.pylintrc`, and `bandit.yml`, and CI runs Biome (`npm run lint:biome`), Pylint, and Bandit with the same files, so a pull request gets every check Codacy runs before Codacy does.

## Making Changes

Expand Down
3 changes: 3 additions & 0 deletions bandit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bandit settings: every test runs, none skipped. Codacy's Bandit reads this file, and the lint job
# of wp-compatibility-test.yml runs Bandit with it.
skips: []
Loading
Loading