Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
990d5388
Commit
990d5388
authored
Aug 21, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow string in distinct_count cop
parent
a7d59ca0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
5 deletions
+10
-5
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+0
-2
rubocop/cop/usage_data/distinct_count_by_large_foreign_key.rb
...cop/cop/usage_data/distinct_count_by_large_foreign_key.rb
+1
-1
rubocop/rubocop-usage-data.yml
rubocop/rubocop-usage-data.yml
+1
-0
spec/rubocop/cop/usage_data/distinct_count_by_large_foreign_key_spec.rb
...op/usage_data/distinct_count_by_large_foreign_key_spec.rb
+8
-2
No files found.
ee/lib/ee/gitlab/usage_data.rb
View file @
990d5388
...
...
@@ -393,7 +393,6 @@ module EE
# rubocop:enable CodeReuse/ActiveRecord
# rubocop:disable CodeReuse/ActiveRecord
# rubocop: disable UsageData/DistinctCountByLargeForeignKey
def
projects_with_sectional_code_owner_rules
(
time_period
)
distinct_count
(
::
ApprovalMergeRequestRule
...
...
@@ -406,7 +405,6 @@ module EE
finish:
project_maximum_id
)
end
# rubocop: enable UsageData/DistinctCountByLargeForeignKey
# rubocop:enable CodeReuse/ActiveRecord
end
end
...
...
rubocop/cop/usage_data/distinct_count_by_large_foreign_key.rb
View file @
990d5388
...
...
@@ -31,7 +31,7 @@ module RuboCop
private
def
allowed_foreign_key?
(
key
)
key
.
type
==
:sym
&&
allowed_foreign_keys
.
include?
(
key
.
value
)
[
:sym
,
:str
].
include?
(
key
.
type
)
&&
allowed_foreign_keys
.
include?
(
key
.
value
.
to_sym
)
end
def
allowed_foreign_keys
...
...
rubocop/rubocop-usage-data.yml
View file @
990d5388
...
...
@@ -44,3 +44,4 @@ UsageData/DistinctCountByLargeForeignKey:
-
:project_id
-
:issue_id
-
:merge_request_id
-
:merge_requests.target_project_id
spec/rubocop/cop/usage_data/distinct_count_by_large_foreign_key_spec.rb
View file @
990d5388
...
...
@@ -10,7 +10,7 @@ require_relative '../../../../rubocop/cop/usage_data/distinct_count_by_large_for
RSpec
.
describe
RuboCop
::
Cop
::
UsageData
::
DistinctCountByLargeForeignKey
,
type: :rubocop
do
include
CopHelper
let
(
:allowed_foreign_keys
)
{
%i[author_id user_id
]
}
let
(
:allowed_foreign_keys
)
{
[
:author_id
,
:user_id
,
:'merge_requests.target_project_id'
]
}
let
(
:config
)
do
RuboCop
::
Config
.
new
(
'UsageData/DistinctCountByLargeForeignKey'
=>
{
...
...
@@ -29,10 +29,16 @@ RSpec.describe RuboCop::Cop::UsageData::DistinctCountByLargeForeignKey, type: :r
end
context
'when calling by allowed key'
do
it
'does not register an offence'
do
it
'does not register an offence
with symbol
'
do
inspect_source
(
'distinct_count(Issue, :author_id)'
)
expect
(
cop
.
offenses
).
to
be_empty
end
it
'does not register an offence with string'
do
inspect_source
(
"distinct_count(Issue, 'merge_requests.target_project_id')"
)
expect
(
cop
.
offenses
).
to
be_empty
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment