Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JPlagOptions alternative constructors should be removed #1157

Open
brodmo opened this issue Jun 22, 2023 · 3 comments
Open

JPlagOptions alternative constructors should be removed #1157

brodmo opened this issue Jun 22, 2023 · 3 comments
Labels
enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change

Comments

@brodmo
Copy link
Contributor

brodmo commented Jun 22, 2023

At the moment, the JPlagOptions record has about 15 alternative constructors of the following form:

public JPlagOptions withLanguageOption(Language language) {
    return new JPlagOptions(language, minimumTokenMatch, submissionDirectories, oldSubmissionDirectories, baseCodeSubmissionDirectory,
            subdirectoryName, fileSuffixes, exclusionFileName, similarityMetric, similarityThreshold, maximumNumberOfComparisons,
            clusteringOptions, debugParser);
}

These constructors are obviously horrible in terms of maintainability. They are currently used for testing. They should be removed and some other way to construct options for the tests introduced (e.g. a builder). TestBase.java, which is not in good shape at the moment either, would also be simplified as a result.

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

Somewhat relatedly, the readability of the JPlagOptions field definitions could be greatly improved by utilizing this spotless feature:

public record JPlagOptions(
        // spotless:off
        Language language,
        Integer minimumTokenMatch,
        Set<File> submissionDirectories,
        Set<File> oldSubmissionDirectories,
        File baseCodeSubmissionDirectory,
        String subdirectoryName,
        List<String> fileSuffixes,
        String exclusionFileName,
        SimilarityMetric similarityMetric,
        double similarityThreshold,
        int maximumNumberOfComparisons,
        ClusteringOptions clusteringOptions,
        boolean debugParser
        // spotless:on
) {

rather than

public record JPlagOptions(Language language, Integer minimumTokenMatch, Set<File> submissionDirectories, Set<File> oldSubmissionDirectories,
        File baseCodeSubmissionDirectory, String subdirectoryName, List<String> fileSuffixes, String exclusionFileName,
        SimilarityMetric similarityMetric, double similarityThreshold, int maximumNumberOfComparisons, ClusteringOptions clusteringOptions,
        boolean debugParser) {

@brodmo
Copy link
Contributor Author

brodmo commented Jun 22, 2023

It's also possible to set eclipse's join_wrapped_lines setting to false, which would make spotless generally much more lenient in such cases

@tsaglam tsaglam added enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change labels Jul 17, 2023
@dfuchss
Copy link
Member

dfuchss commented Jul 26, 2023

Simply use // if you want to force line breaks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue/PR that involves features, improvements and other changes minor Minor issue/feature/contribution/change
Projects
None yet
Development

No branches or pull requests

3 participants