rubocop-isucon 0.1.0 → 1.0.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +10 -0
  3. data/.github/workflows/pages.yml +68 -0
  4. data/.github/workflows/test.yml +3 -7
  5. data/.rubocop.yml +5 -1
  6. data/CHANGELOG.md +21 -1
  7. data/README.md +24 -6
  8. data/config/default.yml +37 -1
  9. data/gemfiles/activerecord_7_1.gemfile +14 -0
  10. data/lib/rubocop/cop/isucon/correctors/{mysql2_n_plus_one_query_corrector → n_plus_one_query_corrector}/correctable_methods.rb +1 -1
  11. data/lib/rubocop/cop/isucon/correctors/{mysql2_n_plus_one_query_corrector → n_plus_one_query_corrector}/replace_methods.rb +1 -1
  12. data/lib/rubocop/cop/isucon/correctors/{mysql2_n_plus_one_query_corrector.rb → n_plus_one_query_corrector.rb} +16 -5
  13. data/lib/rubocop/cop/isucon/mixin/join_without_index_methods.rb +87 -0
  14. data/lib/rubocop/cop/isucon/mixin/many_join_table_methods.rb +39 -0
  15. data/lib/rubocop/cop/isucon/mixin/mysql2_xquery_methods.rb +7 -116
  16. data/lib/rubocop/cop/isucon/mixin/n_plus_one_query_methods.rb +153 -0
  17. data/lib/rubocop/cop/isucon/mixin/offense_location_methods.rb +130 -0
  18. data/lib/rubocop/cop/isucon/mixin/select_asterisk_methods.rb +148 -0
  19. data/lib/rubocop/cop/isucon/mixin/sqlite3_execute_methods.rb +67 -0
  20. data/lib/rubocop/cop/isucon/mixin/where_without_index_methods.rb +96 -0
  21. data/lib/rubocop/cop/isucon/mysql2/join_without_index.rb +4 -67
  22. data/lib/rubocop/cop/isucon/mysql2/many_join_table.rb +1 -26
  23. data/lib/rubocop/cop/isucon/mysql2/n_plus_one_query.rb +5 -115
  24. data/lib/rubocop/cop/isucon/mysql2/select_asterisk.rb +1 -135
  25. data/lib/rubocop/cop/isucon/mysql2/where_without_index.rb +7 -72
  26. data/lib/rubocop/cop/isucon/shell/backtick.rb +7 -0
  27. data/lib/rubocop/cop/isucon/sqlite3/join_without_index.rb +37 -0
  28. data/lib/rubocop/cop/isucon/sqlite3/many_join_table.rb +61 -0
  29. data/lib/rubocop/cop/isucon/sqlite3/n_plus_one_query.rb +70 -0
  30. data/lib/rubocop/cop/isucon/sqlite3/select_asterisk.rb +37 -0
  31. data/lib/rubocop/cop/isucon/sqlite3/where_without_index.rb +40 -0
  32. data/lib/rubocop/cop/isucon_cops.rb +13 -1
  33. data/lib/rubocop/isucon/gda/client.rb +1 -1
  34. data/lib/rubocop/isucon/gda/join_operand.rb +1 -1
  35. data/lib/rubocop/isucon/version.rb +1 -1
  36. data/rubocop-isucon.gemspec +3 -2
  37. metadata +38 -10
  38. data/.github/workflows/gh-pages.yml +0 -44
@@ -1,10 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "isucon/mixin/database_methods"
4
+ require_relative "isucon/mixin/join_without_index_methods"
5
+ require_relative "isucon/mixin/offense_location_methods"
6
+ require_relative "isucon/mixin/many_join_table_methods"
4
7
  require_relative "isucon/mixin/mysql2_xquery_methods"
8
+ require_relative "isucon/mixin/n_plus_one_query_methods"
9
+ require_relative "isucon/mixin/select_asterisk_methods"
5
10
  require_relative "isucon/mixin/sinatra_methods"
11
+ require_relative "isucon/mixin/sqlite3_execute_methods"
12
+ require_relative "isucon/mixin/where_without_index_methods"
6
13
 
