| Age | Commit message (Collapse) | Author |
|
tagliala/chore/fix-redundant-file-extension-in-require-offenses
Fix Style/RedundantFileExtensionInRequire offenses
|
|
Enable Naming cops
|
|
Use #== and #eql? from BasicObject
|
|
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
```
|
|
Also fix safe minor offenses
- Naming/BinaryOperatorParameterName
- Naming/HeredocDelimiterCase
|
|
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 Performance/RedundantBlockCall offense
|
|
Fix Style/LineEndConcatenation offenses
|
|
Enable Security cops
|
|
Fix Style/NonNilCheck offenses
|
|
Replace `.match` with `.match?`
|
|
- 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
```
|
|
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
|
|
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
|
|
Remove check needed for Ruby < 2.5
|
|
Fix Style/ZeroLengthPredicate unsafe offenses
|
|
Remove minor safe offenses
|
|
Fix Style/AndOr offenses
|
|
Fix Lint/Void offenses
|
|
Fix hash transformation related offenses
|
|
Fix YARD warnings
|
|
- Use https where possible
- Capitalize Excel
|
|
|
|
Ref: #202
|
|
|
|
- Style/RaiseArgs
- Style/RedundantCondition
- Style/RedundantReturn
- Style/SelfAssignment
- Style/SoleNestedConditional
|
|
From Ruby Style Guide:
> Do not use `and` and `or` in boolean context - and and or are control
flow operators and should be used as such. They have very low
precedence, and can be used as a short form of specifying flow sequences
like "evaluate expression 1, and only if it is not successful
(returned `nil`), evaluate expression 2". This is especially useful for
raising errors or early return without breaking the reading flow.
Also:
- Remove redundant use of self
- Use attribute reader instead of accessing instance variable
|
|
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
|
|
|
|
- Style/HashConversion
- Style/HashTransformKeys
```
Comparison (IPS):
transform_keys: 2890030.0 i/s
Hash[map]: 1777641.0 i/s - 1.63x (± 0.00) slower
Comparison (Memory):
transform_keys: 168 allocated
Hash[map]: 248 allocated - 1.48x more
```
|
|
- `should_use_same_id_as?` has been replaced by `ids_cache_key` in 913003e
Also fixes a typo
[ci skip]
|
|
|
|
- Fix Performance/RedundantMatch and Performance/RegexpMatch
- Fix Performance/RedundantSplitRegexpArgument
|
|
|
|
|
|
|
|
Fix Performance/StringIdentifierArgument offense
|
|
|
|
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
```
|