Skip to content
Snippets Groups Projects
Commit 9cc0937b authored by Connor Shea's avatar Connor Shea
Browse files

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.
parent 44501820
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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:
Loading
Loading
Loading
Loading
@@ -238,7 +238,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
Loading
Loading
Loading
Loading
@@ -544,7 +544,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
Loading
Loading
Loading
Loading
@@ -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'])
Loading
Loading
@@ -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|
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment