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-03-05 10:07:52 -05:00
|
|
|
telemetry
|
2020-04-30 11:09:46 -04:00
|
|
|
utility_css
|
2019-09-06 07:21:53 -04:00
|
|
|
].freeze
|
|
|
|
|
|
|
|
CI_ONLY_RULES ||= %w[
|
|
|
|
metadata
|
|
|
|
changelog
|
|
|
|
specs
|
|
|
|
roulette
|
|
|
|
ce_ee_vue_templates
|
|
|
|
].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
|