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