Sha256: f254d5899fff8032f3d3724100fcecc4decb21dc8b08463ee7f70912fb4572ff
Contents?: true
Size: 1.06 KB
Versions: 8
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Git module Lint module Analyzers # Analyzes commit trailer collaborator duplication. class CommitTrailerCollaboratorDuplication < Abstract def initialize commit, parser: Parsers::Trailers::Collaborator super commit @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
8 entries across 8 versions & 1 rubygems