You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#21441 converted RegexpOnFilenameCheckTest to verifyWithInlineConfigParser. A sweep of the whole test tree on current master shows the same problem remains in many other tests.
Per @romani: any Check with "Header" in its name cannot use inlined config, so HeaderCheckTest, RegexpHeaderCheckTest and MultiFileRegexpHeaderCheckTest are excluded from everything below (they account for a further 65 old-style calls and 39 config-less inputs that should stay as they are).
Old style verify(...) usage
107 call sites across 31 test classes. (Excludes AbstractModuleTestSupport itself, Mockito's verify, IndentationCheckTest's own private verify helper, and the Header checks.) 49 test classes still build configs in Java via createModuleConfig/createRootConfig.
Test class
old-style verify calls
TranslationCheckTest
20
LineEndingCheckTest
16
OrderedPropertiesCheckTest
10
IndentationCheckTest
9
RegexpMultilineCheckTest
5
EmptyLineSeparatorCheckTest
5
UniquePropertiesCheckTest
4
TreeWalkerTest
4
NewlineAtEndOfFileCheckTest
3
and 22 more classes with 1-2 calls each: UnusedImports, UncommentedMain, SuppressWithPlainTextCommentFilter, PackageDeclaration, OuterTypeFilename, NoCodeInFile, JavadocLinkFirstOccurrence, Checker, RedundantImport, OneTopLevelClass, OneStatementPerLine, NonEmptyAtclauseDescription, MutableException, MultipleStringLiterals, LineLength, InnerTypeLast, IllegalType, IllegalInstantiation, EqualsHashCode, CustomImportOrder, AnnotationUseStyle, AllChecksTest.
Bad inputs
80 input files used by those old-style tests have no embedded config. Repo-wide, 292 input files under checks/ + filters/ (excluding checks/header/) do not start with a config block, out of 3916 Input* files scanned; the remaining config-less files are grammar/parser/main inputs that legitimately have none.
Good candidates for standalone issues, in increasing effort: LineEndingCheckTest (16). NoCodeInFileCheckTest and UniquePropertiesCheckTest were previously listed here too - both were wrong, see "Known exceptions" below.
TranslationCheckTest, OrderedPropertiesCheckTest - operate on property files; an inlined header is not possible for these, so they stay old-style in full.
UniquePropertiesCheckTest - same family as the two above (all three are in InlineConfigParser.PERMANENT_SUPPRESSED_CHECKS, "Inlined config is not supported for non java files"), so it stays old-style in full too. Not one of @romani's original examples, but the same underlying restriction applies.
IndentationCheckTest - has its own way of handling the header check and trailing comments, so it needs special attention rather than a mechanical conversion.
NewlineAtEndOfFileCheckTest - one method needs to stay old-style since it operates on an empty file; the rest should be updated.
NoCodeInFileCheckTest - both remaining old-style methods (testBlank, testSingleLineComment) test a file with no text at all and a file containing only a single-line comment, respectively. The inline config format requires a /* ... */ block, which would either add text to the "no text" case or turn the "single-line comment only" case into a multi-line comment (already covered by testMultiLineComment) or a mix of both (already covered by testBothSingleLineAndMultiLineComment). Neither can be embedded without either breaking or duplicating what the test is meant to cover, so this class is not actually convertible - despite being listed as a "good candidate" above until this correction.
PackageDeclarationCheckTest#testEmptyFile (:151) - same "operates on a genuinely empty file" restriction as NewlineAtEndOfFileCheckTest and NoCodeInFileCheckTest#testBlank; it was wrongly listed in "Easiest wins" above. :201 (testBeginTreeClear) was convertible and is done in Issue #21480: Convert PackageDeclarationCheckTest#testBeginTreeClear to embedded config #21482, using the existing two-file verifyWithInlineConfigParser(filePath1, filePath2, expectedFromFile1, expectedFromFile2) overload since the two inputs already carried configs from earlier conversions.
Given how many "empty/comment-only file" cases have turned up (3 so far, across 3 different classes), it's worth treating "input has no meaningful non-comment content to embed a config into" as its own standing exception category, not a one-off per class.
Blockers that need a decision
Multi-file tests with 3+ inputs (EqualsHashCodeCheckTest, IllegalTypeCheckTest) - verifyWithInlineConfigParser only has 1-file and 2-file overloads today, so these need a new overload.
Tests that generate inputs at runtime in a temp dir (RegexpMultilineCheckTest) - no file on disk to embed a config into.
AnnotationUseStyleCheckTest#testNonTrimmedInput deliberately passes untrimmed property values (" ignore "); the inline config parser trims, so this one cannot be expressed as an embedded config.
Should these be filed as separate issues per test class, or tracked here as an umbrella?
Moved from #21441 (comment) at @romani's request.
#21441 converted
RegexpOnFilenameCheckTesttoverifyWithInlineConfigParser. A sweep of the whole test tree on currentmastershows the same problem remains in many other tests.Per @romani: any Check with "Header" in its name cannot use inlined config, so
HeaderCheckTest,RegexpHeaderCheckTestandMultiFileRegexpHeaderCheckTestare excluded from everything below (they account for a further 65 old-style calls and 39 config-less inputs that should stay as they are).Old style
verify(...)usage107 call sites across 31 test classes. (Excludes
AbstractModuleTestSupportitself, Mockito'sverify,IndentationCheckTest's own privateverifyhelper, and the Header checks.) 49 test classes still build configs in Java viacreateModuleConfig/createRootConfig.verifycallsand 22 more classes with 1-2 calls each: UnusedImports, UncommentedMain, SuppressWithPlainTextCommentFilter, PackageDeclaration, OuterTypeFilename, NoCodeInFile, JavadocLinkFirstOccurrence, Checker, RedundantImport, OneTopLevelClass, OneStatementPerLine, NonEmptyAtclauseDescription, MutableException, MultipleStringLiterals, LineLength, InnerTypeLast, IllegalType, IllegalInstantiation, EqualsHashCode, CustomImportOrder, AnnotationUseStyle, AllChecksTest.
Bad inputs
80 input files used by those old-style tests have no embedded config. Repo-wide, 292 input files under
checks/+filters/(excludingchecks/header/) do not start with a config block, out of 3916Input*files scanned; the remaining config-less files are grammar/parser/maininputs that legitimately have none.Per test class: Translation (33), OrderedProperties (10), LineEnding (10), Indentation (5), UniqueProperties (4), EmptyLineSeparator (4), TreeWalker (3), NewlineAtEndOfFile (3), NoCodeInFile (2), JavadocLinkFirstOccurrence (2), SuppressWithPlainTextCommentFilter (1), PackageDeclaration (1), NonEmptyAtclauseDescription (1), IllegalType (1).
Worst input directories overall:
checks/indentation/indentation(157),checks/imports/importcontrol(26),filters/suppressionsloader(17),filters/suppressionxpathfilter(15),filters/suppressionfilter(10),checks/orderedproperties(10),checks/lineending(10).Easiest wins first
18 call sites where the input already carries an embedded config, so only the test method needs changing, no input edits at all:
TreeWalkerTest:723checks/annotation/AnnotationUseStyleCheckTest:102checks/coding/EqualsHashCodeCheckTest:95checks/coding/IllegalTypeCheckTest:293checks/coding/MultipleStringLiteralsCheckTest:87checks/coding/OneStatementPerLineCheckTest:164checks/coding/PackageDeclarationCheckTest:201(:151moved to "Known exceptions" - see below;:201done in Issue #21480: Convert PackageDeclarationCheckTest#testBeginTreeClear to embedded config #21482)checks/design/InnerTypeLastCheckTest:95checks/design/MutableExceptionCheckTest:86checks/imports/CustomImportOrderCheckTest:381checks/imports/RedundantImportCheckTest:74checks/imports/UnusedImportsCheckTest:64checks/indentation/IndentationCheckTest:4533checks/javadoc/JavadocLinkFirstOccurrenceCheckTest:92checks/sizes/LineLengthCheckTest:162checks/whitespace/EmptyLineSeparatorCheckTest:122,:384Good candidates for standalone issues, in increasing effort:
LineEndingCheckTest(16).NoCodeInFileCheckTestandUniquePropertiesCheckTestwere previously listed here too - both were wrong, see "Known exceptions" below.Known exceptions (per @romani unless noted)
TranslationCheckTest,OrderedPropertiesCheckTest- operate on property files; an inlined header is not possible for these, so they stay old-style in full.UniquePropertiesCheckTest- same family as the two above (all three are inInlineConfigParser.PERMANENT_SUPPRESSED_CHECKS, "Inlined config is not supported for non java files"), so it stays old-style in full too. Not one of @romani's original examples, but the same underlying restriction applies.IndentationCheckTest- has its own way of handling the header check and trailing comments, so it needs special attention rather than a mechanical conversion.NewlineAtEndOfFileCheckTest- one method needs to stay old-style since it operates on an empty file; the rest should be updated.NoCodeInFileCheckTest- both remaining old-style methods (testBlank,testSingleLineComment) test a file with no text at all and a file containing only a single-line comment, respectively. The inline config format requires a/* ... */block, which would either add text to the "no text" case or turn the "single-line comment only" case into a multi-line comment (already covered bytestMultiLineComment) or a mix of both (already covered bytestBothSingleLineAndMultiLineComment). Neither can be embedded without either breaking or duplicating what the test is meant to cover, so this class is not actually convertible - despite being listed as a "good candidate" above until this correction.PackageDeclarationCheckTest#testEmptyFile(:151) - same "operates on a genuinely empty file" restriction asNewlineAtEndOfFileCheckTestandNoCodeInFileCheckTest#testBlank; it was wrongly listed in "Easiest wins" above.:201(testBeginTreeClear) was convertible and is done in Issue #21480: Convert PackageDeclarationCheckTest#testBeginTreeClear to embedded config #21482, using the existing two-fileverifyWithInlineConfigParser(filePath1, filePath2, expectedFromFile1, expectedFromFile2)overload since the two inputs already carried configs from earlier conversions.RegexpOnFilenameCheckTest#testWithFileWithoutParent(the singleverifyleft after Update RegexpOnFilenameCheckTest to use embedded configs #21441) needs aMockFileoverridinggetParent(), so it has to stay old-style too.Given how many "empty/comment-only file" cases have turned up (3 so far, across 3 different classes), it's worth treating "input has no meaningful non-comment content to embed a config into" as its own standing exception category, not a one-off per class.
Blockers that need a decision
EqualsHashCodeCheckTest,IllegalTypeCheckTest) -verifyWithInlineConfigParseronly has 1-file and 2-file overloads today, so these need a new overload.RegexpMultilineCheckTest) - no file on disk to embed a config into.AnnotationUseStyleCheckTest#testNonTrimmedInputdeliberately passes untrimmed property values (" ignore "); the inline config parser trims, so this one cannot be expressed as an embedded config.Should these be filed as separate issues per test class, or tracked here as an umbrella?
Good example of migration #21482