Skip to content

Commit 13af6e6

Browse files
committed
Implement an assortment of various fixes
See #526 for more details.
1 parent 97c8f66 commit 13af6e6

File tree

16 files changed

+95
-78
lines changed

16 files changed

+95
-78
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ assignees: FWDekker
2424
<!-- If applicable, add screenshots to help explain your problem. -->
2525

2626
**Version information**
27-
- Randomness version [e.g. 2.7.7]: <!-- Check `Settings -> Plugins` in your IDE and search for `Randomness` -->
28-
- IDE version [e.g. IntelliJ Community 2023.1.3]: <!-- Check `Help -> About` in your IDE -->
29-
- Operating system [e.g. Windows 11, Ubuntu 22.04.2, macOS 13.4.1]: <!-- Use a search engine for help if you don't know -->
30-
- Java version [e.g. 17.0.5, 19.0.2]: <!-- Run `java -version` in a terminal or check https://www.java.com/en/download/help/version_manual.xml -->
27+
- Randomness version [e.g. 3.2.0]: <!-- Check `Settings -> Plugins` in your IDE and search for `Randomness` -->
28+
- IDE version [e.g. IntelliJ Community 2023.3.3]: <!-- Check `Help -> About` in your IDE -->
29+
- Operating system [e.g. Windows 11, Ubuntu 22.04.3, macOS 14.2.1]: <!-- Use a search engine for help if you don't know -->
30+
- Java version [e.g. 17.0.9, 21.0.1]: <!-- Run `java -version` in a terminal or check https://www.java.com/en/download/help/version_manual.xml -->
3131

3232
**Additional context**
3333
<!-- Add any other context about the problem here. -->

