From 127693a4926a7391194711000079e958d8ba1519 Mon Sep 17 00:00:00 2001
From: Rajeshreeputra <pravin.gaikwad@acquia.com>
Date: Wed, 6 Mar 2024 15:36:16 +0530
Subject: [PATCH] ACMS-3596: Remove axelerant/drupal-quality-checker plugin.

---
 composer.json    |   8 ++-
 composer.lock    | 128 +----------------------------------------------
 grumphp.yml.dist |  51 +++++++++++++++++++
 phpmd.xml.dist   |  43 ++++++++++++++++
 4 files changed, 103 insertions(+), 127 deletions(-)
 create mode 100644 grumphp.yml.dist
 create mode 100644 phpmd.xml.dist

diff --git a/composer.json b/composer.json
index 428bf3a2a..56c23944b 100644
--- a/composer.json
+++ b/composer.json
@@ -40,12 +40,18 @@
     },
     "require-dev": {
         "acquia/coding-standards": "^1.0",
-        "axelerant/drupal-quality-checker": "^1.1",
+        "dealerdirect/phpcodesniffer-composer-installer": "*",
+        "drupal/coder": "^8.3.7",
         "drupal/core-composer-scaffold": "^9.0.0 || ^10",
         "drupal/core-dev": "^9 || ^10",
         "ergebnis/composer-normalize": "^2.31.0",
+        "friendsoftwig/twigcs": "^4.0 || ^5.0 || ^6.0",
         "mglaman/drupal-check": "^1.4",
         "oomphinc/composer-installers-extender": "^1.1 || ^2",
+        "php-parallel-lint/php-parallel-lint": "^1.2",
+        "phpcompatibility/php-compatibility": "^9.0",
+        "phpmd/phpmd": "^2.8",
+        "phpro/grumphp-shim": "^1.0.0",
         "phpspec/prophecy-phpunit": "^2.0",
         "phpunit/phpunit": "^9.4.0",
         "weitzman/drupal-test-traits": "^2"
diff --git a/composer.lock b/composer.lock
index d1ee63754..52bb3e730 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "6728293353fbe2f377fef0bdf0f9340e",
+    "content-hash": "0d18e12b32e899d9866d19d75c049f57",
     "packages": [
         {
             "name": "acquia/acquia-cms-starterkit",
@@ -2436,7 +2436,7 @@
             "dist": {
                 "type": "path",
                 "url": "./modules/acquia_cms_common",
-                "reference": "d981733c3e8ea7fa7d6a31a69f7f2c1300ec541b"
+                "reference": "5335510514290d8e41b46ee10549ab78368313ed"
             },
             "require": {
                 "acquia/drupal-environment-detector": "^1.5",
@@ -16094,68 +16094,6 @@
             },
             "time": "2023-03-03T22:51:37+00:00"
         },
-        {
-            "name": "axelerant/drupal-quality-checker",
-            "version": "v1.3.0",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/axelerant/drupal-quality-checker.git",
-                "reference": "d354e3c1eda986c8a1b718af1f86fe0280d17486"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/axelerant/drupal-quality-checker/zipball/d354e3c1eda986c8a1b718af1f86fe0280d17486",
-                "reference": "d354e3c1eda986c8a1b718af1f86fe0280d17486",
-                "shasum": ""
-            },
-            "require": {
-                "dealerdirect/phpcodesniffer-composer-installer": "*",
-                "drupal/coder": "^8.3.7",
-                "friendsoftwig/twigcs": "^4.0 || ^5.0 || ^6.0",
-                "php-parallel-lint/php-parallel-lint": "^1.2",
-                "phpcompatibility/php-compatibility": "^9.0",
-                "phpmd/phpmd": "^2.8",
-                "phpro/grumphp-shim": "^1.0.0",
-                "sebastian/phpcpd": "^3.0 || ^4.0 || ^5.0 || ^6.0"
-            },
-            "suggest": {
-                "drupal/core-composer-scaffold": "Scaffold relevant files in project root. Add axelerant/drupal-quality-checker to extra.drupal-scaffold.allowed-packages."
-            },
-            "type": "project",
-            "extra": {
-                "drupal-scaffold": {
-                    "file-mapping": {
-                        "[project-root]/grumphp.yml.dist": {
-                            "mode": "replace",
-                            "path": "grumphp.yml.dist",
-                            "overwrite": false
-                        },
-                        "[project-root]/phpcs.xml.dist": "phpcs.xml.dist",
-                        "[project-root]/phpmd.xml.dist": "phpmd.xml.dist"
-                    }
-                },
-                "branch-alias": {
-                    "dev-main": "1.0.x-dev"
-                }
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "proprietary"
-            ],
-            "authors": [
-                {
-                    "name": "Hussain Abbas",
-                    "role": "Maintainer"
-                }
-            ],
-            "description": "Code quality checking tools for Drupal project.",
-            "homepage": "https://github.com/axelerant/drupal-quality-checker",
-            "support": {
-                "issues": "https://github.com/axelerant/drupal-quality-checker/issues",
-                "source": "https://github.com/axelerant/drupal-quality-checker"
-            },
-            "time": "2022-12-16T23:18:27+00:00"
-        },
         {
             "name": "behat/mink",
             "version": "v1.11.0",
@@ -20510,68 +20448,6 @@
             ],
             "time": "2020-10-26T13:14:26+00:00"
         },
