Skip to content

Issue #14019: Covered pitest survivals for SuppressFilterElement#16840

Merged
romani merged 1 commit into
checkstyle:masterfrom
Atharv3221:pitestSolving6
Apr 23, 2025
Merged

Issue #14019: Covered pitest survivals for SuppressFilterElement#16840
romani merged 1 commit into
checkstyle:masterfrom
Atharv3221:pitestSolving6

Conversation

@Atharv3221

@Atharv3221 Atharv3221 commented Apr 12, 2025

Copy link
Copy Markdown
Contributor

Issue: #14019

Killing mutation with removing redundant code
Changes


    /**
     * Constructs a {@code SuppressFilterElement} using regular expressions
     * as {@code String}s. These are internally compiled into {@code Pattern}
     * objects and passed to the main constructor.
     *
     * @param files   regular expression for names of filtered files.
     * @param checks  regular expression for filtered check classes.
     * @param message regular expression for messages.
     * @param modId   the id
     * @param lines   lines CSV values and ranges for line number filtering.
     * @param columns columns CSV values and ranges for column number filtering.
     */
    public SuppressFilterElement(String files, String checks, String message,
                                 String modId, String lines, String columns) {
        this(toPattern(files), toPattern(checks), toPattern(message),
                modId, lines, columns);
    }

    /**
     * Converts a string into a compiled {@code Pattern}, or returns {@code null}
     * if the input is {@code null}.
     *
     * @param regex the regular expression as a string, may be {@code null}.
     * @return the compiled {@code Pattern}, or {@code null} if input is {@code null}.
     */
    private static Pattern toPattern(String regex) {
        final Pattern result;
        if (regex != null) {
            result = Pattern.compile(regex);
        }
        else {
            result = null;
        }
        return result;
    }

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Itey

final SuppressFilterElement filter2 =
new SuppressFilterElement(filePattern, checkPattern, messagePattern,
"module1", "1-10", "3,4");
assertWithMessage("filter, filter2")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good that you know what Filter elements are required to kill mutation.
But we do not allow pure unit testing anymore, sorry that there are bunch of bad examples of such testing.

Please convert such tests to have Input files with config for check+Filter to kill this mutation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to use this method

@Atharv3221 Atharv3221 force-pushed the pitestSolving6 branch 6 times, most recently from 94b5558 to 46614d8 Compare April 21, 2025 18:17
@Atharv3221

Atharv3221 commented Apr 22, 2025

Copy link
Copy Markdown
Contributor Author

@romani some ci checks are failing wrongly, I tried few times it gave me a vaild ci check failure + 1 ci incorrect check failure for 6 times

Similar thing happened on my last PR too for once

@Atharv3221 Atharv3221 requested a review from romani April 22, 2025 02:11
@Atharv3221 Atharv3221 force-pushed the pitestSolving6 branch 2 times, most recently from 8fe603a to b53cfea Compare April 22, 2025 02:35
@Atharv3221 Atharv3221 changed the title Issue #14019: Covered pitest survivals with tests for SuppressFilterElement Issue #14019: Covered pitest survivals for SuppressFilterElement Apr 22, 2025

@romani romani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants