Ejegg has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/351351 )

Change subject: Resurrecting hashar's original composer json linter
......................................................................

Resurrecting hashar's original composer json linter

To replace I2945f2b05bc7e91812b8 and make tests run faster

Change-Id: Ia6b74ed7c3e35019c5bde6fa4f6c4f2eb96af526
---
A bin/jsonlint.php
M composer.json
M composer.lock
3 files changed, 105 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/51/351351/1

diff --git a/bin/jsonlint.php b/bin/jsonlint.php
new file mode 100644
index 0000000..2ec14f7
--- /dev/null
+++ b/bin/jsonlint.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Parse json files from current directory.
+ *
+ * Inspired by Adam Wight "LintYaml.php" from the DonationInterface.
+ */
+
+use Seld\JsonLint\JsonParser;
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+/** Passed to fnmatch() */
+$excludes = array(
+       './vendor/**'
+);
+
+$jsonFiles = new recursiveCallbackFilterIterator(
+       new RecursiveDirectoryIterator( '.' ),
+       /** Actual filter */
+       function ( $cur, $key, $iterator ) {
+               global $excludes;
+
+               foreach ( $excludes as $exclude ) {
+                       if ( fnmatch( $exclude, $cur->getPathname() ) ) {
+                               return false;
+                       }
+               }
+
+
+               if ( $iterator->hasChildren() ) {
+                       return true;  // recurse
+               }
+               return 'json' === $cur->getExtension();
+       }
+);
+
+$jp = new JsonParser();
+$hasError = 0;
+$count = 0;
+foreach ( new RecursiveIteratorIterator( $jsonFiles ) as $jsonFile ) {
+       $count++;
+       $err = $jp->lint( file_get_contents( $jsonFile ) );
+       if ( $err ) {
+               $hasError++;
+               fwrite( STDERR, $jsonFile . ': ' . $err->getMessage() . "\n" );
+       }
+}
+if ( $hasError ) {
+       exit(1);
+} else {
+       print "Linted $count json files\n";
+}
diff --git a/composer.json b/composer.json
index 1ad856e..f123340 100644
--- a/composer.json
+++ b/composer.json
@@ -34,12 +34,14 @@
     ],
     "require-dev": {
         "phpunit/phpunit": "4.*",
+        "seld/jsonlint": "~1.6.0",
         "jakub-onderka/php-parallel-lint": "~0.9.2",
         "jakub-onderka/php-console-highlighter": "~0.3.2"
     },
     "scripts": {
         "test": [
-                       "parallel-lint --exclude vendor ."
+                       "parallel-lint --exclude vendor .",
+                       "php bin/jsonlint.php"
                ]
     }
 }
diff --git a/composer.lock b/composer.lock
index bba239f..ef70ee3 100644
--- a/composer.lock
+++ b/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": "b4d5a67549742ecca7b33afc58860195",
+    "content-hash": "837816dc238a69089c20c3637c029fad",
     "packages": [
         {
             "name": "addshore/psr-6-mediawiki-bagostuff-adapter",
@@ -2443,6 +2443,55 @@
             "time": "2015-06-21T13:59:46+00:00"
         },
         {
+            "name": "seld/jsonlint",
+            "version": "1.6.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Seldaek/jsonlint.git";,
+                "reference": "791f8c594f300d246cdf01c6b3e1e19611e301d8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": 
"https://api.github.com/repos/Seldaek/jsonlint/zipball/791f8c594f300d246cdf01c6b3e1e19611e301d8";,
+                "reference": "791f8c594f300d246cdf01c6b3e1e19611e301d8",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^5.3 || ^7.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^4.5"
+            },
+            "bin": [
+                "bin/jsonlint"
+            ],
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Seld\\JsonLint\\": "src/Seld/JsonLint/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/";,
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggi...@seld.be",
+                    "homepage": "http://seld.be";
+                }
+            ],
+            "description": "JSON Linter",
+            "keywords": [
+                "json",
+                "linter",
+                "parser",
+                "validator"
+            ],
+            "time": "2017-03-06T16:42:24+00:00"
+        },
+        {
             "name": "webmozart/assert",
             "version": "1.2.0",
             "source": {

-- 
To view, visit https://gerrit.wikimedia.org/r/351351
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6b74ed7c3e35019c5bde6fa4f6c4f2eb96af526
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to