7
- require_relative "isucon/correctors/mysql2_n_plus_one_query_corrector"
14
+ require_relative "isucon/correctors/n_plus_one_query_corrector"
8
15
 
9
16
  require_relative "isucon/mysql2/join_without_index"
10
17
  require_relative "isucon/mysql2/many_join_table"
@@ -18,3 +25,8 @@ require_relative "isucon/sinatra/rack_logger"
18
25
  require_relative "isucon/sinatra/serve_static_file"
19
26
  require_relative "isucon/shell/backtick"
20
27
  require_relative "isucon/shell/system"
28
+ require_relative "isucon/sqlite3/join_without_index"
29
+ require_relative "isucon/sqlite3/many_join_table"
30
+ require_relative "isucon/sqlite3/n_plus_one_query"
31
+ require_relative "isucon/sqlite3/select_asterisk"
32
+ require_relative "isucon/sqlite3/where_without_index"
@@ -33,7 +33,7 @@ module RuboCop
33
33
 
34
34
  @table_names =
35
35
  if from_targets?
36
- ast.from.targets.map(&:table_name).compact.uniq
36
+ ast.from.targets.filter_map(&:table_name).uniq
37
37
  else
38
38
  []
39
39
  end
@@ -25,7 +25,7 @@ module RuboCop
25
25
  # @param column_name [String]
26
26
  # @param as [String]
27
27
  # @param node [GDA::Nodes::Expr]
28
- def initialize(table_name: nil, column_name: nil, as: nil, node: nil) # rubocop:disable Naming/MethodParameterName
28
+ def initialize(table_name: nil, column_name: nil, as: nil, node: nil)
29
29
  @table_name = table_name
30
30
  @column_name = column_name
31
31
  @as = as
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Isucon
5
- VERSION = "0.1.0"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "RuboCop plugin for ruby reference implementation of ISUCON"
13
13
  spec.homepage = "https://github.com/sue445/rubocop-isucon"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
15
+ spec.required_ruby_version = ">= 3.0.0"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/sue445/rubocop-isucon"
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_runtime_dependency "activerecord", ">= 6.1.0"
39
39
  spec.add_runtime_dependency "gda", "!= 1.1.2"
40
- spec.add_runtime_dependency "rubocop", ">= 1.29.0"
40
+ spec.add_runtime_dependency "rubocop", ">= 1.49.0"
41
41
  spec.add_runtime_dependency "rubocop-performance"
42
42
 
43
43
  spec.add_development_dependency "benchmark-ips"
@@ -47,6 +47,7 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "rspec", "~> 3.0"
48
48
  spec.add_development_dependency "rspec-its"
49
49
  spec.add_development_dependency "rubocop_auto_corrector"
50
+ spec.add_development_dependency "rubocop-yard"
50
51
  spec.add_development_dependency "sqlite3"
51
52
  spec.add_development_dependency "yard"
52
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-isucon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sue445
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-23 00:00:00.000000000 Z
11
+ date: 2023-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.29.0
47
+ version: 1.49.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.29.0
54
+ version: 1.49.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-performance
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-yard
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: sqlite3
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -199,7 +213,8 @@ executables: []
199
213
  extensions: []
200
214
  extra_rdoc_files: []
201
215
  files:
202
- - ".github/workflows/gh-pages.yml"
216
+ - ".github/dependabot.yml"
217
+ - ".github/workflows/pages.yml"
203
218
  - ".github/workflows/test.yml"
204
219
  - ".gitignore"
205
220
  - ".rspec"
@@ -220,13 +235,21 @@ files:
220
235
  - config/enable-only-performance.yml
221
236
  - gemfiles/activerecord_6_1.gemfile
222
237
  - gemfiles/activerecord_7_0.gemfile
238
+ - gemfiles/activerecord_7_1.gemfile
223
239
  - lib/rubocop-isucon.rb
224
- - lib/rubocop/cop/isucon/correctors/mysql2_n_plus_one_query_corrector.rb
225
- - lib/rubocop/cop/isucon/correctors/mysql2_n_plus_one_query_corrector/correctable_methods.rb
226
- - lib/rubocop/cop/isucon/correctors/mysql2_n_plus_one_query_corrector/replace_methods.rb
240
+ - lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb
241
+ - lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector/correctable_methods.rb
242
+ - lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector/replace_methods.rb
227
243
  - lib/rubocop/cop/isucon/mixin/database_methods.rb
