From 9bd66882a2c0bd2a8fa77ac14d7737c977f4a93d Mon Sep 17 00:00:00 2001
From: Gangler Fabrice <fabrice.gangler@adullact.org>
Date: Thu, 27 Feb 2020 06:36:21 +0100
Subject: [PATCH] CHORE(git hook): enable syntax checkers (json, php, ...)

syntax checkers: json, xml, yaml and php

install php lint
composer require --dev jakub-onderka/php-parallel-lint


Refs: #18
---
 webapp/composer.json |  1 +
 webapp/composer.lock | 50 ++++++++++++++++++++++-
 webapp/grumphp.yml   | 96 +++++++++++++++++++++++++-------------------
 webapp/symfony.lock  |  3 ++
 4 files changed, 108 insertions(+), 42 deletions(-)

diff --git a/webapp/composer.json b/webapp/composer.json
index 7bc0365..b6557e5 100644
--- a/webapp/composer.json
+++ b/webapp/composer.json
@@ -38,6 +38,7 @@
     },
     "require-dev": {
         "fzaninotto/faker": "^1.9",
+        "jakub-onderka/php-parallel-lint": "^1.0",
         "phpro/grumphp": "^0.18.0",
         "symfony/browser-kit": "5.0.*",
         "symfony/css-selector": "5.0.*",
diff --git a/webapp/composer.lock b/webapp/composer.lock
index 81acbf7..f635e9a 100644
--- a/webapp/composer.lock
+++ b/webapp/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
         "This file is @generated automatically"
     ],
