summaryrefslogtreecommitdiff
path: root/rubocop/spec_helpers.rb
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2019-08-26 12:24:25 +0000
committerSean McGivern <sean@gitlab.com>2019-08-26 12:24:25 +0000
commite101a26444f0f02df2c6301f13bc1f3e20781f8b (patch)
treed745ac1b2f29ae5eb656c5b597e00343d645c5d4 /rubocop/spec_helpers.rb
parent9e48f7079b648e427d24083af19c3f670cda3206 (diff)
downloadgitlab-ce-e101a26444f0f02df2c6301f13bc1f3e20781f8b.tar.gz
Utilize RuboCop's Include/Exclude config
Stop checking the file location programmatically.
Diffstat (limited to 'rubocop/spec_helpers.rb')
-rw-r--r--rubocop/spec_helpers.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb
deleted file mode 100644
index ecd77c4351d..00000000000
--- a/rubocop/spec_helpers.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module RuboCop
- module SpecHelpers
- SPEC_HELPERS = %w[fast_spec_helper.rb rails_helper.rb spec_helper.rb].freeze
- MIGRATION_SPEC_DIRECTORIES = ['spec/migrations', 'spec/lib/gitlab/background_migration'].freeze
-
- # Returns true if the given node originated from the spec directory.
- def in_spec?(node)
- path = node.location.expression.source_buffer.name
- pwd = RuboCop::PathUtil.pwd
-
- !SPEC_HELPERS.include?(File.basename(path)) &&
- path.start_with?(File.join(pwd, 'spec'), File.join(pwd, 'ee', 'spec'))
- end
-
- def migration_directories
- @migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map do |dir|
- pwd = RuboCop::PathUtil.pwd
- [File.join(pwd, dir), File.join(pwd, 'ee', dir)]
- end.flatten
- end
-
- # Returns true if the given node originated from a migration spec.
- def in_migration_spec?(node)
- path = node.location.expression.source_buffer.name
-
- in_spec?(node) &&
- path.start_with?(*migration_directories)
- end
- end
-end