Skip to content
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
| unusedKaptProcessor | unused-kapt-processor |
| unusedKotlinAndroidExtensions | unused-kotlin-android-extensions |

### 🚀 Features

- Added support
for [Static Analysis Results Interchange Format (SARIF)](https://sarifweb.azurewebsites.net)
report
output [@RBusarow](https://github.com/RBusarow) ([#566](https://github.com/rbusarow/ModuleCheck/pull/566))

### ℹ️ Website

- add `google()` repository to config
Expand Down
1 change: 1 addition & 0 deletions build-logic/mcbuild/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation(libs.detekt.gradle)
implementation(libs.dokka.gradle)
implementation(libs.google.dagger.api)
implementation(libs.google.ksp)
implementation(libs.kotlin.compiler)
implementation(libs.kotlin.gradle.plug)
implementation(libs.ktlint.gradle)
Expand Down
9 changes: 8 additions & 1 deletion build-logic/mcbuild/src/main/kotlin/mcbuild.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

import modulecheck.builds.ArtifactIdListener
import modulecheck.builds.DIListener
import modulecheck.builds.KspListener
import modulecheck.builds.ModuleCheckBuildExtension
import modulecheck.builds.applyAnvil
import modulecheck.builds.applyDagger
import modulecheck.builds.applyKsp
import modulecheck.builds.configurePublishing
import modulecheck.builds.libsCatalog

Expand All @@ -38,13 +40,18 @@ val settings = extensions.create<ModuleCheckBuildExtension>(
DIListener { anvil, dagger ->
applyAnvil(anvil = anvil, dagger = dagger)
applyDagger(anvil = anvil, dagger = dagger)
}
},
KspListener { onKspToggled(it) }
)

fun onNewArtifactId(artifactId: String) {
project.configurePublishing(artifactId)
}

fun onKspToggled(useKsp: Boolean) {
project.applyKsp(useKsp)
}

@Suppress("UnstableApiUsage")
val kotlinVersion = project.libsCatalog
.findVersion("kotlin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>()

freeCompilerArgs = freeCompilerArgs + listOf(
"-Xinline-classes",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.ExperimentalStdlibApi",
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
"-Xopt-in=kotlinx.coroutines.FlowPreview"
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlin.ExperimentalStdlibApi",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-opt-in=kotlinx.coroutines.FlowPreview"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2021-2022 Rick Busarow
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modulecheck.builds

fun interface KspListener {
fun onChanged(useKsp: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import kotlin.reflect.KProperty
abstract class ModuleCheckBuildExtension @Inject constructor(
objects: ObjectFactory,
private val artifactIdListener: ArtifactIdListener,
private val diListener: DIListener
private val diListener: DIListener,
private val kspListener: KspListener
) {

var artifactId: String? by objects.nullableProperty<String> {
Expand All @@ -36,6 +37,9 @@ abstract class ModuleCheckBuildExtension @Inject constructor(
var dagger: Boolean by objects.property(false) {
diListener.onChanged(anvil, it)
}
var ksp: Boolean by objects.property(false) {
kspListener.onChanged(it)
}
}

internal inline fun <reified T : Any> ObjectFactory.property(
Expand Down
26 changes: 26 additions & 0 deletions build-logic/mcbuild/src/main/kotlin/modulecheck/builds/ksp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2021-2022 Rick Busarow
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package modulecheck.builds

import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply

fun Project.applyKsp(useKsp: Boolean) {

if (!useKsp) return

apply(plugin = "com.google.devtools.ksp")
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.gradle.plugins.signing.Sign
const val GROUP = "com.rickbusarow.modulecheck"
const val PLUGIN_ID = "com.rickbusarow.module-check"
const val VERSION_NAME = "0.12.1-SNAPSHOT"
const val SOURCE_WEBSITE = "https://github.com/rbusarow/ModuleCheck"
const val DOCS_WEBSITE = "https://rbusarow.github.io/ModuleCheck"

@Suppress("UnstableApiUsage")
fun Project.configurePublishing(
Expand All @@ -47,7 +49,7 @@ fun Project.configurePublishing(
pom {
description.set("Fast dependency graph linting for Gradle projects")
name.set(artifactId)
url.set("https://github.com/rbusarow/ModuleCheck")
url.set(SOURCE_WEBSITE)
licenses {
license {
name.set("The Apache Software License, Version 2.0")
Expand All @@ -56,7 +58,7 @@ fun Project.configurePublishing(
}
}
scm {
url.set("https://github.com/rbusarow/ModuleCheck/")
url.set("$SOURCE_WEBSITE/")
connection.set("scm:git:git://github.com/rbusarow/ModuleCheck.git")
developerConnection.set("scm:git:ssh://git@github.com/rbusarow/ModuleCheck.git")
}
Expand Down
4 changes: 4 additions & 0 deletions dependabot-bridge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ dependencies {
dependencySync("com.squareup.anvil:gradle-plugin:2.4.0")
dependencySync("com.squareup:kotlinpoet:1.11.0")
dependencySync("com.github.javaparser:javaparser-core:3.24.2")
dependencySync("com.google.devtools.ksp:symbol-processing-gradle-plugin:1.6.21-1.0.5")
dependencySync("com.squareup.moshi:moshi-kotlin-codegen:1.13.0")
dependencySync("com.squareup.moshi:moshi:1.13.0")
dependencySync("com.squareup.okio:okio:3.1.0")
dependencySync("com.vanniktech:gradle-maven-publish-plugin-base:0.19.0")
dependencySync("com.vanniktech:gradle-maven-publish-plugin:0.19.0")

Expand Down
16 changes: 12 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ kotlin = "1.6.21"
kotlinx-atomicfu = "0.16.3"
kotlinx-coroutines = "1.6.1"
kotlinx-knit = "0.4.0"
google-ksp = "1.6.21-1.0.5"

ktlint = "10.2.1"

Expand All @@ -51,8 +52,8 @@ rickBusarow-moduleCheck = "0.11.3"
rickBusarow-tangle = "0.13.2"

square-anvil = "2.4.0"
square-moshi = "1.12.0"
square-okhttp = "4.9.1"
square-moshi = "1.13.0"
square-okio = "3.1.0"
square-retrofit = "2.9.0"
square-workflow = "1.0.0"

Expand All @@ -61,8 +62,6 @@ taskTree = "2.1.0"

vanniktech-publish = "0.19.0"

zacSweers-moshix = "0.14.1"

[plugins]

anvil = { id = "com.squareup.anvil", version.ref = "square-anvil" }
Expand All @@ -76,6 +75,8 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
taskTree = { id = "com.dorongold.task-tree", version.ref = "taskTree" }

google-ksp = { id = "com.google.devtools.ksp", version.ref = "google-ksp" }

dependencySync = { id = "com.rickbusarow.dependency-sync", version.ref = "rickBusarow-dependencySync" }
moduleCheck = { id = "com.rickbusarow.module-check", version.ref = "rickBusarow-moduleCheck" }
tangle = { id = "com.rickbusarow.tangle", version.ref = "rickBusarow-tangle" }
Expand All @@ -98,6 +99,8 @@ dokka-gradle = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref
google-dagger-api = { module = "com.google.dagger:dagger", version.ref = "google-dagger" }
google-dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "google-dagger" }

google-ksp = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "google-ksp" }

groovy = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" }
groovyXml = { module = "org.codehaus.groovy:groovy-xml", version.ref = "groovy" }

Expand Down Expand Up @@ -162,6 +165,11 @@ square-anvil-compiler-core = { module = "com.squareup.anvil:compiler", version.r
square-anvil-compiler-utils = { module = "com.squareup.anvil:compiler-utils", version.ref = "square-anvil" }
square-anvil-gradle = { module = "com.squareup.anvil:gradle-plugin", version.ref = "square-anvil" }

square-moshi = { module = "com.squareup.moshi:moshi", version.ref = "square-moshi" }
square-moshi-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "square-moshi" }

square-okio = { module = "com.squareup.okio:okio", version.ref = "square-okio" }

square-turbine = "app.cash.turbine:turbine:0.7.0"

unbescape = "org.unbescape:unbescape:1.1.6.RELEASE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

package modulecheck.api.finding

import modulecheck.api.rule.ModuleCheckRule
import modulecheck.project.McProject

interface FindingFactory<T : Finding> {

val rules: List<ModuleCheckRule<out Finding>>

suspend fun evaluateFixable(projects: List<McProject>): List<T>
suspend fun evaluateSorts(projects: List<McProject>): List<T>
suspend fun evaluateReports(projects: List<McProject>): List<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ data class RuleName(

/** SomeRuleName */
val titleCase: String
get() = id.split('-').joinToString { it.capitalize() }
get() = id.split('-').joinToString("") { it.capitalize() }

/** some_rule_name */
val snakeCase: String get() = id.replace('-', '_')

/** someRuleName */
val pascalCase: String
get() = id.split('-')
.joinToString { it.capitalize() }
.joinToString("") { it.capitalize() }
.decapitalize()

/** 'Some Rule Name' */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,19 @@ interface ChecksSettings {

interface ReportsSettings {

/**
* checkstyle-formatted xml report
*/
/** checkstyle-formatted xml report */
val checkstyle: ReportSettings

/**
* plain-text report file matching the console output
*/
/** SARIF-formatted report */
val sarif: ReportSettings

/** plain-text report file matching the console output */
val text: ReportSettings

/**
* report of the depth for each source set for each module
*/
/** report of the depth for each source set for each module */
val depths: ReportSettings

/**
* create dependency graphs for each source set for each module
*/
/** create dependency graphs for each source set for each module */
val graphs: PerModuleReportSettings

companion object {
Expand All @@ -150,6 +145,9 @@ interface ReportsSettings {
const val DEPTHS_ENABLED_DEFAULT = false
const val DEPTHS_PATH_DEFAULT = "build/reports/modulecheck/depths.txt"

const val SARIF_ENABLED_DEFAULT = false
const val SARIF_PATH_DEFAULT = "build/reports/modulecheck/modulecheck.sarif"

const val GRAPH_ENABLED_DEFAULT = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class TestReportsSettings(
ReportsSettings.CHECKSTYLE_ENABLED_DEFAULT,
ReportsSettings.CHECKSTYLE_PATH_DEFAULT
),
override val sarif: ReportSettings = TestReportSettings(
ReportsSettings.SARIF_ENABLED_DEFAULT,
ReportsSettings.SARIF_PATH_DEFAULT
),
override val text: ReportSettings = TestReportSettings(
ReportsSettings.TEXT_ENABLED_DEFAULT,
ReportsSettings.TEXT_PATH_DEFAULT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,27 @@ data class UnusedDependencyFinding(
override val dependency get() = oldDependency

override val message: String
get() = "The declared dependency is not used in this module."
get() = when {
dependency.isTestFixture -> {
"The declared dependency " +
"`${configurationName.value}(testFixtures(\"${dependency.path}\"))` " +
"is not used in this module."
}
else -> {
"The declared dependency `${configurationName.value}(\"${dependency.path}\")` " +
"is not used in this module."
}
}

override fun toString(): String {
return "UnusedDependency(\n" +
"\tdependentPath='$dependentPath', \n" +
"\tbuildFile=$buildFile, \n" +
"\tdependency=$dependency, \n" +
"\tdependencyIdentifier='$dependencyIdentifier', \n" +
"\tconfigurationName=$configurationName\n" +
")"
return """UnusedDependency(
dependentPath='$dependentPath',
buildFile=$buildFile,
dependency=$dependency,
dependencyIdentifier='$dependencyIdentifier',
configurationName=$configurationName
)
""".trimIndent()
}

override fun fromStringOrEmpty(): String = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import modulecheck.utils.sortedWith

class MultiRuleFindingFactory(
private val settings: ModuleCheckSettings,
private val rules: List<ModuleCheckRule<out Finding>>
override val rules: List<ModuleCheckRule<out Finding>>
) : FindingFactory<Finding> {

override suspend fun evaluateFixable(projects: List<McProject>): List<Finding> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class SingleRuleFindingFactory<T : Finding>(
val rule: ModuleCheckRule<T>
) : FindingFactory<Finding> {

override val rules: List<ModuleCheckRule<out Finding>>
get() = listOf(rule)

override suspend fun evaluateFixable(projects: List<McProject>): List<T> {
return if (rule !is SortRule && rule !is ReportOnlyRule) {
evaluateRule(projects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,5 @@ class RuleUrlValidationTest : BaseTest() {
sidebarsRules shouldContain docId
}
}
.toList()
.map { it.second }
.let { urlStrings ->
}
}
}
Loading