Sha256: 97727c07927ccdf2f5b945336e51f723e511de2eabf1642640bb390a00be6461
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Git module Lint module Analyzers class CommitTrailerCollaboratorDuplication < Abstract def self.defaults { enabled: true, severity: :error } end def initialize commit:, settings: self.class.defaults, parser: Parsers::Trailers::Collaborator super commit: commit, settings: settings @parser = parser @tally = build_tally end def valid? = affected_commit_trailers.empty? def issue return {} if valid? { hint: "Avoid duplication.", lines: affected_commit_trailers } end protected def invalid_line? line collaborator = parser.new line collaborator.match? && tally[line] != 1 end private attr_reader :parser, :tally def build_tally zeros = Hash.new { |new_hash, missing_key| new_hash[missing_key] = 0 } zeros.tap do |collection| commit.trailers.each { |line| collection[line] += 1 if parser.new(line).match? } end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems