Skip to content

Commit

Permalink
sonarcloud fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adpare committed Mar 7, 2024
1 parent 30f0f58 commit 84dbe05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions mitreattack/navlayers/exporters/svg_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def recurse(breakset_inherit, depth, break_count):
return breaks


def _optimalFontSize(st, width, height, config, maxFontSize=12):
def _optimalFontSize(st, width, height, maxFontSize=12):
"""Calculate the optimal fontsize and word layout for a box of width x height.
:param st: string to fit
Expand Down Expand Up @@ -293,7 +293,7 @@ def build(
theight = height - 8
if bu:
theight = theight / 2
fs, patch_text = _optimalFontSize(t1text, width, theight, config, maxFontSize=28)
fs, patch_text = _optimalFontSize(t1text, width, theight, maxFontSize=28)
lines = len(patch_text)
y = theight / 2 + 2.1
if lines > 1:
Expand All @@ -307,7 +307,7 @@ def build(
upper_fs = fs
lower_offset = theight + 2.1
lower = G(tx=0, ty=lower_offset)
fs, patch_text = _optimalFontSize(t2text, width, (height - (height / 3 + upper_fs)), config, maxFontSize=28)
fs, patch_text = _optimalFontSize(t2text, width, (height - (height / 3 + upper_fs)), maxFontSize=28)
y = theight / 2 + 5.1
lines = len(patch_text)
adju = "\n".join(patch_text)
Expand Down Expand Up @@ -343,7 +343,7 @@ def build(
off = (block_width - (5 * (1 + len(tblob)))) / 2
if off < 0:
off = 0
fs, _ = _optimalFontSize("0", width / len(gradient_colors), height, config)
fs, _ = _optimalFontSize("0", width / len(gradient_colors), height)
label = Text(tblob, fs, ctype="label", ty=25, tx=off)
cell.append(label)
if len(legend_colors):
Expand All @@ -370,7 +370,7 @@ def build(
off = (block_width - (5 * (1 + len(legendLabel)))) / 2
if off < 0:
off = 0
fs, _ = _optimalFontSize("0", width / len(legend_colors), height, config)
fs, _ = _optimalFontSize("0", width / len(legend_colors), height)
textLabel = Text(legendLabel, fs, ctype="label", ty=25, tx=off)
cell.append(textLabel)
return g
Expand Down Expand Up @@ -477,7 +477,7 @@ def _block(technique, height, width, config, tBC):
"""
tech = Cell(height, width, technique["color"], ctype=technique["id"], tBC=tBC)

fs, patch_text = _optimalFontSize(technique["name"], width, height, config, config.fontSize)
fs, patch_text = _optimalFontSize(technique["name"], width, height, config.fontSize)
adjusted = "\n".join(patch_text)

lines = adjusted.count("\n")
Expand Down
2 changes: 1 addition & 1 deletion mitreattack/navlayers/exporters/svg_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def export(self, showName, showID, layer, config, sort=0, scores=[], colors=[],
# create header text
header_glob = G(tx=index, ty=header_offset)
text_glob = G(tx=technique_width / 2, ty=technique_height / 2)
font_size, _ = _optimalFontSize(displayStr, technique_width, technique_height, config, config.fontSize)
font_size, _ = _optimalFontSize(displayStr, technique_width, technique_height, config.fontSize)
text = Text(ctype="TacticName", font_size=font_size, text=displayStr, position="middle")
text_glob.append(text)
header_glob.append(text_glob)
Expand Down

0 comments on commit 84dbe05

Please sign in to comment.