| Age | Commit message (Collapse) | Author |
|
Ref: https://ruby-doc.org/core-2.6.10/Encoding.html#class-Encoding-label-Changing+an+encoding
|
|
Fix Lint/NonLocalExitFromIterator offense
|
|
All supported Ruby versions now support the `encode` method on strings,
so the conditional check for this method has been removed. Even if the
default encoding on Ruby >= 2.0 is UTF-8, this is not always the case
when the `LANG` environment variable is not set to `C.UTF-8`, so the
`encode` method has been preserved.
Additionally, this commit updates a link to use the `https` protocol for
improved security.
|
|
Uses `Array#any?` instead of `Array#each`.
According to benchmarks, `any?` is slightly faster when validation
fails (3%) and noticeably faster when validation passes (up to 60%)
|
|
No performance gain, this can be seen as a cosmetic change to have
shorter lines
|
|
- Use literal syntax on single line
- Use lambda method on multiple lines
Ref: https://rubystyle.guide/#lambda-multi-line
|
|
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
```
|
|
This commit fixes cases that cannot be detected by RuboCop
Ref: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FormatString
|
|
`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
```
|
|
Fix negated if offenses
|
|
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
|
|
|
|
|
|
|
|
Enable Naming cops
|
|
Use #== and #eql? from BasicObject
|
|
Also fix safe minor offenses
- Naming/BinaryOperatorParameterName
- Naming/HeredocDelimiterCase
|
|
Also refactors Page margins to avoid code duplication
|
|
Improve cell type from value implementation
|
|
Fix Performance/RedundantBlockCall offense
|
|
Replace `.match` with `.match?`
|
|
Prior to https://github.com/caxlsx/caxlsx/pull/223, SimpleTypeList
was just an object and inheritied #== / #eql? from BasicObject.
These versions are fast as they just compare whether two objects
sit in the same memory location.
After https://github.com/caxlsx/caxlsx/pull/223, we started to
inherit #== / #eql? from Array. These are slow as they crawl
all the elements in the Array.
This commit restores the original version of #== / #eql?.
|
|
Ref: https://github.com/fastruby/fast-ruby#proccall-and-block-arguments-vs-yieldcode
|
|
Also fixes a Security/Open offense that couldn't be exploited, because
the only invocation of `get_mime_type_from_uri` was validating the
input with a `URI::DEFAULT_PARSER` regexp
|
|
Remove check needed for Ruby < 2.5
|
|
Remove minor safe offenses
|
|
Fix Lint/Void offenses
|
|
- Use https where possible
- Capitalize Excel
|
|
Ref: #202
|
|
- Style/RaiseArgs
- Style/RedundantCondition
- Style/RedundantReturn
- Style/SelfAssignment
- Style/SoleNestedConditional
|
|
Setter methods return the assigned value. Given:
```rb
class MyClass
def foo=(v)
v = 10
42
end
end
```
`my_object.foo = 5` will always return `5`
This methods removes code that does not have effect
|
|
|
|
|
|
|
|
Ruby 2.5 introduced `delete_prefix` and `delete_suffix`.
Those methods are helpful when serializing formula and array formula
values, that are supposed to start and end with given prefixes
Also moves formula prefix to constants so they can be used by both
`Cell` and `CellSerializer` classes
Formula:
```
Ruby version: 3.2.2
Comparison:
delete_prefix: 8759353.5 i/s
sub: 2607022.4 i/s - 3.36x (± 0.00) slower
Comparison:
delete_prefix: 40 allocated
sub: 160 allocated - 4.00x more
```
Array Formula:
```
Ruby version: 3.2.2
Comparison:
delete_prefixes: 4798837.8 i/s
sub_sub: 937072.1 i/s - 5.12x (± 0.00) slower
Comparison:
delete_prefixes: 120 allocated
sub_sub: 488 allocated - 4.07x more
```
|
|
We still need Style/OptionalBooleanParameter as Ruby 2.7.5
gets confused with,
```
def serialized_attributes(str = +'', additional_attributes = {}, camelize_value: true)
```
|
|
The attributes in rows, cells, styles, etc are pre-defined for each
type and almost never change. The current code, however, does not
take that into account by reading all instance variables (via
declared_attributes), filtering out the blank one and ones that are
not xml attributes, and by camelizing each one.
We can avoid all this extra work by computing the camels and ivars for
xml attributes once and directly read the instance variables we care
about.
|
|
The `u=` would convert `true` to `:single` for backwards compatibility.
However, it is more explicit to set it to `:single` or one of the other
underline options instead of relying on the conversion.
|
|
Added VALID_BOOLEAN_TRUE_VALUES and VALID_BOOLEAN_FALSE_VALUES so that
those can be re-used in other placed and have the same notion of what
a valid boolean value is. For example, we can use the true values in
`Cell#u=`.
Additionally, since validate_boolean / BOOLEAN_VALIDATOR are invoked
so frequently, putting the likely values at the front can actually
make a non-trivial difference. Since VALID_BOOLEAN_VALUES is derived
from VALID_BOOLEAN_TRUE_VALUES and VALID_BOOLEAN_FALSE_VALUES, we
use `Array#zip` to still end up with good order.
|
|
|
|
internal list instance
The `to_a` and `to_ary` now work more like standard Array methods with `to_a` returning a
new array containing the elements of self and `to_ary` returning self.
|
|
Currently the SimpleTypedList is wrapping `@list` Array and re-implementing
certain methods to add type / value checking and delegating all the
non-destrutive methods to the internal @list.
Most everything that ends up being serialized to the excel file is derived
from SimpleTypedList (for example, a Row is a SimpleTypedList of Cells). This
means that many of the delegated methods are hit over and over again especially
`[]`. This extra delegation really adds up.
We can avoid the delegation by having SimpleTypedList extend Array and still
remove any un-safe methods.
It is possible to re-introduce an unsafe method in a subclass of SimpleTypedList
if needed. Here is one way,
```ruby
class MyList < SimpleTypedList
def clear
@clear_method ||= Array.instance_method(:clear).bind(self)
@clear_method.call
end
end
```
|
|
reduce memory consumption
|
|
|
|
Zip::OutputStream
The BufferedZipOutputStream is a drop-in replacement for Zip::OutputStream similar
to ZipCommand.
|
|
Currently, there are lots of examples of code like this,
```
str << ('<tag ' << foo << ' ' << bar << '/>')
```
which create the string for the tag in memory before piping to str.
We can avoid creating all of these intermediate strings by dropping
the paranthesis and piping directly to str.
This relies on the `str` passed around to handle lots of small
appends. This is a problem when using RubyZip, but that is solved
in the next commit.
|
|
|
|
|
|
- Lint/RedundantStringCoercion
- Style/CommentAnnotation offenses
- Style/DefWithParentheses
- Style/EvalWithLocation
- Style/MethodCallWithoutArgsParentheses
- Style/MethodDefParentheses
- Style/NilComparison
- Style/Semicolon
|