| Age | Commit message (Collapse) | Author |
|
|
|
Add optional interpolation points to icon sets
|
|
Fix Lint/UnusedBlockArgument offenses
|
|
|
|
[ci skip]
Close #298
|
|
---------
Co-authored-by: SarahVanHaute <[email protected]>
Co-authored-by: Geremia Taglialatela <[email protected]>
|
|
Provide documentation to two attribute readers which triggered the
offense.
|
|
- Lint/AmbiguousOperatorPrecedence
- Style/PerlBackrefs
- Style/StringChars
- Style/UnpackFirst
|
|
Previously, `require 'cgi'` was only called in `cell.rb`, but there are
other components in the Axlsx module that also use this dependency,
including `Axlsx::SeriesTitle`, `Axlsx::StrVal`, `Axlsx::Title`
(drawing), `Axlsx::Comment`, `Axlsx::ConditionalFormattingRule`, and
`Axlsx::HeaderFooter`.
By requiring cgi at the module level, we ensure that this dependency is
available to all components in the Axlsx module, which can prevent
issues if someone is requiring specific components that depend on cgi.
This change improves the maintainability and reliability of the codebase
by ensuring that all components have access to the required
dependencies.
Close #282
|
|
Fix redundant self offenses
|
|
No performance gain, this can be seen as a cosmetic change to have
shorter lines
|
|
Use `each_value` instead of `each` where possible. The performance gain
is minimal (3%).
```
Comparison:
each_value: 4105733.4 i/s
each: 3998011.4 i/s - 1.03x (± 0.00) slower
```
|
|
Renaming the existing methods would break the public API, and it is not
worth to alias and/or deprecate existing methods, so this commit
enables Naming/PredicateName and allows the existing methods to preserve
their name
|
|
Remove redundant `to_s` calls
|
|
Caxlsx is using both `.` and `::`, 220 occurrences vs 280 to invoke
methods on `Axlsx` module.
This commit standardizes the approach towards `.`, which will also allow
shorter lines.
Performance is not affected
```
Comparison:
Axlsx.validate: 8515252.3 i/s
Axlsx::validate: 8512863.7 i/s - same-ish: difference falls within error
```
|
|
`clean_value`'s return value is a `String`. That method will return
`@value.to_s`, or it will call `Axlsx.sanitize`, which will return a
`String` in both conditions (
|
|
Check for `nil` before checking for more expensive conditions which
include a method call or an array scan.
Also removes redundant comments on self-explanatory code
|
|
This commit fixes cases that cannot be detected by RuboCop
Ref: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FormatString
|
|
`%` is an operation on `String` that will return a new `String`, so
the interpolation is redundant
Also adds a missing spec on PivotTable#rels_pn
```
IPS:
uninterpolated: 4045715.7 i/s
interpolated: 2359775.6 i/s - 1.71x (± 0.00) slower
Memory:
uninterpolated: 160 allocated
interpolated: 232 allocated - 1.45x more
```
|
|
`Kernel#format` is faster and will avoid to allocate an array compared
to `String#%`.
```
IPS:
kernel_format: 3877614.2 i/s
string_percent: 3531475.0 i/s - 1.10x (± 0.00) slower
Memory:
kernel_format: 160 allocated
string_percent: 200 allocated - 1.25x more
```
|
|
Avoid unnecessary calls to `parse_options`
|
|
Fix negated if offenses
|
|
`Cell#initialize` is one of the most used methods in the library, so
a small improvement here will make a lot of difference on the overall
performance.
The impact of this change is negligible when `options` has elements
but is substantial when it is empty.
```
Comparison (empty options):
parse unless: 11636650.6 i/s
parse: 8109825.4 i/s - 1.43x (± 0.00) slower
Comparison (1 option):
parse: 3548037.5 i/s
parse unless: 3459029.7 i/s - same-ish: difference falls within error
```
|
|
Should also provide a negligible performance improvement, about 3%
on Ruby 3.2 and 6% on Ruby 2.6 (M1 Pro)
|
|
- Style/ParenthesesAroundCondition
- Style/RedundantParentheses
- Style/TernaryParentheses
`Style/ParenthesesAroundCondition` may be questionable, but a majority
of comparison where not using parentheses, so offenses have been fixed
for uniformity across the codebase
|
|
|
|
Fix Style/SymbolProc offenses
|
|
Fix Style/MutableConstant offenses
|
|
Fix Style/YodaCondition offense
|
|
Fix Style/ConditionalAssignment offenses
|
|
This also provides a performance improvement
```
Comparison (array of 4 elements):
map(&): 3643131.4 i/s
map {}: 3488052.5 i/s - 1.04x (± 0.00) slower
Comparison (array of 20 elements):
map(&): 466013.9 i/s
map {}: 408447.2 i/s - 1.14x (± 0.00) slower
```
|
|
|
|
|
|
|
|
Fix Style/HashEachMethods offense
|
|
|
|
Improve absolute cell reference method
|
|
tagliala/chore/fix-redundant-file-extension-in-require-offenses
Fix Style/RedundantFileExtensionInRequire offenses
|
|
Also inverts `string.match(REGEX)` with `REGEX.match(string)` because
of uniformity and because it has been tested 5% more performant on
Ruby 3.2. Performance on older Rubies is the same
```
REGEX.match(string): 1234330.7 i/s
string.match(REGEX): 1172670.1 i/s - 1.05x (± 0.00) slower
```
|
|
Replace `keys.each` with hash iteration
```rb
MY_HASH = {
first: '1',
second: '2',
third: '3'
}
%i[ips memory].each do |benchmark|
Benchmark.send(benchmark) do |x|
x.report("each_key") { MY_HASH.each_key { |k| MY_HASH[k] } }
x.report("keys.each") { MY_HASH.keys.each { |k| MY_HASH[k] } }
x.report("each") { MY_HASH.each { |k, v| v } }
x.compare!
end
end
```
```
IPS Comparison:
each: 4283031.6 i/s
each_key: 3683407.4 i/s - 1.16x (± 0.00) slower
keys.each: 3387425.1 i/s - 1.26x (± 0.00) slower
Memory Comparison:
each_key: 0 allocated
each: 0 allocated - same
keys.each: 40 allocated - Infx more
```
|
|
Axlsx::Row is now an Array, so it is possible to remove the extra
duplicate branch
|
|
|
|
Also refactors Page margins to avoid code duplication
|
|
Improve cell type from value implementation
|
|
Fix Style/NonNilCheck offenses
|
|
- Use `Regexp.match?` instead of `=~` when match is not needed
- Use `Regexp.match` instead of `string.match` for uniformity
```
match?: 7335121.2 i/s
=~: 2329358.3 i/s - 3.15x (± 0.00) slower
```
|
|
There were 8 occurrences of `!nil?` and 4 of `!= nil`. This change will
standardize the usage of non-nil checks
|
|
Fixes:
- Style/ClassCheck
- Style/ClassEqualityComparison
While `is_a?` and `kind_of?` are equivalent, there is a 5% gain
when switching from class comparison to `intance_of?`
```
Comparison:
instance_of: 16902635.9 i/s
class comparison: 16061288.3 i/s - 1.05x (± 0.00) slower
```
|
|
Add `Cell#style_str` so that we can directly return '0'
|
|
Fix Lint/UselessAssignment offenses
|