gitlab-styles 6.2.1 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb +31 -0
- data/lib/gitlab/styles/version.rb +1 -1
- data/rubocop-rails.yml +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdb4b922d729575676263e2cb9cf6f63b50be1d8b4205d96af7ecb6aaa2c4c84
|
4
|
+
data.tar.gz: 46a11af0a19079547b1d25e988e80d8271a5fe15fda707096662aee73a4cc9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df88cc8b9ea74b138c8768130b310d50d2204bed62e4648b292a8b0f058dad46335e23432564a546e0acc0ae9ef3c8a2487f4690f8e4ee2a73e6209665441746
|
7
|
+
data.tar.gz: 2d744fd1097268298c1073404bf84ddd4d65b28dbfa4b5bfad95857ea310734d24f93b81870e0c03454c26a2aa8de19470c7f75374e73db25ac0067a2665bebf
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../model_helpers'
|
4
|
+
|
5
|
+
module Gitlab
|
6
|
+
module Styles
|
7
|
+
module Rubocop
|
8
|
+
module Cop
|
9
|
+
module Rails
|
10
|
+
class IncludeUrlHelper < RuboCop::Cop::Cop
|
11
|
+
MSG = <<~MSG
|
12
|
+
Avoid including `ActionView::Helpers::UrlHelper`.
|
13
|
+
It adds/overrides ~40 methods while usually only one is needed.
|
14
|
+
Instead, use the `Gitlab::Routing.url_helpers`/`Application.routes.url_helpers`(outside of gitlab)
|
15
|
+
and `ActionController::Base.helpers.link_to`.
|
16
|
+
See https://gitlab.com/gitlab-org/gitlab/-/issues/340567.
|
17
|
+
MSG
|
18
|
+
|
19
|
+
def_node_matcher :include_url_helpers_node?, <<~PATTERN
|
20
|
+
(send nil? :include (const (const (const {nil? cbase} :ActionView) :Helpers) :UrlHelper))
|
21
|
+
PATTERN
|
22
|
+
|
23
|
+
def on_send(node)
|
24
|
+
add_offense(node) if include_url_helpers_node?(node)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/rubocop-rails.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
---
|
2
2
|
require:
|
3
3
|
- rubocop-rails
|
4
|
+
- ./lib/gitlab/styles/rubocop
|
4
5
|
|
5
6
|
# Enables Rails cops.
|
6
7
|
Rails:
|
@@ -186,3 +187,7 @@ Rails/WhereExists:
|
|
186
187
|
# https://docs.rubocop.org/rubocop-rails/2.8/cops_rails.html#railswherenot
|
187
188
|
Rails/WhereNot:
|
188
189
|
Enabled: true
|
190
|
+
|
191
|
+
# Bans the use of `include ActionView::Helpers::UrlHelper`.
|
192
|
+
Rails/IncludeUrlHelper:
|
193
|
+
Enabled: true
|
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.3.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
|
+
date: 2021-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/gitlab/styles/rubocop/cop/line_break_around_conditional_block.rb
|
165
165
|
- lib/gitlab/styles/rubocop/cop/migration/update_large_table.rb
|
166
166
|
- lib/gitlab/styles/rubocop/cop/polymorphic_associations.rb
|
167
|
+
- lib/gitlab/styles/rubocop/cop/rails/include_url_helper.rb
|
167
168
|
- lib/gitlab/styles/rubocop/cop/redirect_with_status.rb
|
168
169
|
- lib/gitlab/styles/rubocop/cop/rspec/base.rb
|
169
170
|
- lib/gitlab/styles/rubocop/cop/rspec/empty_line_after_final_let_it_be.rb
|