aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorali-al <ali-al@yandex-team.com>2024-09-18 20:00:47 +0300
committerali-al <ali-al@yandex-team.com>2024-09-18 20:14:58 +0300
commit142e640f62d0a4828c7adf4c6268cc44f92dfcbb (patch)
tree35129fcf0972e08c2d3a00d80c2bca655628ba9d
parenta722c5b3d1c9bb1f63ffb38c5eb1976cfdd35cac (diff)
downloadydb-142e640f62d0a4828c7adf4c6268cc44f92dfcbb.tar.gz
support checking detekt in ya make (part 2)
commit_hash:12d2276831dac6e43d6a782919c5a7d511e9d05d
-rw-r--r--build/conf/java.conf25
-rw-r--r--build/plugins/java.py5
-rw-r--r--build/plugins/ytest.py35
3 files changed, 64 insertions, 1 deletions
diff --git a/build/conf/java.conf b/build/conf/java.conf
index ed38d79a312..9d0b4e31c2a 100644
--- a/build/conf/java.conf
+++ b/build/conf/java.conf
@@ -1074,6 +1074,13 @@ module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
when($WITH_KOTLINC_PLUGIN_SERIALIZATION) {
KOTLINC_OPTS_VALUE+=-Xplugin=${KOTLIN_COMPILER_RESOURCE_GLOBAL}/plugins/kotlin-serialization-plugin.jar
}
+ when($WITH_KOTLINC_PLUGIN_DETEKT) {
+ KOTLINC_OPTS_VALUE+=-Xplugin=${tool:"devtools/detekt-compiler-plugin"}
+ KOTLINC_OPTS_VALUE+=-P plugin:detekt-compiler-plugin:report=xml:${BINDIR}/misc/detekt-report.xml
+ # If there are no kt sources, the report won't be generated, however the file must be always present.
+ ALL_KT_COMMANDS+=&& $YMAKE_PYTHON ${input:"build/scripts/touch.py"} ${BINDIR}/misc/detekt-report.xml
+ ALL_KT_COMMANDS+=&& $FS_TOOLS copy ${BINDIR}/misc/detekt-report.xml ${output;noauto:"detekt-report.xml"}
+ }
# Must be in sync with KT_CLASSES_DIR!
# There are problems in JDK13 with abs paths in classpath baked into jar file manifest. Using relative path
# here assumes that jar file with classpath for javac located in the $ARCADIA_BUILD_ROOT
@@ -1165,6 +1172,7 @@ module JAR_LIBRARY: _COMPILABLE_JAR_BASE {
ENABLE(YMAKE_JAVA_TEST)
_ADD_KOTLIN_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/all-kt-sources.txt REQUIREMENTS cpu:2)
_ADD_JAVA_STYLE_CHECKS($(BUILD_ROOT)/$MODDIR/lint-java.srclst::$(SOURCE_ROOT))
+ _ADD_DETEKT_REPORT_CHECK($(BUILD_ROOT)/$MODDIR/detekt-report.xml)
_ADD_CLASSPATH_CLASH_CHECK()
JAVA_MODULE()
}
@@ -1938,11 +1946,25 @@ macro WITH_KOTLINC_SERIALIZATION() {
}
# tag:kotlin-specific
+WITH_KOTLINC_PLUGIN_DETEKT=
+_WITH_KOTLINC_PLUGIN_DETEKT_SEM=
+### @usage: WITH_KOTLINC_DETEKT(-flags)
+###
+### Enable detekt kotlin compiler plugin https://detekt.dev/docs/gettingstarted/compilerplugin/
+macro WITH_KOTLINC_DETEKT(Options...) {
+ SET_APPEND(KOTLINC_OPTS_VALUE ${pre=-P plugin\:detekt-compiler-plugin\::Options})
+ SET(WITH_KOTLINC_PLUGIN_DETEKT yes)
+ SET(_WITH_KOTLINC_PLUGIN_DETEKT_SEM && with_kotlinc_plugin_detekt)
+}
+
+
+# tag:kotlin-specific
### Also search for _KAPT_OPTS and change version there
_KOTLIN_VERSION=1.9.24
KOTLIN_VERSION=1.9.24
KOTLIN_BOM_FILE=${ARCADIA_ROOT}/contrib/java/org/jetbrains/kotlin/kotlin-bom/1.9.24/ya.dependency_management.inc
GROOVY_VERSION=3.0.5
+DETEKT_VERSION=1.23.7
_KOTLIN_SEM= \
${_WITH_KOTLIN_SEM} \
@@ -1950,7 +1972,8 @@ _KOTLIN_SEM= \
${_WITH_KOTLINC_PLUGIN_ALLOPEN_SEM} \
${_WITH_KOTLINC_PLUGIN_LOMBOK_SEM} \
${_WITH_KOTLINC_PLUGIN_NOARG_SEM} \
- ${_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM}
+ ${_WITH_KOTLINC_PLUGIN_SERIALIZATION_SEM} \
+ ${_WITH_KOTLINC_PLUGIN_DETEKT_SEM}
_JAVA_PROTO_GRPC_SEM=
diff --git a/build/plugins/java.py b/build/plugins/java.py
index 60d70919b49..e47d1744730 100644
--- a/build/plugins/java.py
+++ b/build/plugins/java.py
@@ -231,6 +231,11 @@ def on_add_classpath_clash_check(unit, *args):
unit.onjava_test_deps(jdeps_val)
+def on_add_detekt_report_check(unit, *args):
+ if unit.get('WITH_KOTLIN_VALUE') == 'yes' and unit.get('WITH_KOTLINC_PLUGIN_DETEKT') == 'yes':
+ unit.onadd_check(['detekt.report'] + list(args))
+
+
# Ymake java modules related macroses
diff --git a/build/plugins/ytest.py b/build/plugins/ytest.py
index 6b1a77e2358..05ccb430bef 100644
--- a/build/plugins/ytest.py
+++ b/build/plugins/ytest.py
@@ -693,6 +693,39 @@ def govet(fields, unit, *args):
unit.set_property(["DART_DATA", data])
+@df.with_fields(
+ CHECK_FIELDS_BASE
+ + (
+ df.TestedProjectName.normalized_basename,
+ df.SourceFolderPath.normalized,
+ df.TestFiles.flat_args_wo_first,
+ df.ModuleLang.value,
+ )
+)
+def detekt_report(fields, unit, *args):
+ flat_args, spec_args = _common.sort_by_keywords(
+ {
+ "DEPENDS": -1,
+ "TIMEOUT": 1,
+ "DATA": -1,
+ "TAG": -1,
+ "REQUIREMENTS": -1,
+ "FORK_MODE": 1,
+ "SPLIT_FACTOR": 1,
+ "FORK_SUBTESTS": 0,
+ "FORK_TESTS": 0,
+ "SIZE": 1,
+ },
+ args,
+ )
+
+ dart_record = create_dart_record(fields, unit, flat_args, spec_args)
+
+ data = dump_test(unit, dart_record)
+ if data:
+ unit.set_property(["DART_DATA", data])
+
+
def onadd_check(unit, *args):
if unit.get("TIDY") == "yes":
# graph changed for clang_tidy tests
@@ -727,6 +760,8 @@ def onadd_check(unit, *args):
gofmt(unit, *args)
elif check_type == "govet":
govet(unit, *args)
+ elif check_type == "detekt.report":
+ detekt_report(unit, *args)
def on_register_no_check_imports(unit):