Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/152242

Change subject: Convert spaces to tabs in linter files
......................................................................

Convert spaces to tabs in linter files

 * Consistent with the rest of the codebase.

Change-Id: I5ed7b68d96be5d1f7e9b69c3cf700aff74a54140
---
M lib/dom.linter.js
M lib/linter.js
2 files changed, 226 insertions(+), 226 deletions(-)


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

diff --git a/lib/dom.linter.js b/lib/dom.linter.js
index 245e2b8..d585996 100644
--- a/lib/dom.linter.js
+++ b/lib/dom.linter.js
@@ -13,8 +13,8 @@
 "use strict";
 
 var DU = require('./mediawiki.DOMUtils.js').DOMUtils,
-    Consts = require('./mediawiki.wikitext.constants.js').WikitextConstants,
-    Util = require('./mediawiki.Util.js').Util;
+       Consts = require('./mediawiki.wikitext.constants.js').WikitextConstants,
+       Util = require('./mediawiki.Util.js').Util;
 
 /*
 * Log Transclusion with more than one parts
@@ -30,30 +30,30 @@
 
 function logTransclusions(env, c) {
 
-    if (DU.getDataMw(c)) {
-        var dmw = DU.getDataMw(c);
-        var dsr = DU.getDataParsoid(c).dsr;
-        if (dmw.parts) {
-            var parts = dmw.parts, lintObj;
-            if (typeof parts[0] === 'string' || typeof parts[parts.length - 1] 
=== 'string') {
-                lintObj = {src:env.page.src, dsr:dsr };
-                env.log('lint/mixed-content', lintObj);
-            } else if (parts.length > 1) {
-                var targets = [],
-                    t = null;
-                dmw.parts.forEach(function(a) {
-                    if (a.template || a.extension) {
-                        targets.push(JSON.stringify(a.template.target));
-                    }
-                });
-                if (targets.length > 1) {
-                    lintObj = { src:targets, dsr:dsr };
-                    env.log('lint/multi-template', lintObj);
-                }
-            }
-        }
-    }
-    return;
+       if (DU.getDataMw(c)) {
+               var dmw = DU.getDataMw(c);
+               var dsr = DU.getDataParsoid(c).dsr;
+               if (dmw.parts) {
+                       var parts = dmw.parts, lintObj;
+                       if (typeof parts[0] === 'string' || typeof 
parts[parts.length - 1] === 'string') {
+                               lintObj = {src:env.page.src, dsr:dsr };
+                               env.log('lint/mixed-content', lintObj);
+                       } else if (parts.length > 1) {
+                               var targets = [],
+                                       t = null;
+                               dmw.parts.forEach(function(a) {
+                                       if (a.template || a.extension) {
+                                               
targets.push(JSON.stringify(a.template.target));
+                                       }
+                               });
+                               if (targets.length > 1) {
+                                       lintObj = { src:targets, dsr:dsr };
+                                       env.log('lint/multi-template', lintObj);
+                               }
+                       }
+               }
+       }
+       return;
 }
 
 /*
@@ -66,46 +66,46 @@
 */
 function logTreeBuilderFixup(env, c, dp, tmpl) {
 
-    var cNodeName = c.nodeName.toLowerCase(),
-        dsr = dp.dsr,
-        lintObj, inTransclusion = false;
+       var cNodeName = c.nodeName.toLowerCase(),
+               dsr = dp.dsr,
+               lintObj, inTransclusion = false;
 
-    if (tmpl) {
-        dsr = tmpl.dsr;
-        inTransclusion = true;
-    }
+       if (tmpl) {
+               dsr = tmpl.dsr;
+               inTransclusion = true;
+       }
 
-    if (DU.hasNodeName(c, 'meta')) {
-        var type = c.getAttribute('typeof');
-        if (type === 'mw:Placeholder/StrippedTag') {
-            lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
-            env.log('lint/stripped-tag', lintObj);
-        }
-    }
+       if (DU.hasNodeName(c, 'meta')) {
+               var type = c.getAttribute('typeof');
+               if (type === 'mw:Placeholder/StrippedTag') {
+                       lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
+                       env.log('lint/stripped-tag', lintObj);
+               }
+       }
 
-    // Dont lint auto-inserted start/end if:
-    // 1. c is a void element
-    // 2. c is not self-closed
-    // 3. c is not tbody
-    if ( DU.isTplElementNode(env, c) ||
-        (!Util.isVoidElement(cNodeName) &&
-        !dp.selfClose &&
-        cNodeName !== 'tbody' &&
-        DU.hasLiteralHTMLMarker(dp) &&
-        dsr) ) {
+       // Dont lint auto-inserted start/end if:
+       // 1. c is a void element
+       // 2. c is not self-closed
+       // 3. c is not tbody
+       if ( DU.isTplElementNode(env, c) ||
+               (!Util.isVoidElement(cNodeName) &&
+               !dp.selfClose &&
+               cNodeName !== 'tbody' &&
+               DU.hasLiteralHTMLMarker(dp) &&
+               dsr) ) {
 
-        if (dp.autoInsertedEnd === true && (tmpl || dsr[2]>0) ) {
-            lintObj = { src:env.page.src, dsr:dsr,
-                        tip:'Add End Tag to Fix this', 
inTransclusion:inTransclusion};
-            env.log('lint/missing-end-tag', lintObj);
-        }
+               if (dp.autoInsertedEnd === true && (tmpl || dsr[2]>0) ) {
+                       lintObj = { src:env.page.src, dsr:dsr,
+                                               tip:'Add End Tag to Fix this', 
inTransclusion:inTransclusion};
+                       env.log('lint/missing-end-tag', lintObj);
+               }
 
-        if (dp.autoInsertedStart === true && (tmpl ||  dsr[3]>0) ) {
-            lintObj = { src:env.page.src, dsr:dsr,
-                        tip:'Add Start Tag to Fix this', 
inTransclusion:inTransclusion};
-            env.log('lint/missing-start-tag', lintObj);
-        }
-    }
+               if (dp.autoInsertedStart === true && (tmpl ||  dsr[3]>0) ) {
+                       lintObj = { src:env.page.src, dsr:dsr,
+                                               tip:'Add Start Tag to Fix 
this', inTransclusion:inTransclusion};
+                       env.log('lint/missing-start-tag', lintObj);
+               }
+       }
 }
 
 /*
@@ -121,42 +121,42 @@
 */
 function logIgnoredTableAttr(env, c, dp, tmpl) {
 
-    var dsr, inTransclusion = false;
-    if (DU.hasNodeName(c, "table")) {
-        var fc = c.firstChild;
-        while (fc) {
-            if (DU.hasNodeName(fc,"tbody")) {
-                var trfc = fc.firstChild;
-                while (trfc) {
-                    if (DU.hasNodeName(trfc, "tr")) {
-                        dp = DU.getDataParsoid(trfc);
-                        if (dp.sa) {
-                            var wc = false;
-                            // Discard attributes that are only whitespace and 
comments
-                            for (var a in dp.sa) {
-                                var re = /^\s*$|\n[ 
\t]*<!--([^-]|-(?!->))*-->([ \t]|<!--([^-]|-(?!->))*-->)*\n/g;
-                                if ( (a || dp.sa.a) && (!re.test(a) || 
!re.test(dp.sa.a))) {
-                                    wc = true;
-                                }
-                            }
-                            if (wc) {
-                                if ( tmpl ) {
-                                   dsr = tmpl.dsr;
-                                   inTransclusion = true;
-                                } else {
-                                   dsr = dp.dsr;
-                                }
-                                var lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
-                                env.log('lint/ignored-table-attr', lintObj);
-                            }
-                        }
-                    }
-                    trfc = trfc.nextSibling;
-                }
-            }
-            fc = fc.nextSibling;
-        }
-    }
+       var dsr, inTransclusion = false;
+       if (DU.hasNodeName(c, "table")) {
+               var fc = c.firstChild;
+               while (fc) {
+                       if (DU.hasNodeName(fc,"tbody")) {
+                               var trfc = fc.firstChild;
+                               while (trfc) {
+                                       if (DU.hasNodeName(trfc, "tr")) {
+                                               dp = DU.getDataParsoid(trfc);
+                                               if (dp.sa) {
+                                                       var wc = false;
+                                                       // Discard attributes 
that are only whitespace and comments
+                                                       for (var a in dp.sa) {
+                                                               var re = 
/^\s*$|\n[ \t]*<!--([^-]|-(?!->))*-->([ \t]|<!--([^-]|-(?!->))*-->)*\n/g;
+                                                               if ( (a || 
dp.sa.a) && (!re.test(a) || !re.test(dp.sa.a))) {
+                                                                       wc = 
true;
+                                                               }
+                                                       }
+                                                       if (wc) {
+                                                               if ( tmpl ) {
+                                                                  dsr = 
tmpl.dsr;
+                                                                  
inTransclusion = true;
+                                                               } else {
+                                                                  dsr = dp.dsr;
+                                                               }
+                                                               var lintObj = { 
src:env.page.src, dsr:dsr, inTransclusion:inTransclusion };
+                                                               
env.log('lint/ignored-table-attr', lintObj);
+                                                       }
+                                               }
+                                       }
+                                       trfc = trfc.nextSibling;
+                               }
+                       }
+                       fc = fc.nextSibling;
+               }
+       }
 }
 
 /*
@@ -173,24 +173,24 @@
 */
 function logFosteredContent(env, c, dp, tmpl, nextSibling){
 
-    var dsr, inTransclusion = false;
-    var fosteredSRC = c.innerHTML;
-    while (nextSibling && !DU.hasNodeName(nextSibling,'table')) {
-        fosteredSRC += nextSibling.innerHTML;
-        if ( nextSibling === tmpl.last ) {
-            tmpl.done = true;
-        }
-        nextSibling = nextSibling.nextSibling;
-    }
-    if (tmpl) {
-        dsr = tmpl.dsr;
-        inTransclusion = true;
-    } else {
-        dsr = DU.getDataParsoid(nextSibling).dsr;
-    }
-    var lintObj = { src:fosteredSRC, dsr:dsr, inTransclusion:inTransclusion };
-    env.log('lint/fostered', lintObj);
-    return nextSibling;
+       var dsr, inTransclusion = false;
+       var fosteredSRC = c.innerHTML;
+       while (nextSibling && !DU.hasNodeName(nextSibling,'table')) {
+               fosteredSRC += nextSibling.innerHTML;
+               if ( nextSibling === tmpl.last ) {
+                       tmpl.done = true;
+               }
+               nextSibling = nextSibling.nextSibling;
+       }
+       if (tmpl) {
+               dsr = tmpl.dsr;
+               inTransclusion = true;
+       } else {
+               dsr = DU.getDataParsoid(nextSibling).dsr;
+       }
+       var lintObj = { src:fosteredSRC, dsr:dsr, inTransclusion:inTransclusion 
};
+       env.log('lint/fostered', lintObj);
+       return nextSibling;
 }
 
 /*
@@ -201,44 +201,44 @@
 */
 function logObsoleteHTMLTags(env, c, dp, tmpl) {
 
-    var dsr = dp.dsr, inTransclusion = false;
-    var re = /^(BIG|CENTER|FONT|STRIKE|TT)$/;
+       var dsr = dp.dsr, inTransclusion = false;
+       var re = /^(BIG|CENTER|FONT|STRIKE|TT)$/;
 
-    if (tmpl) {
-        dsr = tmpl.dsr;
-        inTransclusion = true;
-    }
+       if (tmpl) {
+               dsr = tmpl.dsr;
+               inTransclusion = true;
+       }
 
-    if (re.test(c.nodeName)) {
-        var lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
-        env.log('lint/obsolete-tag', lintObj);
-    }
+       if (re.test(c.nodeName)) {
+               var lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
+               env.log('lint/obsolete-tag', lintObj);
+       }
 }
 
 /*
 *
 * Log Bogus Image Options, since with unrecognized image options
-* See -  https://www.mediawiki.org/wiki/Help:Images#Syntax
+* See -         https://www.mediawiki.org/wiki/Help:Images#Syntax
 *
 */
 function logBogusImageOptions(env, c, dp, tmpl) {
 
-    if(DU.isGeneratedFigure(c)) {
-        var optlist = dp.optList;
-        optlist.forEach(function (item) {
-            if (item.ck === "bogus") {
-                var dsr, inTransclusion = false;
-                if ( tmpl ) {
-                    dsr = tmpl.dsr;
-                    inTransclusion = true;
-                } else {
-                    dsr = dp.dsr;
-                }
-                var lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
-                env.log('lint/bogus-image-options', lintObj);
-            }
-        });
-    }
+       if(DU.isGeneratedFigure(c)) {
+               var optlist = dp.optList;
+               optlist.forEach(function (item) {
+                       if (item.ck === "bogus") {
+                               var dsr, inTransclusion = false;
+                               if ( tmpl ) {
+                                       dsr = tmpl.dsr;
+                                       inTransclusion = true;
+                               } else {
+                                       dsr = dp.dsr;
+                               }
+                               var lintObj = { src:env.page.src, dsr:dsr, 
inTransclusion:inTransclusion };
+                               env.log('lint/bogus-image-options', lintObj);
+                       }
+               });
+       }
 }
 
 function logWikitextFixups(node, env, options, atTopLevel, tmpl) {
@@ -248,58 +248,58 @@
                return;
        }
 
-    var c = node.firstChild;
+       var c = node.firstChild;
 
-    while (c) {
-        var nextSibling = c.nextSibling,
-            dp = DU.getDataParsoid(c);
+       while (c) {
+               var nextSibling = c.nextSibling,
+                       dp = DU.getDataParsoid(c);
 
-        // Store info from the first node of an about id group.
-        // Nested templates aren't an issue because we expand top-level
-        // templates with the mediawiki api.
-        if ( !tmpl && DU.isTplElementNode(env, c) ) {
-            var about = c.getAttribute('about');
-            tmpl = {
-                last: DU.getAboutSiblings(c, about).last(),
-                dsr: dp.dsr,
-                done: false
-            };
+               // Store info from the first node of an about id group.
+               // Nested templates aren't an issue because we expand top-level
+               // templates with the mediawiki api.
+               if ( !tmpl && DU.isTplElementNode(env, c) ) {
+                       var about = c.getAttribute('about');
+                       tmpl = {
+                               last: DU.getAboutSiblings(c, about).last(),
+                               dsr: dp.dsr,
+                               done: false
+                       };
 
-            // Log transclusions with more than one part
-            logTransclusions(env, c);
-        }
+                       // Log transclusions with more than one part
+                       logTransclusions(env, c);
+               }
 
-        if (DU.isElt(c)) {
+               if (DU.isElt(c)) {
 
-            // Log Tree Builder fixups
-            logTreeBuilderFixup(env, c, dp, tmpl);
+                       // Log Tree Builder fixups
+                       logTreeBuilderFixup(env, c, dp, tmpl);
 
-            // Log Ignored Table Attributes
-            logIgnoredTableAttr(env, c, dp, tmpl);
+                       // Log Ignored Table Attributes
+                       logIgnoredTableAttr(env, c, dp, tmpl);
 
-            // Log obsolete HTML tags
-            logObsoleteHTMLTags(env, c, dp, tmpl);
+                       // Log obsolete HTML tags
+                       logObsoleteHTMLTags(env, c, dp, tmpl);
 
-            // Log bogus image options
-            logBogusImageOptions(env, c, dp, tmpl);
+                       // Log bogus image options
+                       logBogusImageOptions(env, c, dp, tmpl);
 
-            if (dp.fostered) {
-                // Log Fostered content
-                nextSibling = logFosteredContent(env, c, dp, tmpl, 
nextSibling);
-            } else if (c.childNodes.length > 0) {
-                // Process subtree
-                logWikitextFixups(c, env, options, atTopLevel, tmpl);
-            }
-        }
+                       if (dp.fostered) {
+                               // Log Fostered content
+                               nextSibling = logFosteredContent(env, c, dp, 
tmpl, nextSibling);
+                       } else if (c.childNodes.length > 0) {
+                               // Process subtree
+                               logWikitextFixups(c, env, options, atTopLevel, 
tmpl);
+                       }
+               }
 
-        if ( tmpl && (c === tmpl.last || tmpl.done) ) {
-            tmpl = null;
-        }
+               if ( tmpl && (c === tmpl.last || tmpl.done) ) {
+                       tmpl = null;
+               }
 
-        c = nextSibling;
-    }
+               c = nextSibling;
+       }
 }
 
 if (typeof module === "object") {
-    module.exports.logWikitextFixups = logWikitextFixups;
+       module.exports.logWikitextFixups = logWikitextFixups;
 }
