summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2023-06-05 11:22:54 +0200
committerGitHub <[email protected]>2023-06-05 11:22:54 +0200
commit8e496968872c18dbeb7df43435a43758d069ef2a (patch)
tree0129c25512855d16be4e09a0f16a40a09765f8dc /lib/axlsx
parentd9857fee81eb57935848039c6548d81f3339d728 (diff)
parent4195130bb4633bc667aeedd297dc56d7632a5810 (diff)
downloadcaxlsx-8e496968872c18dbeb7df43435a43758d069ef2a.tar.gz
caxlsx-8e496968872c18dbeb7df43435a43758d069ef2a.zip
Merge pull request #274 from tagliala/chore/fix-negated-if-offenses
Fix negated if offenses
Diffstat (limited to 'lib/axlsx')
-rw-r--r--lib/axlsx/drawing/num_val.rb2
-rw-r--r--lib/axlsx/drawing/str_val.rb2
-rw-r--r--lib/axlsx/package.rb4
-rw-r--r--lib/axlsx/stylesheet/styles.rb4
-rw-r--r--lib/axlsx/util/zip_command.rb2
-rw-r--r--lib/axlsx/workbook/workbook.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/border_creator.rb2
-rw-r--r--lib/axlsx/workbook/worksheet/worksheet.rb6
8 files changed, 12 insertions, 12 deletions
diff --git a/lib/axlsx/drawing/num_val.rb b/lib/axlsx/drawing/num_val.rb
index 19829a30..862d22ae 100644
--- a/lib/axlsx/drawing/num_val.rb
+++ b/lib/axlsx/drawing/num_val.rb
@@ -25,7 +25,7 @@ module Axlsx
# serialize the object
def to_xml_string(idx, str = +'')
Axlsx::validate_unsigned_int(idx)
- if !v.to_s.empty?
+ unless v.to_s.empty?
str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>'
end
end
diff --git a/lib/axlsx/drawing/str_val.rb b/lib/axlsx/drawing/str_val.rb
index d09e6ce8..86663cec 100644
--- a/lib/axlsx/drawing/str_val.rb
+++ b/lib/axlsx/drawing/str_val.rb
@@ -25,7 +25,7 @@ module Axlsx
# serialize the object
def to_xml_string(idx, str = +'')
Axlsx::validate_unsigned_int(idx)
- if !v.to_s.empty?
+ unless v.to_s.empty?
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>'
end
end
diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb
index 295ff2eb..4597efc0 100644
--- a/lib/axlsx/package.rb
+++ b/lib/axlsx/package.rb
@@ -101,7 +101,7 @@ module Axlsx
# s = p.to_stream()
# File.open('example_streamed.xlsx', 'wb') { |f| f.write(s.read) }
def serialize(output, options = {}, secondary_options = nil)
- if !workbook.styles_applied
+ unless workbook.styles_applied
workbook.apply_styles
end
@@ -126,7 +126,7 @@ module Axlsx
# @param [Boolean] confirm_valid Validate the package prior to serialization.
# @return [StringIO|Boolean] False if confirm_valid and validation errors exist. rewound string IO if not.
def to_stream(confirm_valid = false)
- if !workbook.styles_applied
+ unless workbook.styles_applied
workbook.apply_styles
end
diff --git a/lib/axlsx/stylesheet/styles.rb b/lib/axlsx/stylesheet/styles.rb
index e518d21e..6356d9e6 100644
--- a/lib/axlsx/stylesheet/styles.rb
+++ b/lib/axlsx/stylesheet/styles.rb
@@ -381,7 +381,7 @@ module Axlsx
end
validate_border_hash = ->(val) {
- if !(val.key?(:style) && val.key?(:color))
+ unless val.key?(:style) && val.key?(:color)
raise ArgumentError, (ERR_INVALID_BORDER_OPTIONS % options[:border])
end
}
@@ -439,7 +439,7 @@ module Axlsx
next
end
- if !edge_b_opts.empty?
+ unless edge_b_opts.empty?
if base_border_opts.empty?
validate_border_hash.call(edge_b_opts)
end
diff --git a/lib/axlsx/util/zip_command.rb b/lib/axlsx/util/zip_command.rb
index 44e06af5..77cc44c7 100644
--- a/lib/axlsx/util/zip_command.rb
+++ b/lib/axlsx/util/zip_command.rb
@@ -63,7 +63,7 @@ module Axlsx
escaped_dir = Shellwords.shellescape(@dir)
command = "cd #{escaped_dir} && #{@zip_command} #{output} #{inputs}"
stdout_and_stderr, status = Open3.capture2e(command)
- if !status.success?
+ unless status.success?
raise ZipError, stdout_and_stderr
end
end
diff --git a/lib/axlsx/workbook/workbook.rb b/lib/axlsx/workbook/workbook.rb
index e6e2f06f..271d4300 100644
--- a/lib/axlsx/workbook/workbook.rb
+++ b/lib/axlsx/workbook/workbook.rb
@@ -197,7 +197,7 @@ module Axlsx
# A helper to apply styles that were added using `worksheet.add_style`
# @return [Boolean]
def apply_styles
- return false if !styled_cells
+ return false unless styled_cells
styled_cells.each do |cell|
current_style = styles.style_index[cell.style]
diff --git a/lib/axlsx/workbook/worksheet/border_creator.rb b/lib/axlsx/workbook/worksheet/border_creator.rb
index 9abaded5..04a9cfac 100644
--- a/lib/axlsx/workbook/worksheet/border_creator.rb
+++ b/lib/axlsx/workbook/worksheet/border_creator.rb
@@ -17,7 +17,7 @@ module Axlsx
else
@edges = @edges.map { |x| x&.to_sym }.uniq
- if !(@edges - Axlsx::Border::EDGES).empty?
+ unless (@edges - Axlsx::Border::EDGES).empty?
raise ArgumentError, "Invalid edges provided, #{edges}"
end
end
diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb
index f2587edb..29a22db1 100644
--- a/lib/axlsx/workbook/worksheet/worksheet.rb
+++ b/lib/axlsx/workbook/worksheet/worksheet.rb
@@ -584,7 +584,7 @@ module Axlsx
# @param [String|Array] cell_refs Cell references
# @param [Hash] styles
def add_style(cell_refs, *styles)
- if !cell_refs.is_a?(Array)
+ unless cell_refs.is_a?(Array)
cell_refs = [cell_refs]
end
@@ -613,7 +613,7 @@ module Axlsx
border_edges = options
end
- if !cell_refs.is_a?(Array)
+ unless cell_refs.is_a?(Array)
cell_refs = [cell_refs]
end
@@ -850,7 +850,7 @@ module Axlsx
end
def add_autofilter_defined_name_to_workbook
- return if !auto_filter.range
+ return unless auto_filter.range
workbook.add_defined_name auto_filter.defined_name, name: '_xlnm._FilterDatabase', local_sheet_id: index, hidden: 1
end