Skip to content
代码片段 群组 项目
未验证 提交 baccf178 编辑于 作者: Peter Leitzen's avatar Peter Leitzen
浏览文件

Provide a single interface for adding suggestions

In order to add a suggestion you now need to:
1. Create a suggestion and specs
2. Add suggestion class to SUGGESTIONS constant
3. There is no step 3
上级 7b12b037
No related branches found
No related tags found
无相关合并请求
......@@ -55,7 +55,5 @@ if helper.changes.added.files.grep(%r{^(ee/)?spec/controllers/}).any?
end
specs.changed_specs_files.each do |filename|
specs.add_suggestions_for_match_with_array(filename)
specs.add_suggestions_for_project_factory_usage(filename)
specs.add_suggestions_for_feature_category(filename)
specs.add_suggestions_for(filename)
end
......@@ -94,6 +94,6 @@
expect(specs).to receive(:markdown).with(comment, file: filename, line: test_case[:number])
end
specs.add_suggestions_for_feature_category(filename)
specs.add_suggestions_for(filename)
end
end
......@@ -94,6 +94,6 @@
expect(specs).to receive(:markdown).with(comment, file: filename, line: test_case[:number])
end
specs.add_suggestions_for_match_with_array(filename)
specs.add_suggestions_for(filename)
end
end
......@@ -99,6 +99,6 @@
expect(specs).to receive(:markdown).with(comment, file: filename, line: test_case[:number])
end
specs.add_suggestions_for_project_factory_usage(filename)
specs.add_suggestions_for(filename)
end
end
# frozen_string_literal: true
require_relative 'specs/match_with_array_suggestion'
require_relative 'specs/project_factory_suggestion'
require_relative 'specs/feature_category_suggestion'
Dir[File.expand_path('specs/*_suggestion.rb', __dir__)].each { |file| require file }
module Tooling
module Danger
module Specs
include ::Tooling::Danger::Suggestor
SPEC_FILES_REGEX = 'spec/'
EE_PREFIX = 'ee/'
SUGGESTIONS = [
FeatureCategorySuggestion,
MatchWithArraySuggestion,
ProjectFactorySuggestion
].freeze
def changed_specs_files(ee: :include)
changed_files = helper.all_changed_files
folder_prefix =
......@@ -27,16 +29,10 @@ def changed_specs_files(ee: :include)
changed_files.grep(%r{\A#{folder_prefix}#{SPEC_FILES_REGEX}})
end
def add_suggestions_for_match_with_array(filename)
MatchWithArraySuggestion.new(filename, context: self).suggest
end
def add_suggestions_for_project_factory_usage(filename)
ProjectFactorySuggestion.new(filename, context: self).suggest
end
def add_suggestions_for_feature_category(filename)
FeatureCategorySuggestion.new(filename, context: self).suggest
def add_suggestions_for(filename)
SUGGESTIONS.each do |suggestion|
suggestion.new(filename, context: self).suggest
end
end
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册