From 37690058d260f5673876f78e6ec75364cfd3e59c Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 16 Mar 2022 22:53:21 +0100 Subject: [PATCH] Add checkstyle to extractor gradle project With respect to NewPipe's checkstyle.xml, checkstyle is disabled for javadoc comments. There is no need for strict rules over comments here in the extractor, as sometimes javadocs are just needed to clarify a small thing and having empty/meaningless @param or @throws is useless. --- build.gradle | 1 + checkstyle/checkstyle.xml | 189 ++++++++++++++++++++++++++++++++++++++ extractor/build.gradle | 20 +++- 3 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 checkstyle/checkstyle.xml diff --git a/build.gradle b/build.gradle index 3cc6fa0c4..ebac57210 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ allprojects { nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751" spotbugsVersion = "4.6.0" junitVersion = "5.8.2" + checkstyleVersion = "9.3" // do not use latest version (10.0) as it requires compile SDK 11 } } diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml new file mode 100644 index 000000000..4a82f6be3 --- /dev/null +++ b/checkstyle/checkstyle.xml @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extractor/build.gradle b/extractor/build.gradle index a9b5f7f3e..70b51a338 100644 --- a/extractor/build.gradle +++ b/extractor/build.gradle @@ -1,9 +1,25 @@ +plugins { + id 'checkstyle' +} + test { -// Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml + // Pass on downloader type to tests for different CI jobs. See DownloaderFactory.java and ci.yml if (System.properties.containsKey('downloader')) { systemProperty('downloader', System.getProperty('downloader')) } useJUnitPlatform() + dependsOn checkstyleMain // run checkstyle when testing +} + +checkstyle { + getConfigDirectory().set(rootProject.file("checkstyle")) + ignoreFailures false + showViolations true + toolVersion checkstyleVersion +} + +checkstyleTest { + enabled false // do not checkstyle test files } dependencies { @@ -15,6 +31,8 @@ dependencies { implementation "com.github.spotbugs:spotbugs-annotations:$spotbugsVersion" implementation 'org.nibor.autolink:autolink:0.10.0' + checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion" + testImplementation platform("org.junit:junit-bom:$junitVersion") testImplementation 'org.junit.jupiter:junit-jupiter-api' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'