.github/SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Security policy
22
The security of Randomness is important to me.
33
If you find a vulnerability in Randomness, please
4-
[report the vulnerability](https://github.com/FWDekker/mommy/security/advisories/new) as soon as possible.
4+
[report the vulnerability](https://github.com/FWDekker/intellij-randomness/security/advisories/new) as soon as possible.
55

66
Please note that Randomness is distinct from IntelliJ and other IDEs developed by JetBrains.
77
To report a vulnerability in IntelliJ or another JetBrains product, please

build.gradle.kts

+22-22
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ fun properties(key: String) = project.findProperty(key).toString()
1717
/// Plugins
1818
plugins {
1919
// Compilation
20-
id("org.jetbrains.kotlin.jvm") version "1.9.21" // Use latest version, ignoring `gradle.properties`
20+
id("org.jetbrains.kotlin.jvm") version "1.8.0" // Set to latest version compatible with `pluginSinceBuild`, cf. https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library
2121
id("org.jetbrains.intellij") version "1.16.1"
2222

2323
// Tests/coverage
2424
id("org.jetbrains.kotlinx.kover") version "0.7.5"
2525

2626
// Static analysis
27-
id("io.gitlab.arturbosch.detekt") version "1.23.4" // See also `gradle.properties`
27+
id("io.gitlab.arturbosch.detekt") version "1.23.4" // cf. `gradle.properties`
2828

2929
// Documentation
3030
id("org.jetbrains.changelog") version "2.2.0"
31-
id("org.jetbrains.dokka") version "1.9.10" // See also `buildscript { dependencies` below and `gradle.properties`
31+
id("org.jetbrains.dokka") version "1.9.10" // cf. `buildscript { dependencies` below and `gradle.properties`
3232
}
3333

3434
buildscript {
3535
dependencies {
36-
classpath("org.jetbrains.dokka:dokka-base:1.9.10") // See also `plugins` above and `gradle.properties`
37-
classpath("org.jetbrains.dokka:versioning-plugin:1.9.10") // See also `plugins` above and `gradle.properties`
36+
classpath("org.jetbrains.dokka", "dokka-base", "1.9.10") // cf. `plugins` above and `gradle.properties`
37+
classpath("org.jetbrains.dokka", "versioning-plugin", "1.9.10") // cf. `plugins` above and `gradle.properties`
3838
}
3939
}
4040

@@ -45,22 +45,22 @@ repositories {
4545
}
4646

4747
dependencies {
48-
implementation("com.fasterxml.uuid:java-uuid-generator:${properties("uuidGeneratorVersion")}")
49-
implementation("com.github.sisyphsu:dateparser:${properties("dateparserVersion")}")
50-
implementation("com.github.curious-odd-man:rgxgen:${properties("rgxgenVersion")}")
51-
implementation("com.vdurmont:emoji-java:${properties("emojiVersion")}")
52-
implementation("org.eclipse.mylyn.github:org.eclipse.egit.github.core:${properties("githubCore")}")
53-
api("org.jetbrains.kotlin:kotlin-reflect")
54-
55-
testImplementation("org.assertj:assertj-swing-junit:${properties("assertjSwingVersion")}")
56-
testRuntimeOnly("org.junit.platform:junit-platform-runner:${properties("junitRunnerVersion")}")
57-
testImplementation("org.junit.vintage:junit-vintage-engine:${properties("junitVersion")}")
58-
testImplementation("io.kotest:kotest-assertions-core:${properties("kotestVersion")}")
59-
testImplementation("io.kotest:kotest-framework-datatest:${properties("kotestVersion")}")
60-
testImplementation("io.kotest:kotest-runner-junit5:${properties("kotestVersion")}")
61-
62-
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${properties("detektVersion")}")
63-
dokkaHtmlPlugin("org.jetbrains.dokka:versioning-plugin:${properties("dokkaVersion")}")
48+
implementation("com.fasterxml.uuid", "java-uuid-generator", properties("uuidGeneratorVersion"))
49+
implementation("com.github.sisyphsu", "dateparser", properties("dateparserVersion")) {
50+
exclude(group = "org.projectlombok", module = "lombok") // cf. https://github.com/sisyphsu/dateparser/issues/30
51+
}
52+
implementation("com.github.curious-odd-man", "rgxgen", properties("rgxgenVersion"))
53+
implementation("org.eclipse.mylyn.github", "org.eclipse.egit.github.core", properties("githubCore"))
54+
55+
testImplementation("org.assertj", "assertj-swing-junit", properties("assertjSwingVersion"))
56+
testRuntimeOnly("org.junit.platform", "junit-platform-runner", properties("junitRunnerVersion"))
57+
testImplementation("org.junit.vintage", "junit-vintage-engine", properties("junitVersion"))
58+
testImplementation("io.kotest", "kotest-assertions-core", properties("kotestVersion"))
59+
testImplementation("io.kotest", "kotest-framework-datatest", properties("kotestVersion"))
60+
testImplementation("io.kotest", "kotest-runner-junit5", properties("kotestVersion"))
61+
62+
detektPlugins("io.gitlab.arturbosch.detekt", "detekt-formatting", properties("detektVersion"))
63+
dokkaHtmlPlugin("org.jetbrains.dokka", "versioning-plugin", properties("dokkaVersion"))
6464
}
6565

6666

@@ -74,7 +74,7 @@ tasks {
7474
withType<KotlinCompile> {
7575
kotlinOptions {
7676
jvmTarget = properties("javaVersion")
77-
apiVersion = properties("kotlinApiVersion")
77+
apiVersion = properties("kotlinVersion")
7878
languageVersion = properties("kotlinVersion")
7979
}
8080
}

gradle.properties

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ pluginVerifierIdeVersions=IC-2023.1.5, IC-2023.2.5, IC-2023.3, CL-2023.1.5, CL-2
2020
# Java version should be the one used by the oldest Randomness-supported version of IntelliJ. See also
2121
# https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html#platformVersions.
2222
#
23-
# * Kotlin
24-
# * `kotlinVersion` is the same as `kotlinApiVersion`.
25-
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version. See also
26-
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library.
23+
# * Kotlin:
24+
# * Kotlin version should be bundled stdlib version of oldest supported IntelliJ version. See also
25+
# https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library.
26+
# * Ensure the version of the `org.jetbrains.kotlin.jvm` in `build.gradle.kts` is updated accordingly.
2727
javaVersion=17
2828
kotlinVersion=1.8
29-
kotlinApiVersion=1.8
3029

3130
# Dependencies
3231
# * Detekt should also be updated in `plugins` block.

src/main/kotlin/com/fwdekker/randomness/ErrorReporter.kt

+30-14
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import javax.crypto.spec.SecretKeySpec
4343
* Heavily inspired by [Patrick Scheibe's error reporter](https://github.com/halirutan/Wolfram-Language-IntelliJ-Plugin-Archive/tree/e3dd72f9cd344d678ac892aaa7bf59abd84871e8/src/de/halirutan/mathematica/errorreporting).
4444
*/
4545
@Suppress("detekt:MaxLineLength") // Necessary because of the long link in the docs above
46-
class ErrorReporter : ErrorReportSubmitter() {
46+
internal class ErrorReporter : ErrorReportSubmitter() {
4747
/**
4848
* Interacts with GitHub.
4949
*/
@@ -150,7 +150,7 @@ private class GitHubReporter {
150150
fun report(issueData: IssueData): SubmittedReportInfo =
151151
try {
152152
synchronized(this) {
153-
val duplicate = issueService.pageIssues(repo).flatSequence().firstOrNull(issueData::isDuplicateOf)
153+
val duplicate = issueService.pageIssues(repo).flatSequence().firstOrNull { issueData.isDuplicateOf(it) }
154154

155155
val context: Issue
156156
if (duplicate == null) {
@@ -241,7 +241,7 @@ private object GitHubScrambler {
241241
* The URL at which a newer token may be available.
242242
*/
243243
private val URL =
244-
URL("http://raw.githubusercontent.com/FWDekker/intellij-randomness/main/src/main/resources/reporter/token.bin")
244+
URL("https://raw.githubusercontent.com/FWDekker/intellij-randomness/main/src/main/resources/reporter/token.bin")
245245

246246

247247
/**
@@ -340,16 +340,27 @@ private class IssueData(
340340
*/
341341
val body: String =
342342
emptySequence<Pair<String, String>>()
343-
.plus("User-supplied comments" to additionalInfo.ifNullOrBlank { "_No comments supplied._" }.trim())
343+
.plus(
344+
Bundle("reporter.issue.body.comments.title") to
345+
additionalInfo.ifNullOrBlank { italic(Bundle("reporter.issue.body.comments.body_empty")) }.trim()
346+
)
344347
.plus(
345348
events
346349
.map { it.throwableText }
347350
.filterNot { it.isBlank() }
348-
.mapIndexed { idx: Int, body: String -> "Stacktrace ${idx + 1}" to spoiler(code(body, "java")) }
351+
.mapIndexed { idx: Int, body: String ->
352+
Bundle("reporter.issue.body.stacktrace.title", idx + 1) to
353+
spoiler(code(body, "java"))
354+
}
355+
)
356+
.plus(
357+
attachments.map {
358+
Bundle("reporter.issue.body.attachment.title", it.name) to
359+
spoiler(code(it.displayText))
360+
}
349361
)
350-
.plus(attachments.map { "Attachment: `${it.name}`" to spoiler(code(it.displayText)) })
351362
.plus(
352-
"Version information" to
363+
Bundle("reporter.issue.body.version.title") to
353364
"""
354365
- Randomness version: ${pluginDescriptor.version ?: "_Unknown_"}
355366
- IDE version: ${ApplicationInfo.getInstance().apiVersion}
@@ -358,7 +369,7 @@ private class IssueData(
358369
""".trimIndent()
359370
)
360371
.joinToString(separator = "\n\n") { section(it.first, it.second) }
361-
.plus("\n\n---\n\n_This issue report was generated automatically for an anonymous user._")
372+
.let { italic(Bundle("reporter.issue.body.header")) + "\n\n---\n\n" + it }
362373

363374

364375
/**
@@ -382,6 +393,17 @@ private class IssueData(
382393
* Holds constants.
383394
*/
384395
companion object {
396+
/**
397+
* Creates a Markdown code block containing [body] and using the given [language].
398+
*/
399+
private fun code(body: String, language: String = ""): String =
400+
"```$language\n$body\n```"
401+
402+
/**
403+
* Creates an italicized piece of Markdown.
404+
*/
405+
private fun italic(body: String) = "_${body}_"
406+
385407
/**
386408
* Creates a Markdown section with the given [title] and [body].
387409
*/
@@ -394,12 +416,6 @@ private class IssueData(
394416
private fun spoiler(body: String, heading: String = "Click to show"): String =
395417
"<details>\n <summary>${heading.trim()}</summary>\n\n${body.prependIndent(" ")}\n\n</details>"
396418

397-
/**
398-
* Creates a Markdown code block containing [body] and using the given [language].
399-
*/
400-
private fun code(body: String, language: String = ""): String =
401-
"```$language\n$body\n```"
402-
403419

404420
/**
405421
* Returns [this] if [this] is neither `null` nor blank, and returns the output of [then] otherwise.

src/main/kotlin/com/fwdekker/randomness/InsertAction.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
99
import com.intellij.openapi.command.WriteCommandAction
1010
import com.intellij.openapi.options.Configurable
1111
import com.intellij.openapi.options.newEditor.SettingsDialogFactory
12+
import com.intellij.util.alsoIfNull
1213
import javax.swing.Icon
1314

1415

@@ -66,8 +67,10 @@ abstract class InsertAction(
6667
val project = event.getData(CommonDataKeys.PROJECT) ?: return
6768

6869
configurable?.also {
69-
if (!SettingsDialogFactory.getInstance().create(project, text, it, false, false).showAndGet())
70-
return
70+
SettingsDialogFactory.getInstance()
71+
.create(project, text, it, false, false)
72+
.showAndGet()
73+
.alsoIfNull { return }
7174
}
7275

7376
val data =
@@ -89,7 +92,7 @@ abstract class InsertAction(
8992
return
9093
}
9194

92-
WriteCommandAction.runWriteCommandAction(project) {
95+
WriteCommandAction.runWriteCommandAction(project, Bundle("misc.insert_command_name"), null, {
9396
editor.caretModel.allCarets.forEachIndexed { i, caret ->
9497
val start = caret.selectionStart
9598
val end = caret.selectionEnd
@@ -98,7 +101,7 @@ abstract class InsertAction(
98101
editor.document.replaceString(start, end, data[i])
99102
caret.setSelection(start, newEnd)
100103
}
101-
}
104+
})
102105
}
103106

104107

src/main/kotlin/com/fwdekker/randomness/Notifier.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import com.intellij.notification.NotificationType
88
import com.intellij.openapi.actionSystem.AnActionEvent
99
import com.intellij.openapi.application.PathManager
1010
import com.intellij.openapi.project.Project
11-
import com.intellij.openapi.startup.StartupActivity
11+
import com.intellij.openapi.startup.ProjectActivity
1212
import com.intellij.openapi.ui.MessageDialogBuilder
1313

1414

1515
/**
1616
* Displays notifications when a project is opened.
1717
*/
18-
class Notifier : StartupActivity {
18+
internal class Notifier : ProjectActivity {
1919
/**
2020
* Shows startup notifications.
2121
*/
22-
override fun runActivity(project: Project) = showWelcomeToV3(project)
22+
override suspend fun execute(project: Project) = showWelcomeToV3(project)
2323

2424
/**
2525
* Shows a notification introducing the user to version 3 of Randomness.

src/main/kotlin/com/fwdekker/randomness/Settings.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ data class Settings(
7777
],
7878
category = SettingsCategory.PLUGINS,
7979
)
80-
class PersistentSettings : PersistentStateComponent<Element> {
80+
internal class PersistentSettings : PersistentStateComponent<Element> {
8181
/**
8282
* The [Settings] that should be persisted.
8383
*

src/main/kotlin/com/fwdekker/randomness/Timely.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Timely {
2828
try {
2929
return executor.submit<T> { generator() }.get(GENERATOR_TIMEOUT, TimeUnit.MILLISECONDS)
3030
} catch (exception: TimeoutException) {
31-
throw DataGenerationException(Bundle("helpers.error.timed_out"), exception)
31+
throw DataGenerationException(Bundle("misc.timed_out"), exception)
3232
} catch (exception: ExecutionException) {
3333
throw DataGenerationException(exception.cause?.message ?: exception.message, exception)
3434
} finally {

src/main/kotlin/com/fwdekker/randomness/string/StringScheme.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ data class StringScheme(
141141
/**
142142
* The default value of the [capitalization] field.
143143
*/
144-
val DEFAULT_CAPITALIZATION get() = CapitalizationMode.RETAIN
144+
val DEFAULT_CAPITALIZATION = CapitalizationMode.RETAIN
145145

146146
/**
147147
* The default value of the [removeLookAlikeSymbols] field.

src/main/kotlin/com/fwdekker/randomness/template/TemplateActionLoader.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ open class TemplateActionLoader(
7777
/**
7878
* Constructor-less version of [TemplateActionLoader], as is required in `plugin.xml`.
7979
*/
80-
class DefaultTemplateActionLoader : TemplateActionLoader()
80+
internal class DefaultTemplateActionLoader : TemplateActionLoader()

src/main/kotlin/com/fwdekker/randomness/template/TemplateListConfigurable.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import javax.swing.JComponent
2424
*
2525
* @see TemplateSettingsAction
2626
*/
27-
class TemplateListConfigurable : Configurable, Disposable {
27+
internal class TemplateListConfigurable : Configurable, Disposable {
2828
/**
2929
* The user interface for changing the settings, displayed in IntelliJ's settings window.
3030
*/
@@ -40,7 +40,7 @@ class TemplateListConfigurable : Configurable, Disposable {
4040
/**
4141
* Returns the name of the configurable as displayed in the settings window.
4242
*/
43-
override fun getDisplayName() = "Randomness"
43+
override fun getDisplayName() = Bundle("randomness")
4444

4545
/**
4646
* Creates a new editor and returns the root pane of the created editor.

src/main/resources/META-INF/plugin.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
<applicationConfigurable parentId="tools"
1717
instance="com.fwdekker.randomness.template.TemplateListConfigurable"
1818
id="com.fwdekker.randomness.template.TemplateListConfigurable"
19-
displayName="Randomness" />
19+
bundle="randomness"
20+
key="randomness" />
2021

2122
<!-- Dynamically loads, unloads, and updates template actions -->
2223
<dynamicActionConfigurationCustomizer
@@ -30,9 +31,8 @@
3031
</extensions>
3132

3233
<!-- Non-dynamic actions -->
33-
<actions>
34+
<actions resource-bundle="randomness">
3435
<action id="com.fwdekker.randomness.PopupAction" class="com.fwdekker.randomness.PopupAction"
35-
text="Randomness" description="Opens the Randomness popup."
3636
icon="/icons/randomness.svg">
3737
<keyboard-shortcut first-keystroke="alt R" keymap="$default" />
3838
<add-to-group group-id="GenerateGroup" anchor="last" />

0 commit comments

Comments
 (0)