Skip to content

Commit

Permalink
Minor sonarcloud fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcnamara committed May 21, 2023
1 parent e0565d8 commit 672ed68
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
5 changes: 2 additions & 3 deletions xlsxwriter/chart_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ def _write_bar_chart(self, args):
subtype = "percentStacked"

# Set a default overlap for stacked charts.
if "stacked" in self.subtype:
if self.series_overlap_1 is None:
self.series_overlap_1 = 100
if "stacked" in self.subtype and self.series_overlap_1 is None:
self.series_overlap_1 = 100

self._xml_start_tag("c:barChart")

Expand Down
5 changes: 2 additions & 3 deletions xlsxwriter/chart_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ def _write_bar_chart(self, args):
subtype = "percentStacked"

# Set a default overlap for stacked charts.
if "stacked" in self.subtype:
if self.series_overlap_1 is None:
self.series_overlap_1 = 100
if "stacked" in self.subtype and self.series_overlap_1 is None:
self.series_overlap_1 = 100

self._xml_start_tag("c:barChart")

Expand Down
10 changes: 3 additions & 7 deletions xlsxwriter/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ def _write_a16_creation_id(self):
# Write the <a16:creationId> element.

xmlns_a_16 = "http://schemas.microsoft.com/office/drawing/2014/main"
id = "{00000000-0008-0000-0000-000002000000}"
creation_id = "{00000000-0008-0000-0000-000002000000}"

attributes = [
("xmlns:a16", xmlns_a_16),
("id", id),
("id", creation_id),
]

self._xml_empty_tag("a16:creationId", attributes)
Expand Down Expand Up @@ -709,11 +709,7 @@ def _write_sp_pr(self, col_absolute, row_absolute, width, height, shape=None):

def _write_xdr_sp_pr(self, index, col_absolute, row_absolute, width, height, shape):
# Write the <xdr:spPr> element for shapes.

attributes = []
# attributes = [('bwMode', 'auto')]

self._xml_start_tag("xdr:spPr", attributes)
self._xml_start_tag("xdr:spPr")

# Write the a:xfrm element.
self._write_a_xfrm(col_absolute, row_absolute, width, height, shape)
Expand Down
2 changes: 0 additions & 2 deletions xlsxwriter/workbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ def _prepare_num_formats(self):
unique_num_formats = {}
num_formats = []
index = 164
num_format_count = 0

for xf_format in self.xf_formats + self.dxf_formats:
num_format = xf_format.num_format
Expand Down Expand Up @@ -975,7 +974,6 @@ def _prepare_num_formats(self):
# Only increase font count for XF formats (not DXF formats).
if xf_format.xf_index:
num_formats.append(num_format)
num_format_count += 1

self.num_formats = num_formats

Expand Down
29 changes: 15 additions & 14 deletions xlsxwriter/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2040,8 +2040,8 @@ def autofit(self):
length += 16

# Add the string length to the lookup table.
max = col_width_max.get(col_num, 0)
if length > max:
width_max = col_width_max.get(col_num, 0)
if length > width_max:
col_width_max[col_num] = length

# Apply the width to the column.
Expand Down Expand Up @@ -2566,12 +2566,14 @@ def data_validation(self, first_row, first_col, last_row, last_col, options=None
options["error_type"] = error_types[options["error_type"]]

# Convert date/times value if required.
if options["validate"] in ("date", "time"):
if options["value"]:
if supported_datetime(options["value"]):
date_time = self._convert_date_time(options["value"])
# Format date number to the same precision as Excel.
options["value"] = "%.16g" % date_time
if (
options["validate"] in ("date", "time")
and options["value"]
and supported_datetime(options["value"])
):
date_time = self._convert_date_time(options["value"])
# Format date number to the same precision as Excel.
options["value"] = "%.16g" % date_time

if options["maximum"]:
if supported_datetime(options["maximum"]):
Expand Down Expand Up @@ -6171,11 +6173,10 @@ def _write_sheet_view(self):
attributes.append(("topLeftCell", self.top_left_cell))

# Set the zoom level.
if self.zoom != 100:
if not self.page_view:
attributes.append(("zoomScale", self.zoom))
if self.zoom_scale_normal:
attributes.append(("zoomScaleNormal", self.zoom))
if self.zoom != 100 and not self.page_view:
attributes.append(("zoomScale", self.zoom))
if self.zoom_scale_normal:
attributes.append(("zoomScaleNormal", self.zoom))

attributes.append(("workbookViewId", 0))

Expand Down Expand Up @@ -7180,7 +7181,7 @@ def _write_custom_filter(self, operator, val):
warn("Unknown operator = %s" % operator)

# The 'equal' operator is the default attribute and isn't stored.
if not operator == "equal":
if operator != "equal":
attributes.append(("operator", operator))
attributes.append(("val", val))

Expand Down

0 comments on commit 672ed68

Please sign in to comment.