Commit a3329daf authored by Tan Le's avatar Tan Le Committed by Rémy Coutable

Bump `gitlab-styles` to 3.2.0

This brings extended `Include` folders for Rails/FindBy cop.
parent 420f1907
...@@ -7,6 +7,10 @@ require: ...@@ -7,6 +7,10 @@ require:
- ./rubocop/rubocop - ./rubocop/rubocop
- rubocop-rspec - rubocop-rspec
inherit_mode:
merge:
- Include
AllCops: AllCops:
TargetRubyVersion: 2.6 TargetRubyVersion: 2.6
TargetRailsVersion: 5.0 TargetRailsVersion: 5.0
...@@ -161,6 +165,14 @@ Rails/ApplicationRecord: ...@@ -161,6 +165,14 @@ Rails/ApplicationRecord:
- ee/db/**/*.rb - ee/db/**/*.rb
- ee/spec/**/*.rb - ee/spec/**/*.rb
Rails/FindBy:
Enabled: true
Include:
- 'ee/app/**/*.rb'
- 'ee/lib/**/*.rb'
- 'spec/**/*.rb'
- 'ee/spec/**/*.rb'
# GitLab ################################################################### # GitLab ###################################################################
Gitlab/ModuleWithInstanceVariables: Gitlab/ModuleWithInstanceVariables:
......
...@@ -366,7 +366,7 @@ group :development, :test do ...@@ -366,7 +366,7 @@ group :development, :test do
gem 'spring', '~> 2.0.0' gem 'spring', '~> 2.0.0'
gem 'spring-commands-rspec', '~> 1.0.4' gem 'spring-commands-rspec', '~> 1.0.4'
gem 'gitlab-styles', '~> 3.1.0', require: false gem 'gitlab-styles', '~> 3.2.0', require: false
# Pin these dependencies, otherwise a new rule could break the CI pipelines # Pin these dependencies, otherwise a new rule could break the CI pipelines
gem 'rubocop', '~> 0.74.0' gem 'rubocop', '~> 0.74.0'
gem 'rubocop-performance', '~> 1.4.1' gem 'rubocop-performance', '~> 1.4.1'
......
...@@ -398,7 +398,7 @@ GEM ...@@ -398,7 +398,7 @@ GEM
gitlab-puma (>= 2.7, < 5) gitlab-puma (>= 2.7, < 5)
gitlab-sidekiq-fetcher (0.5.2) gitlab-sidekiq-fetcher (0.5.2)
sidekiq (~> 5) sidekiq (~> 5)
gitlab-styles (3.1.0) gitlab-styles (3.2.0)
rubocop (~> 0.74.0) rubocop (~> 0.74.0)
rubocop-gitlab-security (~> 0.1.0) rubocop-gitlab-security (~> 0.1.0)
rubocop-performance (~> 1.4.1) rubocop-performance (~> 1.4.1)
...@@ -1240,7 +1240,7 @@ DEPENDENCIES ...@@ -1240,7 +1240,7 @@ DEPENDENCIES
gitlab-puma (~> 4.3.3.gitlab.2) gitlab-puma (~> 4.3.3.gitlab.2)
gitlab-puma_worker_killer (~> 0.1.1.gitlab.1) gitlab-puma_worker_killer (~> 0.1.1.gitlab.1)
gitlab-sidekiq-fetcher (= 0.5.2) gitlab-sidekiq-fetcher (= 0.5.2)
gitlab-styles (~> 3.1.0) gitlab-styles (~> 3.2.0)
gitlab_chronic_duration (~> 0.10.6.2) gitlab_chronic_duration (~> 0.10.6.2)
gitlab_omniauth-ldap (~> 2.1.1) gitlab_omniauth-ldap (~> 2.1.1)
gon (~> 6.2) gon (~> 6.2)
......
...@@ -98,8 +98,7 @@ module DesignManagement ...@@ -98,8 +98,7 @@ module DesignManagement
strong_memoize(:most_recent_action) do strong_memoize(:most_recent_action) do
::DesignManagement::Action ::DesignManagement::Action
.most_recent.up_to_version(version) .most_recent.up_to_version(version)
.where(design: design) .find_by(design: design)
.first
end end
end end
......
...@@ -93,12 +93,15 @@ module Gitlab ...@@ -93,12 +93,15 @@ module Gitlab
# Commit.last_for_path(repo, 'master', 'Gemfile') # Commit.last_for_path(repo, 'master', 'Gemfile')
# #
def last_for_path(repo, ref, path = nil) def last_for_path(repo, ref, path = nil)
# rubocop: disable Rails/FindBy
# This is not where..first from ActiveRecord
where( where(
repo: repo, repo: repo,
ref: ref, ref: ref,
path: path, path: path,
limit: 1 limit: 1
).first ).first
# rubocop: enable Rails/FindBy
end end
# Get commits between two revspecs # Get commits between two revspecs
......
...@@ -38,9 +38,8 @@ module Gitlab ...@@ -38,9 +38,8 @@ module Gitlab
identities = ::Identity.arel_table identities = ::Identity.arel_table
User.select(:id) User.select(:id)
.joins(:identities).where(identities[:provider].eq(:github) .joins(:identities)
.and(identities[:extern_uid].eq(id))) .find_by(identities[:provider].eq(:github).and(identities[:extern_uid].eq(id)))
.first
.try(:id) .try(:id)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -39,7 +39,10 @@ describe Gitlab::Git::Tree, :seed_helper do ...@@ -39,7 +39,10 @@ describe Gitlab::Git::Tree, :seed_helper do
it { expect(dir.flat_path).to eq('encoding') } it { expect(dir.flat_path).to eq('encoding') }
context :subdir do context :subdir do
# rubocop: disable Rails/FindBy
# This is not ActiveRecord where..first
let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files').first } let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files').first }
# rubocop: enable Rails/FindBy
it { expect(subdir).to be_kind_of Gitlab::Git::Tree } it { expect(subdir).to be_kind_of Gitlab::Git::Tree }
it { expect(subdir.id).to eq('a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba') } it { expect(subdir.id).to eq('a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba') }
...@@ -50,7 +53,10 @@ describe Gitlab::Git::Tree, :seed_helper do ...@@ -50,7 +53,10 @@ describe Gitlab::Git::Tree, :seed_helper do
end end
context :subdir_file do context :subdir_file do
# rubocop: disable Rails/FindBy
# This is not ActiveRecord where..first
let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first } let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
# rubocop: enable Rails/FindBy
it { expect(subdir_file).to be_kind_of Gitlab::Git::Tree } it { expect(subdir_file).to be_kind_of Gitlab::Git::Tree }
it { expect(subdir_file.id).to eq('7e3e39ebb9b2bf433b4ad17313770fbe4051649c') } it { expect(subdir_file.id).to eq('7e3e39ebb9b2bf433b4ad17313770fbe4051649c') }
...@@ -63,7 +69,10 @@ describe Gitlab::Git::Tree, :seed_helper do ...@@ -63,7 +69,10 @@ describe Gitlab::Git::Tree, :seed_helper do
context :flat_path do context :flat_path do
let(:filename) { 'files/flat/path/correct/content.txt' } let(:filename) { 'files/flat/path/correct/content.txt' }
let(:oid) { create_file(filename) } let(:oid) { create_file(filename) }
# rubocop: disable Rails/FindBy
# This is not ActiveRecord where..first
let(:subdir_file) { Gitlab::Git::Tree.where(repository, oid, 'files/flat').first } let(:subdir_file) { Gitlab::Git::Tree.where(repository, oid, 'files/flat').first }
# rubocop: enable Rails/FindBy
let(:repository_rugged) { Rugged::Repository.new(File.join(SEED_STORAGE_PATH, TEST_REPO_PATH)) } let(:repository_rugged) { Rugged::Repository.new(File.join(SEED_STORAGE_PATH, TEST_REPO_PATH)) }
it { expect(subdir_file.flat_path).to eq('files/flat/path/correct') } it { expect(subdir_file.flat_path).to eq('files/flat/path/correct') }
......
...@@ -87,7 +87,7 @@ describe Ci::RetryPipelineService, '#execute' do ...@@ -87,7 +87,7 @@ describe Ci::RetryPipelineService, '#execute' do
it 'creates a new job for report job in this case' do it 'creates a new job for report job in this case' do
service.execute(pipeline) service.execute(pipeline)
expect(statuses.where(name: 'report 1').first).to be_retried expect(statuses.find_by(name: 'report 1', status: 'failed')).to be_retried
end end
end end
......
...@@ -5,7 +5,11 @@ require 'spec_helper' ...@@ -5,7 +5,11 @@ require 'spec_helper'
describe 'projects/tree/_tree_row' do describe 'projects/tree/_tree_row' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
# rubocop: disable Rails/FindBy
# This is not ActiveRecord where..first
let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first } let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
# rubocop: enable Rails/FindBy
before do before do
assign(:project, project) assign(:project, project)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment