summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Shea <connor.james.shea@gmail.com>2016-05-08 15:33:34 -0600
committerConnor Shea <connor.james.shea@gmail.com>2016-05-08 15:33:34 -0600
commit9cc0937b3a41caca89fa6722149248a8f7b0a447 (patch)
tree4e1fdfcb34d69da81b993f59742a35b6bccae413
parent44501820152083d231459223fe09b9d9641b7c1e (diff)
downloadgitlab-ce-9cc0937b3a41caca89fa6722149248a8f7b0a447.tar.gz
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.
-rw-r--r--.rubocop.yml2
-rw-r--r--app/models/ci/build.rb2
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--config/boot.rb2
-rw-r--r--config/initializers/carrierwave.rb2
-rw-r--r--lib/gitlab/backend/shell.rb2
-rw-r--r--lib/gitlab/redis.rb2
-rw-r--r--spec/config/mail_room_spec.rb2
-rw-r--r--spec/services/projects/create_service_spec.rb4
-rw-r--r--spec/services/projects/destroy_service_spec.rb8
10 files changed, 14 insertions, 14 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 9f179efa3ce..b49b60d6767 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -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:
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 4bc3a225e2c..073ec9dd89e 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -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
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 4175e1e5fba..365ccc90b40 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -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
diff --git a/config/boot.rb b/config/boot.rb
index 4489e58688c..f2830ae3166 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -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'])
diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb
index df28d30d750..0d278717d6e 100644
--- a/config/initializers/carrierwave.rb
+++ b/config/initializers/carrierwave.rb
@@ -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|
diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/backend/shell.rb
index 132f9cd1966..3e3986d6382 100644
--- a/lib/gitlab/backend/shell.rb
+++ b/lib/gitlab/backend/shell.rb
@@ -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
diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb
index 5c352c96de5..f7db7a6391c 100644
--- a/lib/gitlab/redis.rb
+++ b/lib/gitlab/redis.rb
@@ -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
diff --git a/spec/config/mail_room_spec.rb b/spec/config/mail_room_spec.rb
index 462afb24f08..6fad7e2b9e7 100644
--- a/spec/config/mail_room_spec.rb
+++ b/spec/config/mail_room_spec.rb
@@ -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"
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index e43903dbd3c..fd114359467 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -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
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index 1ec27077717..a5cb6f382e4 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -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)