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

TranslationCheck: should fire file started/finished when invoking errors #5057

Closed
rnveach opened this Issue Sep 2, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@rnveach
Member

rnveach commented Sep 2, 2017

Identified at #5043 (comment) this issue is slightly related to multi-file validation,

PR wishes to remove file started/finished calls in TranslationCheck.
See https://github.com/checkstyle/checkstyle/pull/5043/files

As pitest has proven these calls aren't needed because:
After the check destroy executes from the violation, we run fireAuditFinished

// It may also log!!!
fileSetChecks.forEach(FileSetCheck::destroy);
final int errorCount = counter.getCount();
fireAuditFinished();

and the XML logger clears out it's file cache if it hadn't before.
public void auditFinished(AuditEvent event) {
fileMessages.forEach(this::writeFileMessages);

So correct output is still here only because XML logger was extra careful in clearing out it's cache.

DefaultLogger doesn't care about files starting or finishing really.

public void fileStarted(AuditEvent event) {
// No need to implement this method in this class
}
@Override
public void fileFinished(AuditEvent event) {
infoWriter.flush();
}


To me, it is weird we fire errors without a start/end file, but this check is already 'special' as it is related to multi-file mode. We can't assume any new listener made will know this weird behavior.

I suggest we undo the changes to TranslationCheck in that PR and in #5397 , and modify XMLLogger to not clear out it's cache as fileFinished should be the only one doing this.
I assume removing the fileMessages.forEach(this::writeFileMessages); in XMLLogger's auditFinished would solve the pitest issue in this check and require the removed code to stay.

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Dec 30, 2017

Member

fix is merged

Member

romani commented Dec 30, 2017

fix is merged

@romani romani closed this Dec 30, 2017

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