<commit_before>package org.shipkit.internal.notes.format;

import org.shipkit.internal.util.MultiMap;
import org.shipkit.internal.notes.internal.DateFormat;
import org.shipkit.internal.notes.model.*;

import java.text.MessageFormat;
import java.util.*;

/**
 * Generates release notes. The class is hard to maintain. If you have ideas on how to make it cleaner, go for it
 */
class DetailedFormatter implements MultiReleaseNotesFormatter {

    private static final int MAX_AUTHORS = 3;
    private static final String NO_LABEL = "Remaining changes";
    private final String introductionText;
    private final Map<String, String> labelMapping;
    private final String vcsCommitsLinkTemplate;
    private final String publicationRepository;
    private final Map<String, Contributor> contributors;
    private final boolean emphasizeVersion;

    DetailedFormatter(String introductionText, Map<String, String> labelMapping, String vcsCommitsLinkTemplate,
                      String publicationRepository, Map<String, Contributor> contributors, boolean emphasizeVersion) {
        this.introductionText = introductionText;
        this.labelMapping = labelMapping;
        this.vcsCommitsLinkTemplate = vcsCommitsLinkTemplate;
        this.publicationRepository = publicationRepository;
        this.contributors = contributors;
        this.emphasizeVersion = emphasizeVersion;
    }

    @Override
    public String formatReleaseNotes(Collection<ReleaseNotesData> data) {
        StringBuilder sb = new StringBuilder(introductionText == null ? "" : introductionText);
        if (data.isEmpty()) {
            sb.append("No release information.");
            return sb.toString();
        }

        for (ReleaseNotesData d : data) {
            sb.append(header(d.getVersion(), d.getDate(), emphasizeVersion));
            String vcsCommitsLink = MessageFormat.format(vcsCommitsLinkTemplate, d.getPreviousVersionVcsTag(), d.getVcsTag());
            sb.append(releaseSummary(d.getVersion(), d.getDate(), d.getContributions(), contributors, vcsCommitsLink, publicationRepository));

            if (!d.getContributions().getContributions().isEmpty()) {
                //no point printing any improvements information if there are no code changes
                sb.append(formatImprovements(d.getImprovements(), labelMapping));
            }

            sb.append("\n");
        }

        return sb.toString().trim();
    }

    static String header(String version, Date date, boolean emphasizeVersion){
        return emphasizeVersion ? headerHelper(version, date, "# ", "")
                : headerHelper(version, date, "**", "**");
    }

    private static String headerHelper(String version, Date date, String prefix, String postfix){
        return prefix + version + " (" + DateFormat.formatDate(date) + ")" + postfix + " - ";
    }

    static String releaseSummary(String version, Date date, ContributionSet contributions, Map<String, Contributor> contributors,
                                 String vcsCommitsLink, String publicationRepository) {
        return authorsSummary(contributions, contributors, vcsCommitsLink) +
                " - published to " + getBintrayBadge(version, publicationRepository) + "\n" +
                authorsSummaryAppendix(contributions, contributors);
    }

    private static String getBintrayBadge(String version, String publicationRepository) {
        final String markdownPrefix = "[![Bintray](";
        final String shieldsIoBadgeLink = "https://img.shields.io/badge/Bintray-" + version + "-green.svg";
        final String markdownPostfix = ")]";
        final String repositoryLinkWithVersion = publicationRepository + "/" + version;
        return markdownPrefix + shieldsIoBadgeLink + markdownPostfix + "(" + repositoryLinkWithVersion + ")";
    }
<commit_msg>More meaningful name for headerHelper method #190<commit_after>package org.shipkit.internal.notes.format;

import org.shipkit.internal.util.MultiMap;
import org.shipkit.internal.notes.internal.DateFormat;
import org.shipkit.internal.notes.model.*;

import java.text.MessageFormat;
import java.util.*;

/**
 * Generates release notes. The class is hard to maintain. If you have ideas on how to make it cleaner, go for it
 */
class DetailedFormatter implements MultiReleaseNotesFormatter {

    private static final int MAX_AUTHORS = 3;
    private static final String NO_LABEL = "Remaining changes";
    private final String introductionText;
    private final Map<String, String> labelMapping;
    private final String vcsCommitsLinkTemplate;
    private final String publicationRepository;
    private final Map<String, Contributor> contributors;
    private final boolean emphasizeVersion;

    DetailedFormatter(String introductionText, Map<String, String> labelMapping, String vcsCommitsLinkTemplate,
                      String publicationRepository, Map<String, Contributor> contributors, boolean emphasizeVersion) {
        this.introductionText = introductionText;
        this.labelMapping = labelMapping;
        this.vcsCommitsLinkTemplate = vcsCommitsLinkTemplate;
        this.publicationRepository = publicationRepository;
        this.contributors = contributors;
        this.emphasizeVersion = emphasizeVersion;
    }

    @Override
    public String formatReleaseNotes(Collection<ReleaseNotesData> data) {
        StringBuilder sb = new StringBuilder(introductionText == null ? "" : introductionText);
        if (data.isEmpty()) {
            sb.append("No release information.");
            return sb.toString();
        }

        for (ReleaseNotesData d : data) {
            sb.append(header(d.getVersion(), d.getDate(), emphasizeVersion));
            String vcsCommitsLink = MessageFormat.format(vcsCommitsLinkTemplate, d.getPreviousVersionVcsTag(), d.getVcsTag());
            sb.append(releaseSummary(d.getVersion(), d.getDate(), d.getContributions(), contributors, vcsCommitsLink, publicationRepository));

            if (!d.getContributions().getContributions().isEmpty()) {
                //no point printing any improvements information if there are no code changes
                sb.append(formatImprovements(d.getImprovements(), labelMapping));
            }

            sb.append("\n");
        }

        return sb.toString().trim();
    }

    static String header(String version, Date date, boolean emphasizeVersion){
        return emphasizeVersion ? buildHeader(version, date, "# ", "")
                : buildHeader(version, date, "**", "**");
    }

    private static String buildHeader(String version, Date date, String prefix, String postfix){
        return prefix + version + " (" + DateFormat.formatDate(date) + ")" + postfix + " - ";
    }

    static String releaseSummary(String version, Date date, ContributionSet contributions, Map<String, Contributor> contributors,
                                 String vcsCommitsLink, String publicationRepository) {
        return authorsSummary(contributions, contributors, vcsCommitsLink) +
                " - published to " + getBintrayBadge(version, publicationRepository) + "\n" +
                authorsSummaryAppendix(contributions, contributors);
    }

    private static String getBintrayBadge(String version, String publicationRepository) {
        final String markdownPrefix = "[![Bintray](";
        final String shieldsIoBadgeLink = "https://img.shields.io/badge/Bintray-" + version + "-green.svg";
        final String markdownPostfix = ")]";
        final String repositoryLinkWithVersion = publicationRepository + "/" + version;
        return markdownPrefix + shieldsIoBadgeLink + markdownPostfix + "(" + repositoryLinkWithVersion + ")";
    }

{'fraction_non_alphanumeric': 0.09611132787098452, 'fraction_numerical': 0.0006502796202367018, 'mean_word_length': 3.332394366197183, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3752598', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1850, 'n_words': 494}