summaryrefslogtreecommitdiff
path: root/tooling/danger/merge_request_linter.rb
blob: ddeb9cc2981b9334fd59efd057d83a3313c2fc3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

require_relative 'base_linter'

module Tooling
  module Danger
    class MergeRequestLinter < BaseLinter
      alias_method :lint, :lint_subject

      def self.subject_description
        'merge request title'
      end

      def self.mr_run_options_regex
        [
          'RUN AS-IF-FOSS',
          'UPDATE CACHE',
          'RUN ALL RSPEC',
          'SKIP RSPEC FAIL-FAST'
        ].join('|')
      end

      private

      def subject
        super.gsub(/\[?(#{self.class.mr_run_options_regex})\]?/, '').strip
      end
    end
  end
end