diff --git a/lib/linter.js b/lib/linter.js
index 837c0f0..bcb27be 100644
--- a/lib/linter.js
+++ b/lib/linter.js
@@ -9,7 +9,7 @@
 var request = require('request');
 
 var Linter = function (){
-    this.buffer = [];
+       this.buffer = [];
 };
 
 Linter.prototype.logLintOutput = function(logData, cb) {
@@ -33,60 +33,60 @@
                } else {
                        console.log("No Issues found");
                }
-    } catch (e) {
-        console.error("Error in logLintOutput: " + e);
-        return;
-    } finally {
-        cb();
-    }
+       } catch (e) {
+               console.error("Error in logLintOutput: " + e);
+               return;
+       } finally {
+               cb();
+       }
 };
 
 Linter.prototype.linterBackend = function(logData, cb) {
-    try {
-        var logType = logData.logType,
-            lintObj = logData.logObject[0],
-            src = lintObj.src,
-            dsr = lintObj.dsr,
-            inTransclusion = lintObj.inTransclusion,
-            msg = {};
+       try {
+               var logType = logData.logType,
+                       lintObj = logData.logObject[0],
+                       src = lintObj.src,
+                       dsr = lintObj.dsr,
+                       inTransclusion = lintObj.inTransclusion,
+                       msg = {};
 
-        var re = /lint\/(.*)/,
-            wiki = logData._env.conf.wiki.iwp;
+               var re = /lint\/(.*)/,
+                       wiki = logData._env.conf.wiki.iwp;
 
-        msg.type = logType.match(re)[1];
-        msg.location = logData.locationMsg();
-        msg.wiki = wiki;
-        msg.page = logData._env.page.name;
-        msg.revision = logData._env.page.meta.revision.revid;
-        msg.wikiurl = 
logData._env.conf.parsoid.interwikiMap[wiki].split('/w/')[0];
+               msg.type = logType.match(re)[1];
+               msg.location = logData.locationMsg();
+               msg.wiki = wiki;
+               msg.page = logData._env.page.name;
+               msg.revision = logData._env.page.meta.revision.revid;
+               msg.wikiurl = 
logData._env.conf.parsoid.interwikiMap[wiki].split('/w/')[0];
 
-        if (dsr) {
-            msg.dsr = dsr;
-        }
+               if (dsr) {
+                       msg.dsr = dsr;
+               }
 
-        if (inTransclusion) {
-            msg.inTransclusion = inTransclusion;
-        }
-        if (logType === 'lint/fostered' || logType === 'lint/multi-template' 
|| logType === 'lint/mixed-content' ) {
-            msg.src = src;
-        } else if (dsr) {
-            msg.src = src.substring(dsr[0], dsr[1]);
-        }
+               if (inTransclusion) {
+                       msg.inTransclusion = inTransclusion;
+               }
+               if (logType === 'lint/fostered' || logType === 
'lint/multi-template' || logType === 'lint/mixed-content' ) {
+                       msg.src = src;
+               } else if (dsr) {
+                       msg.src = src.substring(dsr[0], dsr[1]);
+               }
 
-        if (logData.logObject[2]) {
-            msg.tips = logData.tip;
-        }
+               if (logData.logObject[2]) {
+                       msg.tips = logData.tip;
+               }
 
-        this.buffer.push(msg);
+               this.buffer.push(msg);
 
-    } catch (e) {
-        console.error("Error in linterBackend: " + e);
-        return;
-    } finally {
-        cb();
-    }
+       } catch (e) {
+               console.error("Error in linterBackend: " + e);
+               return;
+       } finally {
+               cb();
+       }
 };
 
 if (typeof module === "object") {
-    module.exports.Linter = Linter;
+       module.exports.Linter = Linter;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ed7b68d96be5d1f7e9b69c3cf700aff74a54140
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>

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

Reply via email to