gitlab-styles 7.0.0 → 9.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/Gemfile +3 -3
  4. data/gitlab-styles.gemspec +6 -6
  5. data/lib/gitlab/styles/common/banned_constants.rb +28 -0
  6. data/lib/gitlab/styles/rubocop/model_helpers.rb +1 -1
  7. data/lib/gitlab/styles/rubocop.rb +2 -2
  8. data/lib/gitlab/styles/version.rb +1 -1
  9. data/lib/rubocop/cop/active_record_dependent.rb +32 -0
  10. data/lib/rubocop/cop/active_record_serialize.rb +20 -0
  11. data/lib/rubocop/cop/avoid_return_from_blocks.rb +79 -0
  12. data/lib/rubocop/cop/code_reuse/active_record.rb +80 -0
  13. data/lib/rubocop/cop/custom_error_class.rb +67 -0
  14. data/lib/rubocop/cop/fips/md5.rb +27 -0
  15. data/lib/rubocop/cop/fips/open_ssl.rb +31 -0
  16. data/lib/rubocop/cop/fips/sha1.rb +27 -0
  17. data/lib/rubocop/cop/gem_fetcher.rb +37 -0
  18. data/lib/rubocop/cop/in_batches.rb +18 -0
  19. data/lib/rubocop/cop/internal_affairs/deprecate_cop_helper.rb +42 -0
  20. data/lib/rubocop/cop/line_break_after_guard_clauses.rb +101 -0
  21. data/lib/rubocop/cop/line_break_around_conditional_block.rb +127 -0
  22. data/lib/rubocop/cop/migration/update_large_table.rb +61 -0
  23. data/lib/rubocop/cop/performance/rubyzip.rb +36 -0
  24. data/lib/rubocop/cop/polymorphic_associations.rb +25 -0
  25. data/lib/rubocop/cop/rails/include_url_helper.rb +28 -0
  26. data/lib/rubocop/cop/redirect_with_status.rb +46 -0
  27. data/lib/rubocop/cop/rspec/base.rb +12 -0
  28. data/lib/rubocop/cop/rspec/empty_line_after_let_block.rb +61 -0
  29. data/lib/rubocop/cop/rspec/empty_line_after_shared_example.rb +63 -0
  30. data/lib/rubocop/cop/rspec/example_starting_character.rb +122 -0
  31. data/lib/rubocop/cop/rspec/have_link_parameters.rb +45 -0
  32. data/lib/rubocop/cop/rspec/single_line_hook.rb +43 -0
  33. data/lib/rubocop/cop/rspec/verbose_include_metadata.rb +73 -0
  34. data/lib/rubocop/cop/style/hash_transformation.rb +81 -0
  35. data/lib/rubocop/cop/style/open_struct_use.rb +40 -0
  36. data/lib/rubocop/cop/without_reactive_cache.rb +16 -0
  37. data/rubocop-default.yml +1 -0
  38. data/rubocop-fips.yml +15 -0
  39. data/rubocop-layout.yml +1 -1
  40. data/rubocop-rspec.yml +13 -5
  41. metadata +44 -47
  42. data/lib/gitlab/styles/rubocop/cop/active_record_dependent.rb +0 -36
  43. data/lib/gitlab/styles/rubocop/cop/active_record_serialize.rb +0 -24
  44. data/lib/gitlab/styles/rubocop/cop/avoid_return_from_blocks.rb +0 -81
  45. data/lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb +0 -84
  46. data/lib/gitlab/styles/rubocop/cop/custom_error_class.rb +0 -73
  47. data/lib/gitlab/styles/rubocop/cop/gem_fetcher.rb +0 -41
  48. data/lib/gitlab/styles/rubocop/cop/in_batches.rb +0 -22
  49. data/lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb +0 -43
  50. data/lib/gitlab/styles/rubocop/cop/line_break_after_guard_clauses.rb +0 -104
  51. data/lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb +0 -132
  52. data/lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb +0 -64
  53. data/lib/gitlab/styles/rubocop/cop/performance/rubyzip.rb +0 -39
  54. data/lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb +0 -29
  55. data/lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb +0 -31
  56. data/lib/gitlab/styles/rubocop/cop/redirect_with_status.rb +0 -50
  57. data/lib/gitlab/styles/rubocop/cop/rspec/base.rb +0 -18
  58. data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb +0 -51
  59. data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_let_block.rb +0 -65
  60. data/lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_shared_example.rb +0 -65
  61. data/lib/gitlab/styles/rubocop/cop/rspec/example_starting_character.rb +0 -124
  62. data/lib/gitlab/styles/rubocop/cop/rspec/have_link_parameters.rb +0 -48
  63. data/lib/gitlab/styles/rubocop/cop/rspec/single_line_hook.rb +0 -45
  64. data/lib/gitlab/styles/rubocop/cop/rspec/verbose_include_metadata.rb +0 -75
  65. data/lib/gitlab/styles/rubocop/cop/style/hash_transformation.rb +0 -87
  66. data/lib/gitlab/styles/rubocop/cop/style/open_struct_use.rb +0 -43
  67. data/lib/gitlab/styles/rubocop/cop/without_reactive_cache.rb +0 -20
  68. data/lib/gitlab/styles/rubocop/rspec/helpers.rb +0 -18
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gitlab
4
- module Styles
5
- module Rubocop
6
- module Cop
7
- module Style
8
- # This cop flags uses of OpenStruct, as it is now officially discouraged
9
- # to be used for performance, version compatibility, and potential security issues.
10
- #
11
- # See also:
12
- # - https://rubyreferences.github.io/rubychanges/3.0.html#standard-library
13
- # - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
14
- # - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67855
15
- class OpenStructUse < RuboCop::Cop::Cop
16
- MSG = 'Avoid using `OpenStruct`. It is officially discouraged. ' \
17
- 'Replace it with `Struct`, `Hash`, or RSpec doubles. ' \
18
- 'See https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats'
19
-
20
- def_node_matcher :uses_open_struct?, <<-PATTERN
21
- (const {nil? (cbase)} :OpenStruct)
22
- PATTERN
23
-
24
- def on_const(node)
25
- return unless uses_open_struct?(node)
26
- return if custom_class_or_module_definition?(node)
27
-
28
- add_offense(node)
29
- end
30
-
31
- private
32
-
33
- def custom_class_or_module_definition?(node)
34
- parent = node.parent
35
-
36
- (parent.class_type? || parent.module_type?) && node.left_siblings.empty?
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gitlab
4
- module Styles
5
- module Rubocop
6
- module Cop
7
- # Cop that prevents the use of `without_reactive_cache`
8
- class WithoutReactiveCache < RuboCop::Cop::Cop
9
- MSG = 'without_reactive_cache is for debugging purposes only. Please use with_reactive_cache.'
10
-
11
- def on_send(node)
12
- return unless node.children[1] == :without_reactive_cache
13
-
14
- add_offense(node, location: :selector)
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubocop-rspec'
4
-
5
- module Gitlab
6
- module Styles
7
- module Rubocop
8
- module Rspec
9
- module Helpers
10
- include RuboCop::RSpec::Language
11
-
12
- LET_IT_BE_HELPERS = SelectorSet.new(%i[let_it_be let_it_be_with_refind let_it_be_with_reload])
13
- LET = LET_IT_BE_HELPERS + RuboCop::RSpec::Language::Helpers::ALL
14
- end
15
- end
16
- end
17
- end
18
- end