2021-11-18 22:05:49 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
Dir[File.expand_path('specs/*_suggestion.rb', __dir__)].each { |file| require file }
|
2023-04-23 21:23:45 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
module Tooling
|
|
|
|
module Danger
|
|
|
|
module Specs
|
|
|
|
SPEC_FILES_REGEX = 'spec/'
|
|
|
|
EE_PREFIX = 'ee/'
|
2022-11-25 23:54:43 +05:30
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
SUGGESTIONS = [
|
|
|
|
FeatureCategorySuggestion,
|
|
|
|
MatchWithArraySuggestion,
|
|
|
|
ProjectFactorySuggestion
|
2022-11-25 23:54:43 +05:30
|
|
|
].freeze
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
def changed_specs_files(ee: :include)
|
|
|
|
changed_files = helper.all_changed_files
|
|
|
|
folder_prefix =
|
|
|
|
case ee
|
|
|
|
when :include
|
|
|
|
"(#{EE_PREFIX})?"
|
|
|
|
when :only
|
|
|
|
EE_PREFIX
|
|
|
|
when :exclude
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
changed_files.grep(%r{\A#{folder_prefix}#{SPEC_FILES_REGEX}})
|
|
|
|
end
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
def add_suggestions_for(filename)
|
|
|
|
SUGGESTIONS.each do |suggestion|
|
|
|
|
suggestion.new(filename, context: self).suggest
|
2023-03-17 16:20:25 +05:30
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|