# frozen_string_literal: true require_relative "base_linter" require_relative "emoji_checker" module Gitlab module Dangerfiles class CommitLinter < BaseLinter MAX_CHANGED_FILES_IN_COMMIT = 3 MAX_CHANGED_LINES_IN_COMMIT = 30 # Issue, MR, Epic SHORT_REFERENCE_REGEX = %r{(\S*([\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? match_data = commit.message.match(SHORT_REFERENCE_REGEX) || commit.message.match(MS_SHORT_REFERENCE_REGEX) return false unless match_data # Any URL would include "//". This works for http/https/ftp etc. !match_data[1].include?("//") end def emoji_checker @emoji_checker ||= Gitlab::Dangerfiles::EmojiChecker.new end end end end