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

[kotlin-client] Add licenses API example #15

Closed
wants to merge 1 commit into from
Closed
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
@@ -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()
}
}
Loading