fix warnings per code climate

This commit is contained in:
whyzdev 2016-12-17 18:03:11 -05:00
parent 7d5c3144dc
commit 96a25935ac
3 changed files with 24 additions and 22 deletions

4
.gitignore vendored
View File

@ -7,4 +7,6 @@ bower_components
.DS_Store
.idea
coverage
coverage
test/tmp_*

View File

@ -271,16 +271,14 @@ var _drawTextCandidateFunc = (function() {
.attr('x', x + width / 2).attr('y', y + height / 2 + 5)
.style('text-anchor', 'middle')
.text(content);
for (var key in textAttrs) {
text.attr(key, textAttrs[key]);
}
};
_setTextAttrs(text, textAttrs);
}
function byTspan(content, g, x, y, width, height, textAttrs) {
var text = g.append('text')
.attr('x', x + width / 2).attr('y', y)
.style('text-anchor', 'middle');
var tspan = text.append('tspan')
text.append('tspan')
.attr('x', x + width / 2).attr('dy', '0')
.text(content);
@ -293,16 +291,13 @@ var _drawTextCandidateFunc = (function() {
if (tspans.length > 0 && tspans[0].length > 0) {
tspans = tspans[0];
//set y of <text> to the mid y of the first line
text.attr('y', y + (height/2.- text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.))
text.attr('y', y + (height/2.0 - text[0][0].getBBox().height*(1 - 1.0/tspans.length)/2.0))
.attr("dominant-baseline", "central")
.attr("alignment-baseline", "central")
.attr("alignment-baseline", "central");
}
}
for (var key in textAttrs) {
text.attr(key, textAttrs[key]);
}
};
_setTextAttrs(text, textAttrs);
}
function byFo(content, g, x, y, width, height, textAttrs) {
var s = g.append('switch');
@ -315,14 +310,19 @@ var _drawTextCandidateFunc = (function() {
text.append('div').style('display', 'table-cell')
.style('text-align', 'center').style('vertical-align', 'middle')
.text(content)
.text(content);
byTspan(content, s, x, y, width, height, textAttrs);
_setTextAttrs(text, textAttrs);
}
for (var key in textAttrs) {
text.attr(key, textAttrs[key]);
function _setTextAttrs(toText, fromTextAttrsDict) {
for (var key in fromTextAttrsDict) {
if (fromTextAttrsDict.hasOwnProperty(key)) {
toText.attr(key, fromTextAttrsDict[key]);
}
};
}
}
return function(conf) {
return conf.textPlacement==='fo' ? byFo : (

View File

@ -47,7 +47,7 @@ test('output of single png', function(t) {
var expected = ['test.mermaid.png']
opt = clone(singleFile)
var opt = clone(singleFile)
opt.outputDir += '_png'
opt.png = true
@ -64,7 +64,7 @@ test('output of multiple png', function(t) {
var expected = ['test.mermaid.png', 'test2.mermaid.png',
'gantt.mermaid.png', 'sequence.mermaid.png']
opt = clone(multiFile)
var opt = clone(multiFile)
opt.outputDir += '_png'
opt.png = true
@ -80,7 +80,7 @@ test('output of single svg', function(t) {
var expected = ['test.mermaid.svg']
opt = clone(singleFile)
var opt = clone(singleFile)
opt.outputDir += '_svg'
opt.svg = true
@ -97,7 +97,7 @@ test('output of multiple svg', function(t) {
var expected = ['test.mermaid.svg', 'test2.mermaid.svg',
'gantt.mermaid.svg', 'sequence.mermaid.svg']
opt = clone(multiFile)
var opt = clone(multiFile)
opt.outputDir += '_svg'
opt.svg = true
@ -154,7 +154,7 @@ function verifyFiles(expected, dir, t) {
}
, function(err) {
t.notOk(err, 'all files passed')
var delete_tmps = true
var delete_tmps = false
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); }
_rimraf(dir, function(rmerr) {
t.notOk(rmerr, 'cleaned up')