summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-05-03 05:41:47 -0700
committerStan Hu <stanhu@gmail.com>2019-05-03 05:44:46 -0700
commita8cbec49a09fc82f5d6b0a74f06858b667f39a56 (patch)
tree433fa13eae164f0c8b69be2aba27d2d533d981a5 /rubocop
parent9f8123d935679582ac4f1487e1dcb559863372cb (diff)
downloadgitlab-ce-a8cbec49a09fc82f5d6b0a74f06858b667f39a56.tar.gz
Cache current working directory to speed up Rubocopsh-cache-rubocop-cwd
This saves thousands of getcwd() system calls and improves the performance of running Rubocop, which is also used by HAML linting. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61383
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/qa_helpers.rb2
-rw-r--r--rubocop/spec_helpers.rb6
2 files changed, 5 insertions, 3 deletions
diff --git a/rubocop/qa_helpers.rb b/rubocop/qa_helpers.rb
index f4adf7f4e9f..95875d64727 100644
--- a/rubocop/qa_helpers.rb
+++ b/rubocop/qa_helpers.rb
@@ -5,7 +5,7 @@ module RuboCop
def in_qa_file?(node)
path = node.location.expression.source_buffer.name
- path.start_with?(File.join(Dir.pwd, 'qa'))
+ path.start_with?(File.join(RuboCop::PathUtil.pwd, 'qa'))
end
end
end
diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb
index 63c1b975a65..ecd77c4351d 100644
--- a/rubocop/spec_helpers.rb
+++ b/rubocop/spec_helpers.rb
@@ -6,14 +6,16 @@ module RuboCop
# 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(Dir.pwd, 'spec'), File.join(Dir.pwd, 'ee', 'spec'))
+ path.start_with?(File.join(pwd, 'spec'), File.join(pwd, 'ee', 'spec'))
end
def migration_directories
@migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map do |dir|
- [File.join(Dir.pwd, dir), File.join(Dir.pwd, 'ee', dir)]
+ pwd = RuboCop::PathUtil.pwd
+ [File.join(pwd, dir), File.join(pwd, 'ee', dir)]
end.flatten
end