<commit_before>package uk.co.automatictester.lightning.core.s3;

import uk.co.automatictester.lightning.core.ci.CIReporter;
import uk.co.automatictester.lightning.core.data.JMeterTransactions;
import uk.co.automatictester.lightning.core.s3.client.S3Client;
import uk.co.automatictester.lightning.core.s3.client.S3ClientFlyweightFactory;
import uk.co.automatictester.lightning.core.state.TestSet;

public class JenkinsS3Reporter extends CIReporter {

    private static S3Client s3Client;

    private JenkinsS3Reporter(String region, String bucket, TestSet testSet) {
        super(testSet);
        s3Client = S3ClientFlyweightFactory.getInstance(region).setBucket(bucket);
    }

    private JenkinsS3Reporter(String region, String bucket, JMeterTransactions jmeterTransactions) {
        super(jmeterTransactions);
        s3Client = S3ClientFlyweightFactory.getInstance(region).setBucket(bucket);
    }

    public static JenkinsS3Reporter fromTestSet(String region, String bucket, TestSet testSet) {
        return new JenkinsS3Reporter(region, bucket, testSet);
    }

    public static JenkinsS3Reporter fromJmeterTransactions(String region, String bucket, JMeterTransactions jmeterTransactions) {
        return new JenkinsS3Reporter(region, bucket, jmeterTransactions);
    }

    public String storeJenkinsBuildNameInS3() {
        if (testSet != null) {
            String jenkinsReportContent = getVerifySummary(testSet);
            return storeJenkinsReportToS3(jenkinsReportContent);
        } else {
            return storeJenkinsReportToS3(getReportSummary());
        }
    }

    private static String getVerifySummary(TestSet testSet) {
        int executed = testSet.getTestCount();
        int failed = testSet.getFailCount() + testSet.getErrorCount();
        return String.format("Tests executed: %s, failed: %s", executed, failed);
    }

    private String storeJenkinsReportToS3(String summary) {
        String escapedSummary = summary.replace(":", "\\:");
        String jenkinsReportTemplate = "#In Jenkins Build Name Setter Plugin, define build name as: ${BUILD_NUMBER} - ${PROPFILE,file=\"lightning-jenkins.properties\",property=\"result.string\"}\nresult.string=%s\n";
        String jenkinsReport = String.format(jenkinsReportTemplate, escapedSummary);
        return s3Client.putObject("output/lightning-jenkins.properties", jenkinsReport);
    }
}<commit_msg>Code cleanup<commit_after>package uk.co.automatictester.lightning.core.s3;

import uk.co.automatictester.lightning.core.ci.CIReporter;
import uk.co.automatictester.lightning.core.data.JMeterTransactions;
import uk.co.automatictester.lightning.core.s3.client.S3Client;
import uk.co.automatictester.lightning.core.s3.client.S3ClientFlyweightFactory;
import uk.co.automatictester.lightning.core.state.TestSet;

public class JenkinsS3Reporter extends CIReporter {

    private static S3Client s3Client;

    private JenkinsS3Reporter(String region, String bucket, TestSet testSet) {
        super(testSet);
        s3Client = S3ClientFlyweightFactory.getInstance(region).setBucket(bucket);
    }

    private JenkinsS3Reporter(String region, String bucket, JMeterTransactions jmeterTransactions) {
        super(jmeterTransactions);
        s3Client = S3ClientFlyweightFactory.getInstance(region).setBucket(bucket);
    }

    public static JenkinsS3Reporter fromTestSet(String region, String bucket, TestSet testSet) {
        return new JenkinsS3Reporter(region, bucket, testSet);
    }

    public static JenkinsS3Reporter fromJmeterTransactions(String region, String bucket, JMeterTransactions jmeterTransactions) {
        return new JenkinsS3Reporter(region, bucket, jmeterTransactions);
    }

    public String storeJenkinsBuildNameInS3() {
        String jenkinsReportContent;
        if (testSet != null) {
            jenkinsReportContent = getVerifySummary();
        } else {
            jenkinsReportContent = getReportSummary();
        }
        return storeJenkinsReportToS3(jenkinsReportContent);
    }

    private String getVerifySummary() {
        int executed = testSet.getTestCount();
        int failed = testSet.getFailCount() + testSet.getErrorCount();
        return String.format("Tests executed: %s, failed: %s", executed, failed);
    }

    private String storeJenkinsReportToS3(String summary) {
        String escapedSummary = summary.replace(":", "\\:");
        String jenkinsReportTemplate = "#In Jenkins Build Name Setter Plugin, define build name as: ${BUILD_NUMBER} - ${PROPFILE,file=\"lightning-jenkins.properties\",property=\"result.string\"}\nresult.string=%s\n";
        String jenkinsReport = String.format(jenkinsReportTemplate, escapedSummary);
        return s3Client.putObject("output/lightning-jenkins.properties", jenkinsReport);
    }
}
{'fraction_non_alphanumeric': 0.09539748953974896, 'fraction_numerical': 0.009414225941422594, 'mean_word_length': 4.163066954643629, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684488', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1354, 'n_words': 262}