<commit_before>package com.filestack.model.transform.base;

import com.filestack.model.FilestackClient;
import com.filestack.model.FileLink;
import com.filestack.model.Security;
import okhttp3.HttpUrl;
import com.filestack.util.FilestackService;
import com.filestack.util.Networking;

import java.util.ArrayList;

/**
 * Base class for file transformations and conversions.
 */
public class Transform {
    String apiKey;
    String source;
    Security security;

    ArrayList<TransformTask> tasks;

    FilestackService.Process processService;

    Transform(FilestackClient fsClient, String source) {
        this(fsClient, source, null);
    }

    Transform(FileLink fileLink) {
        this(null, null, fileLink);
    }

    Transform(FilestackClient fsClient, String source, FileLink fileLink) {
        if (fsClient != null) {
            this.apiKey = fsClient.getApiKey();
            this.source = source;
        } else {
            this.source = fileLink.getHandle();
        }

        this.tasks = new ArrayList<>();
        this.processService = Networking.getProcessService();

        Security security = fsClient != null ? fsClient.getSecurity() : fileLink.getSecurity();
        this.security = security;
        if (security != null) {
            TransformTask securityTask = new TransformTask("security");
            securityTask.addOption("policy", security.getPolicy());
            securityTask.addOption("signature", security.getSignature());
            this.tasks.add(securityTask);
        }
    }

    /**
     * Build tasks into single string to insert into request.
     */
    protected String getTasksString() {
        if (tasks.size() == 0)
            return "";

        StringBuilder stringBuilder = new StringBuilder();
        for (TransformTask task : tasks)
            stringBuilder.append(task.toString()).append('/');
        stringBuilder.deleteCharAt(stringBuilder.length()-1);
        return stringBuilder.toString();
    }

    public String url() {
        String tasksString = getTasksString();
        HttpUrl httpUrl;

        if (apiKey != null)
            httpUrl = processService.getExternal(apiKey, tasksString, source).request().url();
        else
            httpUrl = processService.get(tasksString, source).request().url();

        // When forming the request we add a / between tasks, then add that entire string as a path variable
        // Because it's added as a single path variable, the / is URL encoded
        // That's a little confusing so we're replacing "%2F" with "/" for a more expected URL
        return httpUrl.toString().replace("%2F", "/");
    }
}
<commit_msg>Fix linter warnings for Transform<commit_after>package com.filestack.model.transform.base;

import com.filestack.model.FileLink;
import com.filestack.model.FilestackClient;
import com.filestack.model.Security;
import com.filestack.util.FilestackService;
import com.filestack.util.Networking;
import java.util.ArrayList;
import okhttp3.HttpUrl;

/** Base class for file transformations and conversions. */
public class Transform {
    String apiKey;
    String source;
    Security security;

    ArrayList<TransformTask> tasks;

    FilestackService.Process processService;

    Transform(FilestackClient fsClient, String source) {
        this(fsClient, source, null);
    }

    Transform(FileLink fileLink) {
        this(null, null, fileLink);
    }

    Transform(FilestackClient fsClient, String source, FileLink fileLink) {
        if (fsClient != null) {
            this.apiKey = fsClient.getApiKey();
            this.source = source;
        } else {
            this.source = fileLink.getHandle();
        }

        this.tasks = new ArrayList<>();
        this.processService = Networking.getProcessService();

        Security security = fsClient != null ? fsClient.getSecurity() : fileLink.getSecurity();
        this.security = security;
        if (security != null) {
            TransformTask securityTask = new TransformTask("security");
            securityTask.addOption("policy", security.getPolicy());
            securityTask.addOption("signature", security.getSignature());
            this.tasks.add(securityTask);
        }
    }

    /** Format tasks into single string to insert into request. */
    protected String getTasksString() {
        if (tasks.size() == 0) {
            return "";
        }

        StringBuilder stringBuilder = new StringBuilder();
        for (TransformTask task : tasks) {
            stringBuilder.append(task.toString()).append('/');
        }
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        return stringBuilder.toString();
    }

    /**
     * Generates a URL of the transformation.
     * Includes the related {@link FileLink FileLink's} policy and signature.
     *
     * @return transformation URL
     */
    public String url() {
        String tasksString = getTasksString();
        HttpUrl httpUrl;

        if (apiKey != null) {
            httpUrl = processService.getExternal(apiKey, tasksString, source).request().url();
        } else {
            httpUrl = processService.get(tasksString, source).request().url();
        }

        // When building the request we add a / between tasks
        // Because that entire task string is added as a single path variable, the / is URL encoded
        // That's a little confusing so we're replacing "%2F" with "/" for a more expected URL
        return httpUrl.toString().replace("%2F", "/");
    }
}

{'fraction_non_alphanumeric': 0.1079607415485278, 'fraction_numerical': 0.0018175209014903672, 'mean_word_length': 2.620394736842105, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5935504', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1411, 'n_words': 382}