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

Zero return status code when all errors & warnings have been muted - close #933 #934

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions console/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2544,8 +2544,8 @@ int main( int argc, char** argv )
}
}

contentErrors += tidyErrorCount( tdoc );
contentWarnings += tidyWarningCount( tdoc );
contentErrors += tidyErrorCount( tdoc ) - tidyMutedErrorCount( tdoc );
contentWarnings += tidyWarningCount( tdoc ) - tidyMutedWarningCount( tdoc );
accessWarnings += tidyAccessWarningCount( tdoc );

--argc;
Expand Down
12 changes: 12 additions & 0 deletions include/tidy.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,24 @@ TIDY_EXPORT Bool TIDY_CALL tidyDetectedGenericXml( TidyDoc tdoc );
*/
TIDY_EXPORT uint TIDY_CALL tidyErrorCount( TidyDoc tdoc );

/** Indicates the number of error messages muted, that won't be output.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of muted error messages.
*/
TIDY_EXPORT uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc );

/** Indicates the number of TidyWarning messages that were generated.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of TidyWarning messages that were generated.
*/
TIDY_EXPORT uint TIDY_CALL tidyWarningCount( TidyDoc tdoc );

/** Indicates the number of warning messages muted, that won't be output.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of muted warning messages.
*/
TIDY_EXPORT uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc );

/** Indicates the number of TidyAccess messages that were generated.
** @param tdoc An instance of a TidyDoc to query.
** @result Returns the number of TidyAccess messages that were generated.
Expand Down
4 changes: 4 additions & 0 deletions src/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ static void messageOut( TidyMessageImpl *message )
break;
case TidyWarning:
doc->warnings++;
if ( message->muted )
doc->mutedWarningCount++;
break;
case TidyConfig:
doc->optionErrors++;
Expand All @@ -142,6 +144,8 @@ static void messageOut( TidyMessageImpl *message )
break;
case TidyError:
doc->errors++;
if ( message->muted )
doc->mutedErrorCount++;
break;
case TidyBadDocument:
doc->docErrors++;
Expand Down
2 changes: 2 additions & 0 deletions src/tidy-int.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ struct _TidyDocImpl
/* Parse + Repair Results */
uint optionErrors;
uint errors;
uint mutedErrorCount;
uint warnings;
uint mutedWarningCount;
uint accessErrors;
uint infoMessages;
uint docErrors;
Expand Down
16 changes: 16 additions & 0 deletions src/tidylib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,14 @@ uint TIDY_CALL tidyErrorCount( TidyDoc tdoc )
count = impl->errors;
return count;
}
uint TIDY_CALL tidyMutedErrorCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
uint count = 0xFFFFFFFF;
if ( impl )
count = impl->mutedErrorCount;
return count;
}
uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
Expand All @@ -1052,6 +1060,14 @@ uint TIDY_CALL tidyWarningCount( TidyDoc tdoc )
count = impl->warnings;
return count;
}
uint TIDY_CALL tidyMutedWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
uint count = 0xFFFFFFFF;
if ( impl )
count = impl->mutedWarningCount;
return count;
}
uint TIDY_CALL tidyAccessWarningCount( TidyDoc tdoc )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
Expand Down