Skip to content

Commit

Permalink
build: remove inconsistent code analysis / align with hedera-services
Browse files Browse the repository at this point in the history
Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Oct 7, 2024
1 parent 62a6fcb commit 63438db
Show file tree
Hide file tree
Showing 72 changed files with 171 additions and 644 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ jobs:
run: |
./gradlew -POPERATOR_ID=$OPERATOR_ID -POPERATOR_KEY=$OPERATOR_KEY -PHEDERA_NETWORK=$HEDERA_NETWORK jacocoTestReport --scan
- name: Sonar Scan
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonarqube --info --scan

- name: Upload coverage to Codecov
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
Expand Down
5 changes: 1 addition & 4 deletions gradle/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ repositories.gradlePluginPortal()

dependencies {
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:2.0.2")
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.12")
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0")
implementation("org.gradlex:extra-java-module-info:1.8")
implementation("org.gradlex:extra-java-module-info:1.9")
implementation("org.gradlex:java-module-dependencies:1.6.5")
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373")

implementation("org.gradle.toolchains:foojay-resolver:0.8.0")
implementation("com.gradle:develocity-gradle-plugin:3.17.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*
*/

import net.ltgt.gradle.errorprone.errorprone

plugins {
id("application")
id("com.hedera.gradle.java-base")
Expand All @@ -30,13 +28,6 @@ javaModuleDependencies {
moduleNameToGA.put("com.hedera.hashgraph.sdk.full", "com.hedera.hashgraph:sdk-full")
}

tasks.withType<JavaCompile>().configureEach {
options.errorprone {
disable("DefaultPackage")
disable("SystemOut")
}
}

tasks.register<RunAllExample>("runAllExamples") {
workingDirectory = rootDir
sources.from(sourceSets.main.get().java.asFileTree)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import net.ltgt.gradle.errorprone.errorprone

/*-
*
* Hedera Java SDK
Expand All @@ -23,7 +21,6 @@ import net.ltgt.gradle.errorprone.errorprone
plugins {
id("java")
id("jacoco")
id("net.ltgt.errorprone")
id("org.gradlex.java-module-dependencies")
id("com.hedera.gradle.base")
id("com.hedera.gradle.repositories")
Expand All @@ -45,56 +42,26 @@ jvmDependencyConflicts {
consistentResolution.platform("com.hedera.hashgraph:sdk-dependency-versions")
}

dependencies {
// https://github.com/google/error-prone
// https://errorprone.info/
errorprone("com.google.errorprone:error_prone_core:2.21.1")

// https://github.com/uber/NullAway
errorprone("com.uber.nullaway:nullaway:0.10.14")

// https://github.com/grpc/grpc-java-api-checker
errorprone("io.grpc:grpc-java-api-checker:1.1.0")
}
val deactivatedCompileLintOptions =
listOf(
"module", // module not found when doing 'exports to ...'
"serial", // serializable class ... has no definition of serialVersionUID
"processing", // No processor claimed any of these annotations: ...
"try", // auto-closeable resource ignore is never referenced... (AutoClosableLock)
"missing-explicit-ctor", // class ... declares no explicit constructors
"removal",
"deprecation",
"overrides", // overrides equals, but neither it ... overrides hashCode method
"unchecked",
"rawtypes",
"exports",
"dep-ann"
)

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"

// Disable warnings because I'm tired of them :P
options.isWarnings = false

options.errorprone {
// https://github.com/uber/NullAway
warn("NullAway")
option("NullAway:AnnotatedPackages", "com.hedera.hashgraph.sdk")
option("NullAway:TreatGeneratedAsUnannotated", "true")

// https://github.com/grpc/grpc-java-api-checker
disable("GrpcExperimentalApi")
warn("GrpcInternal")

// Enable _all_ error prone checks then selectively disble
// Checks that are default-disabled are enabled as warnings
allDisabledChecksAsWarnings = true
disable("TryFailRefactoring")
disable("ThrowSpecificExceptions")
disable("FutureReturnValueIgnored")
disable("FieldCanBeFinal")
disable("Finally")
disable("BooleanParameter")
disable("ThreadJoinLoop")
disable("UnnecessaryDefaultInEnumSwitch")
disable("UngroupedOverloads")
disable("InlineMeSuggester")

// Uncomment do disable Android + JDK7 checks
// disable("Java7ApiChecker")
// disable("AndroidJdkLibsChecker")

// Ignore generated and protobuf code
disableWarningsInGeneratedCode = true
excludedPaths = ".*generated.*"
}
options.compilerArgs.add("-Werror")
options.compilerArgs.add("-Xlint:all,-" + deactivatedCompileLintOptions.joinToString(",-"))
}

tasks.withType<AbstractArchiveTask>().configureEach {
Expand Down
49 changes: 3 additions & 46 deletions gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
plugins {
id("java-library")
id("com.google.protobuf")
id("com.github.spotbugs")
id("org.sonarqube")
id("com.hedera.gradle.java-base")
id("com.hedera.gradle.publish")
}
Expand Down Expand Up @@ -105,16 +103,16 @@ tasks.jacocoTestReport {
protobuf {
protoc {
// shouldn't be updated for now (breaking changes after 4.x.x)
artifact = "com.google.protobuf:protoc:3.25.3"
artifact = "com.google.protobuf:protoc:3.25.4"
}
plugins {
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:1.50.2"
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0"
}
}
}
tasks.generateProto {
plugins { plugins.register("grpc") }
plugins { plugins.register("grpc") { option("@generated=omit") } }
}

tasks.compileJava {
Expand All @@ -132,44 +130,3 @@ tasks.jar {
sourceSets.all {
configurations[getTaskName("", "compileProtoPath")].extendsFrom(configurations["internal"])
}

spotbugs {
//ignoreFailures = false
//showStackTraces = true
//showProgress = false
//reportLevel = 'default'
//effort = 'default'
//visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
//omitVisitors = [ 'FindNonShortCircuit' ]
reportsDir = layout.buildDirectory.dir("reports/spotbugs")
//includeFilter = file('spotbugs-include.xml')
//excludeFilter = file('spotbugs-exclude.xml')
onlyAnalyze = listOf("com.hedera.hashgraph.sdk.*")
//projectName = name
//release = version
//extraArgs = [ '-nested:false' ]
//jvmArgs = [ '-Duser.language=ja' ]
//maxHeapSize = '512m'
}

tasks.spotbugsMain {
reports.register("html") {
required = true
outputLocation = layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html")
setStylesheet("fancy-hist.xsl")
}
}

dependencies {
spotbugs("com.github.spotbugs:spotbugs:4.8.4")
spotbugs("com.google.code.findbugs:jsr305:3.0.2")
}

sonarqube {
properties {
property("sonar.projectKey", "hashgraph_hedera-sdk-java")
property("sonar.organization", "hashgraph")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.exclusions", "examples/**")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ plugins {
id("org.gradlex.jvm-dependency-conflict-resolution")
}

// Do annotation processing on the classpath, because 'Error Prone' has many non-module dependencies
sourceSets.all {
configurations.getByName(annotationProcessorConfigurationName) {
attributes { attribute(Attribute.of("javaModule", Boolean::class.javaObjectType), false) }
}
}

// Fix or enhance the metadata of third-party Modules. This is about the metadata in the
// repositories: '*.pom' and '*.module' files.
jvmDependencyConflicts.patch {
Expand All @@ -41,7 +34,6 @@ jvmDependencyConflicts.patch {
"com.google.android:annotations",
"com.google.code.findbugs:annotations",
"com.google.code.findbugs:jsr305",
"com.google.errorprone:error_prone_annotations",
"com.google.guava:listenablefuture",
"com.google.j2objc:j2objc-annotations",
"org.checkerframework:checker-compat-qual",
Expand Down Expand Up @@ -76,21 +68,7 @@ extraJavaModuleInfo {
module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal")
module("com.google.guava:guava", "com.google.common") {
exportAllPackages()
requires("com.google.common.util.concurrent.internal")
requires("java.logging")
}
module("guava-32.1.3-jre.jar", "com.google.common") {
/**
* Repetition of the rule above:
*
* There is an issue when the version is "android", but the selected Jar
* with classifier is "jre". If this causes a problem depends on the local
* Gradle dependency cache state (most likely).
* This is an issue that needs to be investigated and fixed in
* https://github.com/gradlex-org/extra-java-module-info
*/
exportAllPackages()
requires("com.google.common.util.concurrent.internal")
requireAllDefinedDependencies()
requires("java.logging")
}
module("com.google.protobuf:protobuf-java", "com.google.protobuf") {
Expand Down Expand Up @@ -128,10 +106,7 @@ extraJavaModuleInfo {
requires("java.logging")
}
module("io.perfmark:perfmark-api", "io.perfmark")
module("javax.annotation:javax.annotation-api", "java.annotation") {
exportAllPackages()
mergeJar("com.google.code.findbugs:jsr305")
}
module("com.google.code.findbugs:jsr305", "java.annotation")
module("org.jetbrains:annotations", "org.jetbrains.annotations")

// Full protobuf only
Expand Down Expand Up @@ -160,7 +135,3 @@ extraJavaModuleInfo {
module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter")
module("org.objenesis:objenesis", "org.objenesis")
}

dependencies {
javaModulesMergeJars("com.google.code.findbugs:jsr305:3.0.2")
}
2 changes: 1 addition & 1 deletion scripts/generate_contract_function_param_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def add_with_param_type(bit_width, param_type, map_method_name, exception_commen
"* @return {@code this}\n"
"*/\n"
"public ContractFunctionParameters addInt" + str(bit_width) + "Array(" + param_type + "[] intArray) {\n"
" @Var ByteString arrayBytes = ByteString.copyFrom(\n"
" ByteString arrayBytes = ByteString.copyFrom(\n"
" J8Arrays.stream(intArray)." + map_method_name + "(i -> int256(i, " + str(bit_width) + "))\n"
" .collect(Collectors.toList()));\n"
"\n"
Expand Down
8 changes: 1 addition & 7 deletions sdk-dependency-versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ dependencies.constraints {
api("com.esaulpaugh:headlong:12.1.0") {
because("headlong")
}
api("com.github.spotbugs:spotbugs-annotations:4.8.6") {
because("com.github.spotbugs.annotations")
}
api("com.google.errorprone:error_prone_annotations:2.21.1") {
because("com.google.errorprone.annotations")
}
api("com.google.code.gson:gson:2.10.1") {
because("com.google.gson")
}
Expand All @@ -58,7 +52,7 @@ dependencies.constraints {
api("io.grpc:grpc-stub:1.64.0") {
because("io.grpc.stub")
}
api("javax.annotation:javax.annotation-api:1.3.2") {
api("com.google.code.findbugs:jsr305:3.0.2") {
because("java.annotation")
}
api("org.bouncycastle:bcpkix-jdk18on:1.78.1") {
Expand Down
4 changes: 1 addition & 3 deletions sdk-full/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
requires org.bouncycastle.provider;
requires org.slf4j;

requires static com.github.spotbugs.annotations;
requires static com.google.errorprone.annotations;
requires static java.annotation;
requires static transitive java.annotation;

exports com.hedera.hashgraph.sdk;
exports com.hedera.hashgraph.sdk.logger;
Expand Down
2 changes: 0 additions & 2 deletions sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ testModuleInfo {
requires("org.mockito")

requiresStatic("java.annotation")
requiresStatic("com.github.spotbugs.annotations")
requiresStatic("com.google.errorprone.annotations")

runtimeOnly("io.grpc.netty.shaded")
runtimeOnly("org.slf4j.simple")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.hedera.hashgraph.sdk.proto.SchedulableTransactionBody;
import com.hedera.hashgraph.sdk.proto.TransactionBody;
import com.hedera.hashgraph.sdk.proto.TransactionResponse;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.grpc.MethodDescriptor;
import java.time.Duration;

Expand Down Expand Up @@ -194,10 +193,6 @@ public AccountCreateTransaction setProxyAccountId(AccountId proxyAccountId) {
* @return the duration for auto-renew
*/
@Nullable
@SuppressFBWarnings(
value = "EI_EXPOSE_REP",
justification = "A Duration can't actually be mutated"
)
public Duration getAutoRenewPeriod() {
return autoRenewPeriod;
}
Expand All @@ -214,10 +209,6 @@ public Duration getAutoRenewPeriod() {
* @param autoRenewPeriod the auto renew period for this account.
* @return {@code this}
*/
@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "A Duration can't actually be mutated"
)
public AccountCreateTransaction setAutoRenewPeriod(Duration autoRenewPeriod) {
requireNotFrozen();
Objects.requireNonNull(autoRenewPeriod);
Expand Down
Loading

0 comments on commit 63438db

Please sign in to comment.