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

Fix #3394: Validating Kdoc ending sequence #5622

Merged
merged 8 commits into from
Jan 15, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface LanguageInterface {
/**
* Returns whether the user is actively seeking a new audio position, that is, dragging the
* knob to a new position in the audio track.
* */
*/
fun getUserIsSeeking(): Boolean

/** Returns the position of the knob on the audio track. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface IntentFactoryShim {
/**
* Creates a [TopicActivity] intent for [PromotedStoryViewModel] and passes necessary string
* data.
* */
*/
fun createTopicPlayStoryActivityIntent(
context: Context,
internalProfileId: Int,
Expand All @@ -27,7 +27,7 @@ interface IntentFactoryShim {

/**
* Creates a [TopicActivity] intent which opens info-tab.
* */
*/
fun createTopicActivityIntent(
context: Context,
internalProfileId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ interface StoryFragmentScroller {
/**
* Scrolls smoothly (with animation) to the specified vertical pixel position in
* [StoryFragment].
* */
*/
fun smoothScrollToPosition(position: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface HintHandler {
* @param trackedWrongAnswerCount the count of wrong answers saved in the checkpoint
* @param helpIndex the cached state of hints/solution from the checkpoint
* @param state the restored pending state
* */
*/
suspend fun resumeHintsForSavedState(
trackedWrongAnswerCount: Int,
helpIndex: HelpIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ExceptionsController @Inject constructor(
* At first, it checks if the size of the store isn't exceeding [exceptionLogStorageCacheSize].
* If the limit is exceeded then the least recent exception is removed from the [exceptionLogStore].
* After this, the [exceptionLog] is added to the store.
* */
*/
private fun cacheExceptionLog(exceptionLog: ExceptionLog) {
exceptionLogStore.storeDataAsync(true) { oppiaExceptionLogs ->
val storeSize = oppiaExceptionLogs.exceptionLogList.size
Expand Down
4 changes: 2 additions & 2 deletions scripts/assets/file_content_validation_checks.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ file_content_checks {
}
file_content_checks {
file_path_regex: ".+?\\.kt$"
prohibited_content_regex: "\\*\\*/"
failure_message: "Badly formatted KDoc or block comment. KDocs and block comments should only end with \"*/\"."
prohibited_content_regex: "\\*(\\s*\\*|\\*)/"
failure_message: "Badly formatted KDoc or block comment. KDocs and block comments should only end with \"*/\". Multiple asterisks or whitespace between asterisks are not allowed."
exempted_file_name: "scripts/src/javatests/org/oppia/android/scripts/regex/RegexPatternValidationCheckTest.kt"
}
file_content_checks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ class RegexPatternValidationCheckTest {
"Badly formatted KDoc. Single-line KDocs should always end with exactly one space before the" +
" final \"*/\"."
private val badKdocOrBlockCommentShouldEndWithCorrectEnding =
"Badly formatted KDoc or block comment. KDocs and block comments should only end with \"*/\"."
"Badly formatted KDoc or block comment. KDocs and block comments should only" +
" end with \"*/\". Multiple asterisks or whitespace between asterisks are not allowed."
private val badKdocParamsAndPropertiesShouldHaveNameFollowing =
"Badly formatted KDoc param or property at-clause: the name of the parameter or property" +
" should immediately follow the at-clause without any additional linking with brackets."
Expand Down Expand Up @@ -2607,6 +2608,37 @@ class RegexPatternValidationCheckTest {
)
}

@Test
fun testFileContent_kdocWithInvalidEndingSequences_failsValidation() {
val prohibitedContent =
"""
/**
* Incorrect KDoc comment.
* */
/**
* Incorrect KDoc comment.
**/
/**
* Correct KDoc comment.
*/
""".trimIndent()
tempFolder.newFolder("testfiles", "app", "src", "main", "java", "org", "oppia", "android")
val stringFilePath = "app/src/main/java/org/oppia/android/TestPresenter.kt"
tempFolder.newFile("testfiles/$stringFilePath").writeText(prohibitedContent)

val exception = assertThrows<Exception>() { runScript() }

assertThat(exception).hasMessageThat().contains(REGEX_CHECK_FAILED_OUTPUT_INDICATOR)
assertThat(outContent.toString().trim())
.isEqualTo(
"""
$stringFilePath:3: $badKdocOrBlockCommentShouldEndWithCorrectEnding
$stringFilePath:6: $badKdocOrBlockCommentShouldEndWithCorrectEnding
$wikiReferenceNote
""".trimIndent()
)
}

@Test
fun testFileContent_singleLineKdocWithExtraSpacesBeforeEnd_fileContentIsNotCorrect() {
val prohibitedContent =
Expand Down
Loading