2019-09-06 07:21:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-01-20 07:11:06 -05:00
|
|
|
# rubocop:todo Gitlab/NamespacedClass
|
2019-09-06 07:21:53 -04:00
|
|
|
class GitlabDanger
|
|
|
|
LOCAL_RULES ||= %w[
|
|
|
|
changes_size
|
2021-01-26 13:09:30 -05:00
|
|
|
commit_messages
|
|
|
|
database
|
2019-09-06 07:21:53 -04:00
|
|
|
documentation
|
|
|
|
duplicate_yarn_dependencies
|
|
|
|
eslint
|
2020-03-03 16:08:37 -05:00
|
|
|
karma
|
2020-09-08 05:08:31 -04:00
|
|
|
pajamas
|
2020-11-30 07:09:21 -05:00
|
|
|
pipeline
|
2021-01-26 13:09:30 -05:00
|
|
|
prettier
|
|
|
|
product_intelligence
|
|
|
|
utility_css
|
2019-09-06 07:21:53 -04:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
CI_ONLY_RULES ||= %w[
|
2021-01-26 13:09:30 -05:00
|
|
|
ce_ee_vue_templates
|
2019-09-06 07:21:53 -04:00
|
|
|
changelog
|
2021-01-26 13:09:30 -05:00
|
|
|
ci_templates
|
|
|
|
metadata
|
|
|
|
feature_flag
|
2019-09-06 07:21:53 -04:00
|
|
|
roulette
|
2020-06-26 11:08:45 -04:00
|
|
|
sidekiq_queues
|
2020-09-03 14:08:29 -04:00
|
|
|
specialization_labels
|
2021-01-26 13:09:30 -05:00
|
|
|
specs
|
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
|