[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Move linter config properties to the linter config object

2017-09-22 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/379429 )

Change subject: Move linter config properties to the linter config object
..


Move linter config properties to the linter config object

Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
---
M config.example.yaml
M lib/config/ParsoidConfig.js
M lib/logger/LintLogger.js
M lib/utils/Util.js
4 files changed, 27 insertions(+), 21 deletions(-)

Approvals:
  jenkins-bot: Verified
  Arlolra: Looks good to me, approved



diff --git a/config.example.yaml b/config.example.yaml
index e74103a..1fd7077 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -84,8 +84,9 @@
 
 # Enable linting of some wikitext errors to the log
 #linting: true
-# Send lint errors to MW API instead of to the log
-#linterSendAPI: false
+#linter:
+#  sendAPI: false # Send lint errors to MW API instead of to the log
+#  apiSampling: 10 # Sampling rate (1 / 10)
 
 # Require SSL certificates to be valid (default true)
 # Set to false when using self-signed SSL certificates
diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js
index 359dc2e..7f6a364 100644
--- a/lib/config/ParsoidConfig.js
+++ b/lib/config/ParsoidConfig.js
@@ -233,25 +233,25 @@
  */
 ParsoidConfig.prototype.linting = false;
 
-/**
- * @property {boolean} linterSendAPI
- * Whether to send lint errors to the MW API
- * Requires the MW Linter extension to be installed
- * and configured.
- */
-ParsoidConfig.prototype.linterSendAPI = false;
-
-/**
- * @property {number} linterSampling
- *
- * Ratio at which to sample linter errors, per page.
- * This is deterministic and based on page_id.
- */
-ParsoidConfig.prototype.linterAPISampling = 1;
-
 // FIXME: Fold other linter config options into this.
 ParsoidConfig.prototype.linter = {
/**
+* @property {boolean} sendAPI
+* Whether to send lint errors to the MW API
+* Requires the MW Linter extension to be installed
+* and configured.
+*/
+   sendAPI: false,
+
+   /**
+* @property {number} apiSampling
+*
+* Ratio at which to sample linter errors, per page.
+* This is deterministic and based on page_id.
+*/
+   apiSampling: 1,
+
+   /**
 * @property {number} tidyWhiteSpaceBugMaxLength
 *
 * Max length of content covered by 'white-space:nowrap' CSS
diff --git a/lib/logger/LintLogger.js b/lib/logger/LintLogger.js
index 0297233..89f1c6e 100644
--- a/lib/logger/LintLogger.js
+++ b/lib/logger/LintLogger.js
@@ -38,7 +38,7 @@
 
this.buffer = [];
 
-   if (env.page.id % env.conf.parsoid.linterAPISampling !== 0) {
+   if (env.page.id % env.conf.parsoid.linter.apiSampling !== 0) {
return;
}
 
@@ -47,7 +47,7 @@
return;
}
 
-   if (!env.conf.parsoid.linterSendAPI) {
+   if (!env.conf.parsoid.linter.sendAPI) {
enabledBuffer.forEach(function(item) {
// Call this async, since recursive sync calls 
to the logger
// are suppressed.  This messes up the 
ordering, as you'd
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index 232d2ac..6511186 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -242,7 +242,12 @@
}
if (opts.lint) {
parsoidConfig.linting = true;
-   parsoidConfig.linterSendAPI = false;
+   if (!parsoidConfig.linter) {
+   // Late require since we have a circular 
require involved
+   var ParsoidConfig = 
require('../config/ParsoidConfig.js').ParsoidConfig;
+   parsoidConfig.linter = 
Util.clone(ParsoidConfig.prototype.linter);
+   }
+   parsoidConfig.linter.sendAPI = false;
}
if (opts.useBatchAPI !== null) {
parsoidConfig.useBatchAPI = 
Util.booleanOption(opts.useBatchAPI);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 
Gerrit-Reviewer: Arlolra 
Gerrit-Reviewer: C. Scott Ananian 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Subramanya Sastry 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Move linter config properties to the linter config object

2017-09-20 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379429 )

Change subject: Move linter config properties to the linter config object
..

Move linter config properties to the linter config object

Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
---
M config.example.yaml
M lib/config/ParsoidConfig.js
M lib/logger/LintLogger.js
M lib/utils/Util.js
4 files changed, 23 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/29/379429/1

diff --git a/config.example.yaml b/config.example.yaml
index e74103a..a19f5da 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -84,8 +84,11 @@
 
 # Enable linting of some wikitext errors to the log
 #linting: true
+#linter:
 # Send lint errors to MW API instead of to the log
-#linterSendAPI: false
+#  - sendAPI: false
+# Sampling rate (1 / 10)
+#apiSampling: 10
 
 # Require SSL certificates to be valid (default true)
 # Set to false when using self-signed SSL certificates
diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js
index 359dc2e..7f6a364 100644
--- a/lib/config/ParsoidConfig.js
+++ b/lib/config/ParsoidConfig.js
@@ -233,25 +233,25 @@
  */
 ParsoidConfig.prototype.linting = false;
 
-/**
- * @property {boolean} linterSendAPI
- * Whether to send lint errors to the MW API
- * Requires the MW Linter extension to be installed
- * and configured.
- */
-ParsoidConfig.prototype.linterSendAPI = false;
-
-/**
- * @property {number} linterSampling
- *
- * Ratio at which to sample linter errors, per page.
- * This is deterministic and based on page_id.
- */
-ParsoidConfig.prototype.linterAPISampling = 1;
-
 // FIXME: Fold other linter config options into this.
 ParsoidConfig.prototype.linter = {
/**
+* @property {boolean} sendAPI
+* Whether to send lint errors to the MW API
+* Requires the MW Linter extension to be installed
+* and configured.
+*/
+   sendAPI: false,
+
+   /**
+* @property {number} apiSampling
+*
+* Ratio at which to sample linter errors, per page.
+* This is deterministic and based on page_id.
+*/
+   apiSampling: 1,
+
+   /**
 * @property {number} tidyWhiteSpaceBugMaxLength
 *
 * Max length of content covered by 'white-space:nowrap' CSS
diff --git a/lib/logger/LintLogger.js b/lib/logger/LintLogger.js
index 0297233..89f1c6e 100644
--- a/lib/logger/LintLogger.js
+++ b/lib/logger/LintLogger.js
@@ -38,7 +38,7 @@
 
this.buffer = [];
 
-   if (env.page.id % env.conf.parsoid.linterAPISampling !== 0) {
+   if (env.page.id % env.conf.parsoid.linter.apiSampling !== 0) {
return;
}
 
@@ -47,7 +47,7 @@
return;
}
 
-   if (!env.conf.parsoid.linterSendAPI) {
+   if (!env.conf.parsoid.linter.sendAPI) {
enabledBuffer.forEach(function(item) {
// Call this async, since recursive sync calls 
to the logger
// are suppressed.  This messes up the 
ordering, as you'd
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index 232d2ac..691a3f3 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -242,7 +242,7 @@
}
if (opts.lint) {
parsoidConfig.linting = true;
-   parsoidConfig.linterSendAPI = false;
+   parsoidConfig.linter.sendAPI = false;
}
if (opts.useBatchAPI !== null) {
parsoidConfig.useBatchAPI = 
Util.booleanOption(opts.useBatchAPI);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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