jenkins-bot has submitted this change and it was merged.

Change subject: linter: Only send 1 log entry per image for bogus image options
......................................................................


linter: Only send 1 log entry per image for bogus image options

Change-Id: Ic4aecc03b337852804dc5cb10b82a0f7b423caf7
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/lintertest.js
2 files changed, 30 insertions(+), 19 deletions(-)

Approvals:
  Arlolra: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index abcd25a..0188365 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -236,26 +236,20 @@
 */
 function logBogusImageOptions(env, c, dp, tplInfo) {
        if (DU.isGeneratedFigure(c)) {
-               var optlist = dp.optList;
-               optlist.forEach(function(item) {
+               var items = [];
+               dp.optList.forEach(function(item) {
                        if (item.ck === "bogus") {
-                               var dsr;
-                               var inTransclusion = false;
-                               if (tplInfo) {
-                                       dsr = tplInfo.dsr;
-                                       inTransclusion = true;
-                               } else {
-                                       dsr = dp.dsr;
-                               }
-                               var lintObj = {
-                                       src: env.page.src,
-                                       dsr: dsr,
-                                       inTransclusion: inTransclusion,
-                                       params: { name: item.ak },
-                               };
-                               env.log('lint/bogus-image-options', lintObj);
+                               items.push(item.ak);
                        }
                });
+               if (items.length) {
+                       env.log('lint/bogus-image-options', {
+                               src: env.page.src,
+                               dsr: tplInfo ? tplInfo.dsr : dp.dsr,
+                               inTransclusion: !!tplInfo,
+                               params: { items: items },
+                       });
+               }
        }
 }
 
diff --git a/tests/mocha/lintertest.js b/tests/mocha/lintertest.js
index 0ac0f4d..0146bfc 100644
--- a/tests/mocha/lintertest.js
+++ b/tests/mocha/lintertest.js
@@ -132,7 +132,8 @@
                                result[0].dsr.should.include.members([ 0, 22, 
null, null ]);
                                result[0].should.have.a.property("src", 
"[[file:a.jpg|foo|bar]]");
                                result[0].should.have.a.property("params");
-                               result[0].params.should.have.a.property("name", 
"foo");
+                               
result[0].params.should.have.a.property("items");
+                               
result[0].params.items.should.include.members(["foo"]);
                        });
                });
                it('should lint Bogus image options found in transclusions 
correctly', function() {
@@ -143,7 +144,23 @@
                                result[0].dsr.should.include.members([ 0, 29, 
null, null ]);
                                result[0].should.have.a.property("src", 
"{{1x|[[file:a.jpg|foo|bar]]}}");
                                result[0].should.have.a.property("params");
-                               result[0].params.should.have.a.property("name", 
"foo");
+                               
result[0].params.items.should.include.members(["foo"]);
+                       });
+               });
+               it('should batch lint Bogus image options correctly', 
function() {
+                       return 
parseWT('[[file:a.jpg|foo|bar|baz]]').then(function(result) {
+                               result.should.have.length(1);
+                               result[0].should.have.a.property("type", 
"bogus-image-options");
+                               result[0].should.have.a.property("wiki", 
"enwiki");
+                               result[0].dsr.should.include.members([ 0, 26, 
null, null ]);
+                               result[0].should.have.a.property("src", 
"[[file:a.jpg|foo|bar|baz]]");
+                               result[0].should.have.a.property("params");
+                               
result[0].params.items.should.include.members(["foo", "bar"]);
+                       });
+               });
+               it('should not send any Bogus image options if there are none', 
function() {
+                       return 
parseWT('[[file:a.jpg|foo]]').then(function(result) {
+                               result.should.have.length(0);
                        });
                });
        });

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic4aecc03b337852804dc5cb10b82a0f7b423caf7
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to