diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/GitLinkBundle.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/GitLinkBundle.kt index a75d5f8..81e63a5 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/GitLinkBundle.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/GitLinkBundle.kt @@ -31,7 +31,7 @@ object GitLinkBundle : DynamicBundle(BUNDLE) { } fun openRepository() { - BrowserLauncher.instance.open("https://github.com/ben-gibson/GitLink"); + BrowserLauncher.instance.open("https://github.com/ben-gibson/GitLink") } fun plugin() = PluginManagerCore.getPlugin(PluginId.getId("uk.co.ben-gibson.remote.repository.mapper")) diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/git/RemoteExtensions.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/git/RemoteExtensions.kt index 85259d2..5e7e641 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/git/RemoteExtensions.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/git/RemoteExtensions.kt @@ -27,7 +27,7 @@ val GitRemote.httpUrl : URL? get() { // will result in an invalid URL when the repository name is made up of digits. // See https://github.com/ben-gibson/GitLink/issues/94 if (!url.startsWith("git@")) { - url = url.replace(":\\d{1,5}".toRegex(), ""); // remove the port + url = url.replace(":\\d{1,5}".toRegex(), "") // remove the port } // Hack for azure diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/Pipeline.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/Pipeline.kt index c30e299..1bfd9a2 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/Pipeline.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/Pipeline.kt @@ -35,7 +35,7 @@ class Pipeline(private val project: Project) { val middleware = queue.remove() return middleware(pass) { - return@middleware next(queue, pass); + return@middleware next(queue, pass) } } } \ No newline at end of file diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/ForceHttps.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/ForceHttps.kt index 95822b8..eebb2ef 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/ForceHttps.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/ForceHttps.kt @@ -19,7 +19,7 @@ class ForceHttps : Middleware { return url.toHttps() } - return url; + return url } } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/GenerateUrl.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/GenerateUrl.kt index a07e402..47a8bc9 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/GenerateUrl.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/GenerateUrl.kt @@ -73,7 +73,7 @@ class GenerateUrl : Middleware { val commit = repository.currentCommit() ?: return null if (!pullRequestWorkflowSupported || !settings.shouldCheckRemote) { - return commit; + return commit } return if (remote.contains(repository, commit)) commit else null diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/RecordHit.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/RecordHit.kt index 3c0be5e..4a6726e 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/RecordHit.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/RecordHit.kt @@ -13,9 +13,9 @@ class RecordHit : Middleware { override fun invoke(pass: Pass, next: () -> URL?) : URL? { val url = next() ?: return null - service().recordHit(); + service().recordHit() - return url; + return url } } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/SendSupportNotification.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/SendSupportNotification.kt index 99102c5..d6aebb3 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/SendSupportNotification.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/SendSupportNotification.kt @@ -21,7 +21,7 @@ class SendSupportNotification : Middleware { sendNotification(Notification.star()) } - return url; + return url } } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/Timer.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/Timer.kt index 8c3ad73..87020ea 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/Timer.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/pipeline/middleware/Timer.kt @@ -23,13 +23,13 @@ class Timer : Middleware { val url = next() - val total = System.currentTimeMillis() - startTime; + val total = System.currentTimeMillis() - startTime if (total > 1000) { sendNotification(Notification.performanceTips(pass.project), pass.project) } - return url; + return url } } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/platform/Platform.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/platform/Platform.kt index 3ed2111..2ddc710 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/platform/Platform.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/platform/Platform.kt @@ -5,7 +5,7 @@ import uk.co.ben_gibson.git.link.GitLinkBundle.message import uk.co.ben_gibson.git.link.ui.Icons import java.util.UUID import javax.swing.Icon -import uk.co.ben_gibson.url.Host; +import uk.co.ben_gibson.url.Host import java.util.regex.Pattern sealed class Platform(val id: UUID, val name: String, val icon: Icon, val domains: Set = setOf(), val domainPattern: Pattern? = null, val pullRequestWorkflowSupported: Boolean = true) { @@ -15,9 +15,7 @@ sealed class Platform(val id: UUID, val name: String, val icon: Icon, val domain other as Platform - if (id != other.id) return false - - return true + return id == other.id } override fun hashCode(): Int { diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/platform/PlatformRepository.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/platform/PlatformRepository.kt index bc70c42..10c2d71 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/platform/PlatformRepository.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/platform/PlatformRepository.kt @@ -24,7 +24,7 @@ private val EXISTING_PLATFORMS = setOf( @Service class PlatformRepository { fun getById(id: String) = getById(UUID.fromString(id)) - fun getById(id: UUID) = load().firstOrNull() { it.id == id } + fun getById(id: UUID) = load().firstOrNull { it.id == id } fun getByDomain(domain: Host): Platform? { val platforms = load() return platforms.firstOrNull { it.domains.contains(domain) } ?: platforms.firstOrNull { it.domainPattern?.matcher(domain.toString())?.matches() == true } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ApplicationSettings.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ApplicationSettings.kt index ba4fd7a..f63c989 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ApplicationSettings.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ApplicationSettings.kt @@ -4,7 +4,7 @@ import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.util.xmlb.XmlSerializerUtil -import com.intellij.util.xmlb.annotations.Tag; +import com.intellij.util.xmlb.annotations.Tag import uk.co.ben_gibson.url.Host import java.util.UUID diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ProjectSettings.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ProjectSettings.kt index c696788..a8bb447 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ProjectSettings.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/settings/ProjectSettings.kt @@ -15,7 +15,7 @@ class ProjectSettings : PersistentStateComponent { var host: String? = null var fallbackBranch = "main" var remote = "origin" - var checkCommitOnRemote = true + private var checkCommitOnRemote = true var shouldCheckRemote get() = checkCommitOnRemote set(value) { diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt index 3038e20..4786bb3 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/actions/Action.kt @@ -46,7 +46,7 @@ abstract class Action(private val type: Type): DumbAwareAction() { if (host == null) { event.presentation.isEnabledAndVisible = false - return; + return } event.presentation.isEnabled = shouldBeEnabled(event) diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notification.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notification.kt index cf24942..7cd0f0e 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notification.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notification.kt @@ -42,11 +42,11 @@ data class Notification( Finding GitLink useful? Show your support 💖 and ⭐ the repository 🙏. """.trimIndent(), actions = setOf( - NotificationAction.openRepository() { - service().requestSupport = false; + NotificationAction.openRepository { + service().requestSupport = false }, - NotificationAction.doNotAskAgain() { - service().requestSupport = false; + NotificationAction.doNotAskAgain { + service().requestSupport = false } ) ) @@ -76,9 +76,6 @@ data class Notification( Type.TRANSIENT, ) } - - fun isTransient() = type == Type.TRANSIENT - fun isPersistent() = !isTransient(); } data class NotificationAction(val title: String, val run: (dismiss: () -> Unit) -> Unit) { @@ -101,12 +98,12 @@ data class NotificationAction(val title: String, val run: (dismiss: () -> Unit) fun openUrl(url: URL, title: String = message("actions.take-me-there")) = NotificationAction(title) { dismiss -> dismiss() - BrowserLauncher.instance.open(url.toString()); + BrowserLauncher.instance.open(url.toString()) } fun disableRemoteCheck(project: Project) = NotificationAction(message("actions.disable")) { dismiss -> dismiss() - project.service().shouldCheckRemote = false; + project.service().shouldCheckRemote = false } } } diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notifier.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notifier.kt index 9809d67..45f4bd4 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notifier.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/notification/Notifier.kt @@ -29,7 +29,7 @@ fun sendNotification(notification : Notification, project : Project? = null) { notification.actions.forEach { action -> intellijNotification.addAction(DumbAwareAction.create(action.title) { - action.run() { + action.run { intellijNotification.expire() } }) diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/CustomPlatformSettingsConfigurable.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/CustomPlatformSettingsConfigurable.kt index d8373d5..b495d3d 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/CustomPlatformSettingsConfigurable.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/CustomPlatformSettingsConfigurable.kt @@ -127,7 +127,7 @@ private class CustomPlatformDialog(customPlatform: CustomHostSettings? = null) : textField() .bindText(platform::displayName) .focused() - .validationOnApply() { notBlank(it.text) ?: alphaNumeric(it.text) ?: length(it.text, 3, 15) } + .validationOnApply { notBlank(it.text) ?: alphaNumeric(it.text) ?: length(it.text, 3, 15) } .comment(message("settings.custom-platform.add-dialog.field.name.comment")) } row(message("settings.custom-platform.add-dialog.field.domain.label")) { diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/DomainRegistrySettings.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/DomainRegistrySettings.kt index 500cf66..77be7e0 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/DomainRegistrySettings.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/settings/DomainRegistrySettings.kt @@ -44,7 +44,7 @@ class DomainRegistrySettings : BoundConfigurable(message("settings.domain-regist .setEditAction { editDomain() } .setRemoveAction { removeDomain() } .setEditActionUpdater { canModifyDomain() } - .setRemoveActionUpdater() { canModifyDomain() } + .setRemoveActionUpdater { canModifyDomain() } .createPanel() init { diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/validation/ValidationExtensions.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/validation/ValidationExtensions.kt index 73c1e77..a467084 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/ui/validation/ValidationExtensions.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/ui/validation/ValidationExtensions.kt @@ -24,7 +24,7 @@ fun ValidationInfoBuilder.domain(value: String): ValidationInfo? { Host(value) null } catch (e: IllegalArgumentException) { - error(message("validation.invalid-domain")); + error(message("validation.invalid-domain")) } } @@ -46,7 +46,7 @@ fun ValidationInfoBuilder.exists(value: String, existing: Collection): V fun ValidationInfoBuilder.length(value: String, min: Int, max: Int): ValidationInfo? { if (value.isEmpty()) { - return null; + return null } return when { @@ -58,7 +58,7 @@ fun ValidationInfoBuilder.length(value: String, min: Int, max: Int): ValidationI fun ValidationInfoBuilder.fileAtCommitTemplate(value: String): ValidationInfo? { if (value.isEmpty()) { - return null; + return null } val options = UrlOptionsFileAtCommit( @@ -73,7 +73,7 @@ fun ValidationInfoBuilder.fileAtCommitTemplate(value: String): ValidationInfo? { fun ValidationInfoBuilder.fileAtBranchTemplate(value: String): ValidationInfo? { if (value.isEmpty()) { - return null; + return null } val options = UrlOptionsFileAtBranch( @@ -88,7 +88,7 @@ fun ValidationInfoBuilder.fileAtBranchTemplate(value: String): ValidationInfo? { fun ValidationInfoBuilder.commitTemplate(value: String): ValidationInfo? { if (value.isEmpty()) { - return null; + return null } val options = UrlOptionsCommit( @@ -96,7 +96,7 @@ fun ValidationInfoBuilder.commitTemplate(value: String): ValidationInfo? { Commit("734232a3c18f0625843bd161c3f5da272b9d53c1") ) - return urlTemplate(options, commit = value); + return urlTemplate(options, commit = value) } private fun ValidationInfoBuilder.urlTemplate( @@ -105,7 +105,7 @@ private fun ValidationInfoBuilder.urlTemplate( fileAtCommit: String = "", commit: String = "" ) : ValidationInfo? { - val factory = TemplatedUrlFactory(UrlTemplates(fileAtBranch, fileAtCommit, commit)); + val factory = TemplatedUrlFactory(UrlTemplates(fileAtBranch, fileAtCommit, commit)) return try { factory.createUrl(options) diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactory.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactory.kt index 1a474ea..9d493ec 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactory.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactory.kt @@ -74,7 +74,7 @@ class TemplatedUrlFactory(private val templates: UrlTemplates) : UrlFactory { processed = processed.replace("{remote:url:path:${position}}", pathParts.getOrElse(position) { "" }) } - return processed; + return processed } private fun processBranch(template: String, branch: String) = template @@ -83,7 +83,7 @@ class TemplatedUrlFactory(private val templates: UrlTemplates) : UrlFactory { private fun processFile(template: String, file: File) = template .replace("{object}", if (file.isDirectory) "tree" else "blob") .replace("{file:name}", if (file.isRoot) "" else escape.apply(file.name)) - .replace("{file:path}", file.path.split("/").map { escape.apply(it) }.joinToString("/")) + .replace("{file:path}", file.path.split("/").joinToString("/") { escape.apply(it) }) private fun processCommit(template: String, commit: Commit) = template .replace("{commit}", commit.toString()) diff --git a/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactoryProvider.kt b/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactoryProvider.kt index 7781d28..d52b50f 100644 --- a/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactoryProvider.kt +++ b/src/main/kotlin/uk/co/ben_gibson/git/link/url/factory/TemplatedUrlFactoryProvider.kt @@ -20,7 +20,7 @@ val PLATFORM_MAP = mapOf( ) @Service -class TemplatedUrlFactoryProvider() { +class TemplatedUrlFactoryProvider { fun forPlatform(platform: Platform): TemplatedUrlFactory { if (platform is Custom) { return customPlatform(platform)