Skip to content

Commit

Permalink
Merge pull request #1 from newsuk/chore/CPNT-2252-phpmd-config
Browse files Browse the repository at this point in the history
chore(CPNT-2252) PHPMD config
  • Loading branch information
mohanrajpac authored Jan 15, 2024
2 parents ebb09f3 + a8f0119 commit 9045ab5
Show file tree
Hide file tree
Showing 8 changed files with 1,162 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2.1
jobs:
phpmd:
docker:
- image: cimg/php:8.2-node
steps:
- checkout
- run:
name: Install production dependencies
command: composer install --no-dev -o
- run:
name: Composer validate
command: composer validate --strict
- run:
name: PHPMD install check
command: |
vendor/bin/phpmd --version
if vendor/bin/phpmd --version | grep -q "PHPMD"; then
echo "PHPMD installed successfully."
else
echo "Error: PHPMD is not installed."
exit 1
fi
- persist_to_workspace:
root: .
paths:
- vendor
workflows:
version: 2
build:
jobs:
- phpmd
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @newsuk/tnl-wp-newspress
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# nuk-wp-phpmd-config
Provides PHPMD standard config for NUK WordPress plugins and themes.
### NUK WP PHPMD config

This library contains PHPMD configuration for NewsUK plugins and themes.

## Installation

Composer install:

```bash
composer require --dev newsuk/nuk-wp-phpmd-config
```

## Using the ruleset
Create a `phpmd.xml.dist` file in your project and add the following:

```xml
<?xml version="1.0"?>
<ruleset>
<rule ref="vendor/newsuk/nuk-wp-phpmd-config/ruleset.xml" />
</ruleset>
```

## Composer scripts
Add the following to `scripts` section in `composer.json` file and run `composer phpmd`, make sure to update the directory and file names accordingly.

```json
"phpmd": "phpmd plugin.php,includes text phpmd.xml.dist --color"
```

Add the following to generate baseline file for existing plugins and run `composer phpmd-baseline`, make sure to update the directory and file names accordingly.

```json
"phpmd-baseline": "phpmd plugin.php,includes text phpmd.xml.dist --generate-baseline"
```
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "newsuk/nuk-wp-phpmd-config",
"description": "PHPMD configuration for WordPress VIP plugins and themes",
"type": "phpmd-standard",
"license": "MIT",
"authors": [
{
"name": "Content Platforms",
"email": "[email protected]"
}
],
"require": {
"phpmd/phpmd": "^2.15"
}
}
Loading

0 comments on commit 9045ab5

Please sign in to comment.