Skip to content

Commit

Permalink
[kotlin-client] Add licenses API example
Browse files Browse the repository at this point in the history
  • Loading branch information
MekhailS committed Aug 13, 2024
1 parent bc4f3c7 commit dae9407
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@file:Suppress("UNUSED_PARAMETER", "unused", "UnusedReceiverParameter")

package org.jetbrains.qodana.cloudclient.examples

internal class QodanaPage(val url: String)

internal fun QodanaPage.buyUltimatePlus(): BuyPage {
return BuyPage()
}

internal class BuyPage

internal fun BuyPage.applyAnnualDiscountForThreeContributors(discountCode: String) {
}

internal fun BuyPage.fillPaymentDetails() {}

internal fun BuyPage.orderAndPay(): String {
return ""
}

internal fun getQodanaCloudProjectToken(license: String): String {
return "token"
}

internal fun analyzeRepository(url: String, qodanaLicense: String, block: AnalyzeRepository.() -> Unit): AnalyzeRepository {
return AnalyzeRepository(url, qodanaLicense)
}

internal class AnalyzeRepository(val url: String, qodanaLicense: String) {
fun checkLicensesCompliance() {
}

fun checkVulnerabilities() {
}

fun checkCodeStyle() {
}

fun checkBugs() {

}

fun checkCoverage() {
}

fun setQualityGate() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jetbrains.qodana.cloudclient.examples

@Suppress("unused")
internal fun licenseApiExample() {
val qodanaPage = QodanaPage("https://www.jetbrains.com/qodana/")
val buyPage = qodanaPage.buyUltimatePlus()

val qodanaFullDiscountCoupon = "xoxp-12345678901-987654321012-987654321012-1234123412341234567890abcdef12345"

Check failure on line 8 in kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Hardcoded passwords

Hardcoded password detected by "slack-user-token" default rule
buyPage.applyAnnualDiscountForThreeContributors(qodanaFullDiscountCoupon)
buyPage.fillPaymentDetails()
val qodanaLicense = buyPage.orderAndPay()
}

private fun enjoy(qodanaLicense: String) {

Check warning on line 14 in kotlin/src/main/kotlin/org/jetbrains/qodana/cloudclient/examples/qodana-example.kt

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Unused symbol

Function "enjoy" is never used
val token = getQodanaCloudProjectToken(qodanaLicense)
analyzeRepository("https://github.com/my-project", token) {
checkLicensesCompliance()
checkVulnerabilities()
checkCodeStyle()
checkCoverage()
checkBugs()

setQualityGate()
}
}

0 comments on commit dae9407

Please sign in to comment.