2019-09-06 07:21:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class GitlabDanger
|
|
|
|
LOCAL_RULES ||= %w[
|
|
|
|
changes_size
|
|
|
|
documentation
|
|
|
|
frozen_string
|
|
|
|
duplicate_yarn_dependencies
|
|
|
|
prettier
|
|
|
|
eslint
|
2020-03-03 16:08:37 -05:00
|
|
|
karma
|
2019-09-06 07:21:53 -04:00
|
|
|
database
|
2019-09-16 08:06:26 -04:00
|
|
|
commit_messages
|
2020-09-29 11:10:08 -04:00
|
|
|
product_analytics
|
2020-04-30 11:09:46 -04:00
|
|
|
utility_css
|
2020-09-08 05:08:31 -04:00
|
|
|
pajamas
|
2020-11-30 07:09:21 -05:00
|
|
|
pipeline
|
2019-09-06 07:21:53 -04:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
CI_ONLY_RULES ||= %w[
|
|
|
|
metadata
|
|
|
|
changelog
|
|
|
|
specs
|
|
|
|
roulette
|
|
|
|
ce_ee_vue_templates
|
2020-06-26 11:08:45 -04:00
|
|
|
sidekiq_queues
|
2020-09-03 14:08:29 -04:00
|
|
|
specialization_labels
|
2020-10-16 14:09:04 -04:00
|
|
|
ci_templates
|
2019-09-06 07:21:53 -04:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
MESSAGE_PREFIX = '==>'.freeze
|
|
|
|
|
|
|
|
attr_reader :gitlab_danger_helper
|
|
|
|
|
|
|
|
def initialize(gitlab_danger_helper)
|
|
|
|
@gitlab_danger_helper = gitlab_danger_helper
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.local_warning_message
|
|
|
|
"#{MESSAGE_PREFIX} Only the following Danger rules can be run locally: #{LOCAL_RULES.join(', ')}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.success_message
|
|
|
|
"#{MESSAGE_PREFIX} No Danger rule violations!"
|
|
|
|
end
|
|
|
|
|
|
|
|
def rule_names
|
|
|
|
ci? ? LOCAL_RULES | CI_ONLY_RULES : LOCAL_RULES
|
|
|
|
end
|
|
|
|
|
|
|
|
def html_link(str)
|
|
|
|
self.ci? ? gitlab_danger_helper.html_link(str) : str
|
|
|
|
end
|
|
|
|
|
|
|
|
def ci?
|
|
|
|
!gitlab_danger_helper.nil?
|
|
|
|
end
|
|
|
|
end
|