gitlab-org--gitlab-foss/rubocop/qa_helpers.rb
Stan Hu a8cbec49a0 Cache current working directory to speed up Rubocop
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
2019-05-03 05:44:46 -07:00

11 lines
329 B
Ruby

module RuboCop
# Module containing helper methods for writing QA cops.
module QAHelpers
# Returns true if the given node originated from the qa/ directory.
def in_qa_file?(node)
path = node.location.expression.source_buffer.name
path.start_with?(File.join(RuboCop::PathUtil.pwd, 'qa'))
end
end
end