-        {
-            "name": "sebastian/phpcpd",
-            "version": "6.0.3",
-            "source": {
-                "type": "git",
-                "url": "https://github.com/sebastianbergmann/phpcpd.git",
-                "reference": "f3683aa0db2e8e09287c2bb33a595b2873ea9176"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpcpd/zipball/f3683aa0db2e8e09287c2bb33a595b2873ea9176",
-                "reference": "f3683aa0db2e8e09287c2bb33a595b2873ea9176",
-                "shasum": ""
-            },
-            "require": {
-                "ext-dom": "*",
-                "php": ">=7.3",
-                "phpunit/php-file-iterator": "^3.0",
-                "phpunit/php-timer": "^5.0",
-                "sebastian/cli-parser": "^1.0",
-                "sebastian/version": "^3.0"
-            },
-            "bin": [
-                "phpcpd"
-            ],
-            "type": "library",
-            "extra": {
-                "branch-alias": {
-                    "dev-master": "6.0-dev"
-                }
-            },
-            "autoload": {
-                "classmap": [
-                    "src/"
-                ]
-            },
-            "notification-url": "https://packagist.org/downloads/",
-            "license": [
-                "BSD-3-Clause"
-            ],
-            "authors": [
-                {
-                    "name": "Sebastian Bergmann",
-                    "email": "sebastian@phpunit.de",
-                    "role": "lead"
-                }
-            ],
-            "description": "Copy/Paste Detector (CPD) for PHP code.",
-            "homepage": "https://github.com/sebastianbergmann/phpcpd",
-            "support": {
-                "issues": "https://github.com/sebastianbergmann/phpcpd/issues",
-                "source": "https://github.com/sebastianbergmann/phpcpd/tree/6.0.3"
-            },
-            "funding": [
-                {
-                    "url": "https://github.com/sebastianbergmann",
-                    "type": "github"
-                }
-            ],
-            "abandoned": true,
-            "time": "2020-12-07T05:39:23+00:00"
-        },
         {
             "name": "sebastian/recursion-context",
             "version": "4.0.5",
diff --git a/grumphp.yml.dist b/grumphp.yml.dist
new file mode 100644
index 000000000..e79d48adb
--- /dev/null
+++ b/grumphp.yml.dist
@@ -0,0 +1,51 @@
+parameters:
+  git_dir: .
+  bin_dir: vendor/bin
+grumphp:
+  ascii:
+    failed: vendor/axelerant/drupal-quality-checker/resources/grumpy.txt
+    succeeded: vendor/axelerant/drupal-quality-checker/resources/happy.txt
+  tasks:
+    phplint: ~
+    yamllint: ~
+    composer: ~
+    jsonlint: ~
+    twigcs:
+      path: 'web'
+      ruleset: 'FriendsOfTwig\Twigcs\Ruleset\Official'
+      exclude:
+        - core
+        - modules/contrib
+        - themes/contrib
+        - profiles/contrib
+    phpcpd:
+      directory: ['./web/modules/custom']
+    phpcs:
+      standard:
+        - phpcs.xml.dist
+      ignore_patterns:
+        - .github
+        - .gitlab
+        - /config/
+        - /drush/
+        - /web/robots.txt
+        - /web/sites/default/
+        - bower_components
+        - node_modules
+        - /vendor
+      triggered_by:
+        - php
+        - module
+        - inc
+        - install
+        - test
+        - profile
+        - theme
+        - css
+        - info
+        - txt
+    phpmd:
+      whitelist_patterns:
+        - /^web\/modules\/custom\/(.*)/
+      ruleset: ['phpmd.xml.dist']
+      triggered_by: ['php']
diff --git a/phpmd.xml.dist b/phpmd.xml.dist
new file mode 100644
index 000000000..a48c4f018
--- /dev/null
+++ b/phpmd.xml.dist
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<ruleset name="PHPMD ruleset for Drupal"
+         xmlns="http://pmd.sf.net/ruleset/1.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+         xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+  <description>
+    Custom ruleset for Drupal projects at Axelerant
+  </description>
+
+  <!-- Import common rulesets -->
+  <rule ref="rulesets/codesize.xml"/>
+  <rule ref="rulesets/design.xml"/>
+  <rule ref="rulesets/naming.xml"/>
+  <rule ref="rulesets/unusedcode.xml"/>
+
+  <!-- Import entire clean code rule set, modify StaticAccess rule -->
+  <rule ref="rulesets/cleancode.xml">
+    <exclude name="StaticAccess"/>
+    <exclude name="MissingImport"/>
+  </rule>
+  <rule ref="rulesets/cleancode.xml/StaticAccess">
+    <properties>
+      <property name="exceptions">
+        <value>
+          \DateTime,
+          \DateInterval,
+          \DateTimeZone,
+          \Drupal\Component\Plugin\Factory\DefaultFactory,
+          \Drupal\Component\Utility\Html,
+          \Drupal\Component\Utility\UrlHelper,
+          \Drupal\Core\Access\AccessResult,
+          \Drupal\Core\Url,
+          \Drupal\Core\Cache\Cache,
+          \Drupal\Core\Render\Element,
+          \Drupal\Core\Render\Element\Checkboxes,
+          \Drupal\Core\Annotation\Action,
+          \Drupal\Core\Site\Settings,
+        </value>
+      </property>
+    </properties>
+  </rule>
+</ruleset>