# frozen_string_literal: true require_relative 'base_linter' emoji_checker_path = File.expand_path('emoji_checker', __dir__) defined?(Rails) ? require_dependency(emoji_checker_path) : require_relative(emoji_checker_path) module Gitlab module Danger class CommitLinter < BaseLinter MAX_CHANGED_FILES_IN_COMMIT = 3 MAX_CHANGED_LINES_IN_COMMIT = 30 SHORT_REFERENCE_REGEX = %r{([\w\-\/]+)?(? MAX_CHANGED_FILES_IN_COMMIT && lines_changed > MAX_CHANGED_LINES_IN_COMMIT end def separator message_parts[1] end def details message_parts[2]&.gsub(/^Signed-off-by.*$/, '') end def message_contains_text_emoji? emoji_checker.includes_text_emoji?(commit.message) end def message_contains_unicode_emoji? emoji_checker.includes_unicode_emoji?(commit.message) end def message_contains_short_reference? commit.message.match?(SHORT_REFERENCE_REGEX) end def emoji_checker @emoji_checker ||= Gitlab::Danger::EmojiChecker.new end end end end