244
+ - lib/rubocop/cop/isucon/mixin/join_without_index_methods.rb
245
+ - lib/rubocop/cop/isucon/mixin/many_join_table_methods.rb
228
246
  - lib/rubocop/cop/isucon/mixin/mysql2_xquery_methods.rb
247
+ - lib/rubocop/cop/isucon/mixin/n_plus_one_query_methods.rb
248
+ - lib/rubocop/cop/isucon/mixin/offense_location_methods.rb
249
+ - lib/rubocop/cop/isucon/mixin/select_asterisk_methods.rb
229
250
  - lib/rubocop/cop/isucon/mixin/sinatra_methods.rb
251
+ - lib/rubocop/cop/isucon/mixin/sqlite3_execute_methods.rb
252
+ - lib/rubocop/cop/isucon/mixin/where_without_index_methods.rb
230
253
  - lib/rubocop/cop/isucon/mysql2/join_without_index.rb
231
254
  - lib/rubocop/cop/isucon/mysql2/many_join_table.rb
232
255
  - lib/rubocop/cop/isucon/mysql2/n_plus_one_query.rb
@@ -239,6 +262,11 @@ files:
239
262
  - lib/rubocop/cop/isucon/sinatra/logger.rb
240
263
  - lib/rubocop/cop/isucon/sinatra/rack_logger.rb
241
264
  - lib/rubocop/cop/isucon/sinatra/serve_static_file.rb
265
+ - lib/rubocop/cop/isucon/sqlite3/join_without_index.rb
266
+ - lib/rubocop/cop/isucon/sqlite3/many_join_table.rb
267
+ - lib/rubocop/cop/isucon/sqlite3/n_plus_one_query.rb
268
+ - lib/rubocop/cop/isucon/sqlite3/select_asterisk.rb
269
+ - lib/rubocop/cop/isucon/sqlite3/where_without_index.rb
242
270
  - lib/rubocop/cop/isucon_cops.rb
243
271
  - lib/rubocop/isucon.rb
244
272
  - lib/rubocop/isucon/database_connection.rb
@@ -272,14 +300,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
300
  requirements:
273
301
  - - ">="
274
302
  - !ruby/object:Gem::Version
275
- version: 2.6.0
303
+ version: 3.0.0
276
304
  required_rubygems_version: !ruby/object:Gem::Requirement
277
305
  requirements:
278
306
  - - ">="
279
307
  - !ruby/object:Gem::Version
280
308
  version: '0'
281
309
  requirements: []
282
- rubygems_version: 3.3.7
310
+ rubygems_version: 3.4.10
283
311
  signing_key:
284
312
  specification_version: 4
285
313
  summary: RuboCop plugin for ruby reference implementation of ISUCON
@@ -1,44 +0,0 @@
1
- name: gh-pages
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- publish_yard:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - uses: actions/checkout@v2
14
-
15
- - name: Install packages
16
- run: |
17
- set -xe
18
- sudo apt-get update
19
- sudo apt-get install -y libgda-5.0
20
-
21
- - uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: "3.1"
24
- bundler-cache: true
25
-
26
- - run: bundle exec yard
27
-
28
- - name: Deploy to GitHub Pages
29
- uses: peaceiris/actions-gh-pages@v3
30
- with:
31
- github_token: ${{ secrets.GITHUB_TOKEN }}
32
- publish_dir: ./doc
33
- publish_branch: gh-pages
34
-
35
- - name: Slack Notification (not success)
36
- uses: lazy-actions/slatify@master
37
- if: "! success()"
38
- continue-on-error: true
39
- with:
40
- job_name: ${{ format('*publish_yard*') }}
41
- type: ${{ job.status }}
42
- icon_emoji: ":octocat:"
43
- url: ${{ secrets.SLACK_WEBHOOK }}
44
- token: ${{ secrets.GITHUB_TOKEN }}