Commit 4735a753 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'deprecated-class-methods-cop' into 'master'

Enable the Rubocop DeprecatedClassMethods cop

This reports uses of `File.exists?` and `Dir.exists?`, which were both
deprecated in Ruby and will eventually be removed in favor of `.exist?`.
Also fixes all existing uses of the deprecated methods.

See merge request !4087
parents 5186f6e3 9cc0937b
...@@ -770,7 +770,7 @@ Lint/DefEndAlignment: ...@@ -770,7 +770,7 @@ Lint/DefEndAlignment:
# Check for deprecated class method calls. # Check for deprecated class method calls.
Lint/DeprecatedClassMethods: Lint/DeprecatedClassMethods:
Enabled: false Enabled: true
# Check for duplicate method definitions. # Check for duplicate method definitions.
Lint/DuplicateMethods: Lint/DuplicateMethods:
......
...@@ -205,7 +205,7 @@ module Ci ...@@ -205,7 +205,7 @@ module Ci
end end
def recreate_trace_dir def recreate_trace_dir
unless Dir.exists?(dir_to_trace) unless Dir.exist?(dir_to_trace)
FileUtils.mkdir_p(dir_to_trace) FileUtils.mkdir_p(dir_to_trace)
end end
end end
......
...@@ -514,7 +514,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -514,7 +514,7 @@ class MergeRequest < ActiveRecord::Base
end end
def ref_is_fetched? def ref_is_fetched?
File.exists?(File.join(project.repository.path_to_repo, ref_path)) File.exist?(File.join(project.repository.path_to_repo, ref_path))
end end
def ensure_ref_fetched def ensure_ref_fetched
......
...@@ -3,4 +3,4 @@ require 'rubygems' ...@@ -3,4 +3,4 @@ require 'rubygems'
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
...@@ -2,7 +2,7 @@ CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/ ...@@ -2,7 +2,7 @@ CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
aws_file = Rails.root.join('config', 'aws.yml') aws_file = Rails.root.join('config', 'aws.yml')
if File.exists?(aws_file) if File.exist?(aws_file)
AWS_CONFIG = YAML.load(File.read(aws_file))[Rails.env] AWS_CONFIG = YAML.load(File.read(aws_file))[Rails.env]
CarrierWave.configure do |config| CarrierWave.configure do |config|
......
...@@ -180,7 +180,7 @@ module Gitlab ...@@ -180,7 +180,7 @@ module Gitlab
# exists?('gitlab/cookies.git') # exists?('gitlab/cookies.git')
# #
def exists?(dir_name) def exists?(dir_name)
File.exists?(full_path(dir_name)) File.exist?(full_path(dir_name))
end end
protected protected
......
...@@ -42,7 +42,7 @@ module Gitlab ...@@ -42,7 +42,7 @@ module Gitlab
config_file = File.expand_path('../../../config/resque.yml', __FILE__) config_file = File.expand_path('../../../config/resque.yml', __FILE__)
@url = "redis://localhost:6379" @url = "redis://localhost:6379"
if File.exists?(config_file) if File.exist?(config_file)
@url =YAML.load_file(config_file)[rails_env] @url =YAML.load_file(config_file)[rails_env]
end end
end end
......
...@@ -43,7 +43,7 @@ describe "mail_room.yml" do ...@@ -43,7 +43,7 @@ describe "mail_room.yml" do
redis_config_file = Rails.root.join('config', 'resque.yml') redis_config_file = Rails.root.join('config', 'resque.yml')
redis_url = redis_url =
if File.exists?(redis_config_file) if File.exist?(redis_config_file)
YAML.load_file(redis_config_file)[Rails.env] YAML.load_file(redis_config_file)[Rails.env]
else else
"redis://localhost:6379" "redis://localhost:6379"
......
...@@ -64,7 +64,7 @@ describe Projects::CreateService, services: true do ...@@ -64,7 +64,7 @@ describe Projects::CreateService, services: true do
@path = ProjectWiki.new(@project, @user).send(:path_to_repo) @path = ProjectWiki.new(@project, @user).send(:path_to_repo)
end end
it { expect(File.exists?(@path)).to be_truthy } it { expect(File.exist?(@path)).to be_truthy }
end end
context 'wiki_enabled false does not create wiki repository directory' do context 'wiki_enabled false does not create wiki repository directory' do
...@@ -74,7 +74,7 @@ describe Projects::CreateService, services: true do ...@@ -74,7 +74,7 @@ describe Projects::CreateService, services: true do
@path = ProjectWiki.new(@project, @user).send(:path_to_repo) @path = ProjectWiki.new(@project, @user).send(:path_to_repo)
end end
it { expect(File.exists?(@path)).to be_falsey } it { expect(File.exist?(@path)).to be_falsey }
end end
end end
......
...@@ -13,8 +13,8 @@ describe Projects::DestroyService, services: true do ...@@ -13,8 +13,8 @@ describe Projects::DestroyService, services: true do
end end
it { expect(Project.all).not_to include(project) } it { expect(Project.all).not_to include(project) }
it { expect(Dir.exists?(path)).to be_falsey } it { expect(Dir.exist?(path)).to be_falsey }
it { expect(Dir.exists?(remove_path)).to be_falsey } it { expect(Dir.exist?(remove_path)).to be_falsey }
end end
context 'Sidekiq fake' do context 'Sidekiq fake' do
...@@ -24,8 +24,8 @@ describe Projects::DestroyService, services: true do ...@@ -24,8 +24,8 @@ describe Projects::DestroyService, services: true do
end end
it { expect(Project.all).not_to include(project) } it { expect(Project.all).not_to include(project) }
it { expect(Dir.exists?(path)).to be_falsey } it { expect(Dir.exist?(path)).to be_falsey }
it { expect(Dir.exists?(remove_path)).to be_truthy } it { expect(Dir.exist?(remove_path)).to be_truthy }
end end
def destroy_project(project, user, params) def destroy_project(project, user, params)
......
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