-    "content-hash": "1bd0f4c341187428f76c1716b65ae915",
+    "content-hash": "1ae24e97e0d4714a9d66c6f10eac53c6",
     "packages": [
         {
             "name": "doctrine/annotations",
@@ -6275,6 +6275,54 @@
             "homepage": "http://gitonomy.com",
             "time": "2019-12-08T12:42:25+00:00"
         },
+        {
+            "name": "jakub-onderka/php-parallel-lint",
+            "version": "v1.0.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git",
+                "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
+                "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "require-dev": {
+                "jakub-onderka/php-console-highlighter": "~0.3",
+                "nette/tester": "~1.3",
+                "squizlabs/php_codesniffer": "~2.7"
+            },
+            "suggest": {
+                "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet"
+            },
+            "bin": [
+                "parallel-lint"
+            ],
+            "type": "library",
+            "autoload": {
+                "classmap": [
+                    "./"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-2-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Jakub Onderka",
+                    "email": "ahoj@jakubonderka.cz"
+                }
+            ],
+            "description": "This tool check syntax of PHP files about 20x faster than serial check.",
+            "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint",
+            "time": "2018-02-24T15:31:20+00:00"
+        },
         {
             "name": "nikic/php-parser",
             "version": "v4.3.0",
diff --git a/webapp/grumphp.yml b/webapp/grumphp.yml
index 949a226..e9c9804 100644
--- a/webapp/grumphp.yml
+++ b/webapp/grumphp.yml
@@ -5,33 +5,47 @@ parameters:
         failed: ~
         succeeded: ~
     testsuites:
-        # test-suite for the "vendor/bin/grumphp git:commit-msg" command:
+        ##
+        ## test-suite for the "vendor/bin/grumphp git:commit-msg" command:
         git_commit_msg:
             tasks:
                 - git_commit_message
-        # test-suite for the "vendor/bin/grumphp git:pre-commit" command:
-        # ---> run following tasks only on files in the git "stage" (index) : added by "git add <file>"
+        ##
+        ## test-suite for the "vendor/bin/grumphp git:pre-commit" command:
+        ## ---> run following tasks only on files in the git "stage" (index) : added by "git add <file>"
         git_pre_commit:
             tasks:
                 - composer
         #                - phpcs
-        #                - phplint
-        #                - jsonlint
-        #                - xmllint
-        #                - yamllint
+                - phplint
+                - jsonlint
+                - xmllint
+                - yamllint
+                - file_size
         #                - git_blacklist
-        # test-suite for the "vendor/bin/grumphp run --testsuite php_testSuite" command:
-        # ---> run following tasks on the full codebase
-        #        php_testSuite:
-        #            tasks:
-        #                - phplint
+        ##
+        ## test-suite for the "vendor/bin/grumphp run --testsuite linter_testSuite" command:
+        ## ---> run following tasks on the full codebase
+        linter_testSuite:
+            tasks:
+                - phplint
+                - jsonlint
+                - xmllint
+                - yamllint
+        ##
+        ## test-suite for the "vendor/bin/grumphp run --testsuite php_testSuite" command:
+        ## ---> run following tasks on the full codebase
+        php_testSuite:
+            tasks:
+                - phplint
         #                - phpcs
         #                - phpcpd
-        # test-suite for the "vendor/bin/grumphp run --testsuite php_testSuite_full" command:
-        # ---> run following tasks on the full codebase
-        #        php_testSuite_full:
-        #            tasks:
-        #                - phplint
+        ##
+        ## test-suite for the "vendor/bin/grumphp run --testsuite php_testSuite_full" command:
+        ## ---> run following tasks on the full codebase
+        php_testSuite_full:
+            tasks:
+                - phplint
         #                - phpcs
         #                - phpcpd
         #                - phpmd
@@ -96,7 +110,7 @@ parameters:
         ##
         ## File size: https://github.com/phpro/grumphp/blob/master/doc/tasks/file_size.md
         file_size:
-            max_size: 12M
+            max_size: 2M
             ignore_patterns: []
         ##
         ## Composer Require Checker: https://github.com/phpro/grumphp/blob/master/doc/tasks/composer_require_checker.md
@@ -176,32 +190,32 @@ parameters:
         #            triggered_by: ['php']
         ##
         ## JsonLint: https://github.com/phpro/grumphp/blob/master/doc/tasks/jsonlint.md
-        #        jsonlint:
-        #            ignore_patterns: []
-        #            detect_key_conflicts: false
+        jsonlint:
+            ignore_patterns: []
+            detect_key_conflicts: false
         ##
         ## PHPLint: https://github.com/phpro/grumphp/blob/master/doc/tasks/phplint.md
-        #        phplint:
-        #            exclude: []
-        #            jobs: ~
-        #            short_open_tag: false
-        #            ignore_patterns: []
-        #            triggered_by: ['php']
+        phplint:
+            exclude: []
+            jobs: ~
+            short_open_tag: false
+            ignore_patterns: []
+            triggered_by: ['php']
         ##
         ## XmlLint: https://github.com/phpro/grumphp/blob/master/doc/tasks/xmllint.md
-        #        xmllint:
-        #            ignore_patterns: []
-        #            load_from_net: false
-        #            x_include: false
-        #            dtd_validation: false
-        #            scheme_validation: false
-        #            triggered_by: ['xml']
+        xmllint:
+            ignore_patterns: []
+            load_from_net: false
+            x_include: false
+            dtd_validation: false
+            scheme_validation: false
+            triggered_by: ['xml']
         ##
         ## YamlLint: https://github.com/phpro/grumphp/blob/master/doc/tasks/yamllint.md
-        #        yamllint:
-        #            whitelist_patterns: []
-        #            ignore_patterns: []
-        #            object_support: false
-        #            exception_on_invalid_type: false
-        #            parse_constant: false
-        #            parse_custom_tags: false
+        yamllint:
+            whitelist_patterns: []
+            ignore_patterns: []
+            object_support: false
+            exception_on_invalid_type: false
+            parse_constant: false
+            parse_custom_tags: false
diff --git a/webapp/symfony.lock b/webapp/symfony.lock
index 5ed66a5..548dbb7 100644
--- a/webapp/symfony.lock
+++ b/webapp/symfony.lock
@@ -96,6 +96,9 @@
     "gitonomy/gitlib": {
         "version": "v1.2.0"
     },
+    "jakub-onderka/php-parallel-lint": {
+        "version": "v1.0.0"
+    },
     "jdorn/sql-formatter": {
         "version": "v1.2.17"
     },
-- 
GitLab