Skip to content

Conversation

@herbsee02
Copy link

Refactored the files org.catrobat.catroid.soundrecorder.RecordButton, org.catrobat.catroid.soundrecorder.SoundRecorder, and org.catrobat.catroid.soundrecorder.SoundRecorderActivity from Java to Kotlin. Created a Unit-Test for SoundRecorder in addition to existing Integration-Tests. Added Dependency for MockK and used it to fix the test in org.catrobat.catroid.test.formulaeditor.SensorHandlerTest.

https://catrobat.atlassian.net/browse/IDE-295

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

Copy link
Contributor

@Frajhamster Frajhamster left a comment

Choose a reason for hiding this comment

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

Looks great!

@reichli reichli added the Active Member Tickets that are assigned to members that are still currently active label Dec 25, 2025
@dorianpercic dorianpercic self-requested a review December 26, 2025 10:59
@dorianpercic
Copy link
Contributor

Rebased PR.

}

@Throws(IOException::class, RuntimeException::class)
fun start() {

Check warning

Code scanning / detekt

Restrict the number of throw statements in methods. Warning

Too many throw statements in the function start. The maximum number of allowed throw statements is 2.
recorder.start()
isRecording = true
} catch (e: IllegalStateException) {
throw e

Check warning

Code scanning / detekt

Do not rethrow a caught exception of the same type. Warning

Do not rethrow a caught exception of the same type.
isRecording = true
} catch (e: IllegalStateException) {
throw e
} catch (e: RuntimeException) {

Check warning

Code scanning / detekt

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
} catch (e: IllegalStateException) {
throw e
} catch (e: RuntimeException) {
throw e

Check warning

Code scanning / detekt

Do not rethrow a caught exception of the same type. Warning

Do not rethrow a caught exception of the same type.
} catch (_: RuntimeException) {
Log.d(
TAG, ("Note that a RuntimeException is intentionally "
+ "thrown to the application, if no valid audio/video data "

Check warning

Code scanning / detekt

Checks if condition chaining is wrapped right Warning

Line must not begin with "+"
+ "is called immediately after start(). The failure lets the application "
+ "take action accordingly to clean up the output file "
+ "(delete the output file, for instance), since the output file "
+ "is not properly constructed when this happens.")

Check warning

Code scanning / detekt

Checks if condition chaining is wrapped right Warning

Line must not begin with "+"
} catch (e: IllegalStateException) {
Log.e(TAG, "Error recording sound (Other recorder running?).", e)
ToastUtil.showError(this, R.string.soundrecorder_error)
} catch (e: RuntimeException) {

Check warning

Code scanning / detekt

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. Warning

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.

@Test
fun testMaxAmplitudeDelegatesToMediaRecorder() {
val expectedAmplitude = 12345

Check warning

Code scanning / detekt

Report missing or invalid underscores in base 10 numbers. Numeric literals should be underscore separated to increase readability. Warning test

This number should be separated by underscores in order to increase readability.
// Create a file (not directory) at the path where we need a directory
// Then try to create a subdirectory inside it - mkdirs() will fail
val blockingFile = File(tempFolder.root, "blocker")
blockingFile.createNewFile() // Create a FILE named "blocker"

Check warning

Code scanning / detekt

Reports multiple space usages Warning test

Unnecessary long whitespace
// "blocker" is a file, not a directory
val invalidPath = File(File(blockingFile, "subdir"), "test.m4a").absolutePath
val invalidRecorder = SoundRecorder(invalidPath, mockRecorder)
invalidRecorder.start() // Should throw IOException: "Path to file could not be created."

Check warning

Code scanning / detekt

Reports multiple space usages Warning test

Unnecessary long whitespace
@sonarqubecloud
Copy link

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

Labels

Active Member Tickets that are assigned to members that are still currently active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants