gitlab-styles 6.5.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/gitlab-styles.gemspec +1 -1
- data/lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb +39 -0
- data/lib/gitlab/styles/version.rb +1 -1
- data/rubocop-performance.yml +7 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43bff11daad05b1bb5f442c18f3fa7b8ef871e60f7675dd165f55b1515953f7
|
4
|
+
data.tar.gz: 57317b8cb40639df642e1d058f342eba63979b237f18cc5d5290065aef5a3a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb319a3ada8ae43e77ba1de5aeb4234e9c6d8c97848f3ae3870222a4b0a4f4ae2f8f2d6356f8cd9b9747101482758834ceacb5cd2cef09519fd17e736a272c05
|
7
|
+
data.tar.gz: bb37685d5084df12a4820c47ce43ec0106aa50e05f9a7ddbde97c9956a7ec50e62fac388a968ba909c356c66324511fa5f407455b538ea1d183d2fa2f20367d1
|
data/gitlab-styles.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.email = ['gitlab_rubygems@gitlab.com']
|
13
13
|
|
14
14
|
spec.summary = 'GitLab style guides and shared style configs.'
|
15
|
-
spec.homepage = 'https://gitlab.com/gitlab-org/gitlab-styles'
|
15
|
+
spec.homepage = 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles'
|
16
16
|
spec.license = 'MIT'
|
17
17
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module Styles
|
5
|
+
module Rubocop
|
6
|
+
module Cop
|
7
|
+
module Performance
|
8
|
+
# This cop flags inefficient uses of rubyzip's Zip::File, since when instantiated
|
9
|
+
# it reads the file's Central Directory into memory entirely. For zips with many
|
10
|
+
# files and directories, this can be very expensive even when the archive's size
|
11
|
+
# in bytes is small.
|
12
|
+
#
|
13
|
+
# See also:
|
14
|
+
# - https://github.com/rubyzip/rubyzip/issues/506
|
15
|
+
# - https://github.com/rubyzip/rubyzip#notes-on-zipinputstream
|
16
|
+
class Rubyzip < RuboCop::Cop::Cop
|
17
|
+
MSG = 'Be careful when opening or iterating zip files via Zip::File. ' \
|
18
|
+
'Zip archives may contain many entries, and their file index is ' \
|
19
|
+
'read into memory upon construction, which can lead to ' \
|
20
|
+
'high memory use and poor performance. ' \
|
21
|
+
'Consider iterating archive entries via Zip::InputStream instead.'
|
22
|
+
|
23
|
+
def_node_matcher :reads_central_directory?, <<-PATTERN
|
24
|
+
(send
|
25
|
+
(const
|
26
|
+
(const {nil? (cbase)} :Zip) :File) {:new :open :foreach} ...)
|
27
|
+
PATTERN
|
28
|
+
|
29
|
+
def on_send(node)
|
30
|
+
return unless reads_central_directory?(node)
|
31
|
+
|
32
|
+
add_offense(node)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/rubocop-performance.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
---
|
2
2
|
require:
|
3
3
|
- rubocop-performance
|
4
|
+
- ./lib/gitlab/styles/rubocop
|
4
5
|
|
5
6
|
# Used to identify usages of ancestors.include? and change them to use ⇐ instead.
|
6
7
|
# https://docs.rubocop.org/rubocop-performance/1.8/cops_performance.html#performanceancestorsinclude
|
@@ -112,3 +113,9 @@ Performance/Sum:
|
|
112
113
|
# Checks for `.times.map` calls.
|
113
114
|
Performance/TimesMap:
|
114
115
|
Enabled: true
|
116
|
+
|
117
|
+
# Flags potentially expensive operations on ZIP archives.
|
118
|
+
Performance/Rubyzip:
|
119
|
+
Enabled: true
|
120
|
+
Exclude:
|
121
|
+
- 'spec/**/*'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-styles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb
|
178
178
|
- lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
|
179
179
|
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
180
|
+
- lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb
|
180
181
|
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
181
182
|
- lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb
|
182
183
|
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
@@ -211,7 +212,7 @@ files:
|
|
211
212
|
- rubocop-rspec.yml
|
212
213
|
- rubocop-security.yml
|
213
214
|
- rubocop-style.yml
|
214
|
-
homepage: https://gitlab.com/gitlab-org/gitlab-styles
|
215
|
+
homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles
|
215
216
|
licenses:
|
216
217
|
- MIT
|
217
218
|
metadata: {}
|