Skip to content

Commit 170d10d

Browse files
committed
build: remove inconsistent code analysis / align with hedera-services
Signed-off-by: Jendrik Johannes <[email protected]>
1 parent 62a6fcb commit 170d10d

File tree

72 files changed

+172
-645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+172
-645
lines changed

.github/workflows/build.yml

-7
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ jobs:
102102
run: |
103103
./gradlew -POPERATOR_ID=$OPERATOR_ID -POPERATOR_KEY=$OPERATOR_KEY -PHEDERA_NETWORK=$HEDERA_NETWORK jacocoTestReport --scan
104104
105-
- name: Sonar Scan
106-
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
107-
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
110-
run: ./gradlew sonarqube --info --scan
111-
112105
- name: Upload coverage to Codecov
113106
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
114107
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0

gradle/plugins/build.gradle.kts

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ repositories.gradlePluginPortal()
2626

2727
dependencies {
2828
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:2.0.2")
29-
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.12")
3029
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
3130
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
32-
implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0")
33-
implementation("org.gradlex:extra-java-module-info:1.8")
31+
implementation("org.gradlex:extra-java-module-info:1.9")
3432
implementation("org.gradlex:java-module-dependencies:1.6.5")
3533
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1")
36-
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373")
3734

3835
implementation("org.gradle.toolchains:foojay-resolver:0.8.0")
3936
implementation("com.gradle:develocity-gradle-plugin:3.17.2")

gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts

-9
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*
1919
*/
2020

21-
import net.ltgt.gradle.errorprone.errorprone
22-
2321
plugins {
2422
id("application")
2523
id("com.hedera.gradle.java-base")
@@ -30,13 +28,6 @@ javaModuleDependencies {
3028
moduleNameToGA.put("com.hedera.hashgraph.sdk.full", "com.hedera.hashgraph:sdk-full")
3129
}
3230

33-
tasks.withType<JavaCompile>().configureEach {
34-
options.errorprone {
35-
disable("DefaultPackage")
36-
disable("SystemOut")
37-
}
38-
}
39-
4031
tasks.register<RunAllExample>("runAllExamples") {
4132
workingDirectory = rootDir
4233
sources.from(sourceSets.main.get().java.asFileTree)

gradle/plugins/src/main/kotlin/com.hedera.gradle.java-base.gradle.kts

+17-50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import net.ltgt.gradle.errorprone.errorprone
2-
31
/*-
42
*
53
* Hedera Java SDK
@@ -23,7 +21,6 @@ import net.ltgt.gradle.errorprone.errorprone
2321
plugins {
2422
id("java")
2523
id("jacoco")
26-
id("net.ltgt.errorprone")
2724
id("org.gradlex.java-module-dependencies")
2825
id("com.hedera.gradle.base")
2926
id("com.hedera.gradle.repositories")
@@ -45,56 +42,26 @@ jvmDependencyConflicts {
4542
consistentResolution.platform("com.hedera.hashgraph:sdk-dependency-versions")
4643
}
4744

48-
dependencies {
49-
// https://github.com/google/error-prone
50-
// https://errorprone.info/
51-
errorprone("com.google.errorprone:error_prone_core:2.21.1")
52-
53-
// https://github.com/uber/NullAway
54-
errorprone("com.uber.nullaway:nullaway:0.10.14")
55-
56-
// https://github.com/grpc/grpc-java-api-checker
57-
errorprone("io.grpc:grpc-java-api-checker:1.1.0")
58-
}
45+
val deactivatedCompileLintOptions =
46+
listOf(
47+
"module", // module not found when doing 'exports to ...'
48+
"serial", // serializable class ... has no definition of serialVersionUID
49+
"processing", // No processor claimed any of these annotations: ...
50+
"try", // auto-closeable resource ignore is never referenced... (AutoClosableLock)
51+
"missing-explicit-ctor", // class ... declares no explicit constructors
52+
"removal",
53+
"deprecation",
54+
"overrides", // overrides equals, but neither it ... overrides hashCode method
55+
"unchecked",
56+
"rawtypes",
57+
"exports",
58+
"dep-ann"
59+
)
5960

6061
tasks.withType<JavaCompile>().configureEach {
6162
options.encoding = "UTF-8"
62-
63-
// Disable warnings because I'm tired of them :P
64-
options.isWarnings = false
65-
66-
options.errorprone {
67-
// https://github.com/uber/NullAway
68-
warn("NullAway")
69-
option("NullAway:AnnotatedPackages", "com.hedera.hashgraph.sdk")
70-
option("NullAway:TreatGeneratedAsUnannotated", "true")
71-
72-
// https://github.com/grpc/grpc-java-api-checker
73-
disable("GrpcExperimentalApi")
74-
warn("GrpcInternal")
75-
76-
// Enable _all_ error prone checks then selectively disble
77-
// Checks that are default-disabled are enabled as warnings
78-
allDisabledChecksAsWarnings = true
79-
disable("TryFailRefactoring")
80-
disable("ThrowSpecificExceptions")
81-
disable("FutureReturnValueIgnored")
82-
disable("FieldCanBeFinal")
83-
disable("Finally")
84-
disable("BooleanParameter")
85-
disable("ThreadJoinLoop")
86-
disable("UnnecessaryDefaultInEnumSwitch")
87-
disable("UngroupedOverloads")
88-
disable("InlineMeSuggester")
89-
90-
// Uncomment do disable Android + JDK7 checks
91-
// disable("Java7ApiChecker")
92-
// disable("AndroidJdkLibsChecker")
93-
94-
// Ignore generated and protobuf code
95-
disableWarningsInGeneratedCode = true
96-
excludedPaths = ".*generated.*"
97-
}
63+
options.compilerArgs.add("-Werror")
64+
options.compilerArgs.add("-Xlint:all,-" + deactivatedCompileLintOptions.joinToString(",-"))
9865
}
9966

10067
tasks.withType<AbstractArchiveTask>().configureEach {

gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts

+3-46
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
2424
plugins {
2525
id("java-library")
2626
id("com.google.protobuf")
27-
id("com.github.spotbugs")
28-
id("org.sonarqube")
2927
id("com.hedera.gradle.java-base")
3028
id("com.hedera.gradle.publish")
3129
}
@@ -105,16 +103,16 @@ tasks.jacocoTestReport {
105103
protobuf {
106104
protoc {
107105
// shouldn't be updated for now (breaking changes after 4.x.x)
108-
artifact = "com.google.protobuf:protoc:3.25.3"
106+
artifact = "com.google.protobuf:protoc:3.25.4"
109107
}
110108
plugins {
111109
id("grpc") {
112-
artifact = "io.grpc:protoc-gen-grpc-java:1.50.2"
110+
artifact = "io.grpc:protoc-gen-grpc-java:1.66.0"
113111
}
114112
}
115113
}
116114
tasks.generateProto {
117-
plugins { plugins.register("grpc") }
115+
plugins { plugins.register("grpc") { option("@generated=omit") } }
118116
}
119117

120118
tasks.compileJava {
@@ -132,44 +130,3 @@ tasks.jar {
132130
sourceSets.all {
133131
configurations[getTaskName("", "compileProtoPath")].extendsFrom(configurations["internal"])
134132
}
135-
136-
spotbugs {
137-
//ignoreFailures = false
138-
//showStackTraces = true
139-
//showProgress = false
140-
//reportLevel = 'default'
141-
//effort = 'default'
142-
//visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
143-
//omitVisitors = [ 'FindNonShortCircuit' ]
144-
reportsDir = layout.buildDirectory.dir("reports/spotbugs")
145-
//includeFilter = file('spotbugs-include.xml')
146-
//excludeFilter = file('spotbugs-exclude.xml')
147-
onlyAnalyze = listOf("com.hedera.hashgraph.sdk.*")
148-
//projectName = name
149-
//release = version
150-
//extraArgs = [ '-nested:false' ]
151-
//jvmArgs = [ '-Duser.language=ja' ]
152-
//maxHeapSize = '512m'
153-
}
154-
155-
tasks.spotbugsMain {
156-
reports.register("html") {
157-
required = true
158-
outputLocation = layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html")
159-
setStylesheet("fancy-hist.xsl")
160-
}
161-
}
162-
163-
dependencies {
164-
spotbugs("com.github.spotbugs:spotbugs:4.8.4")
165-
spotbugs("com.google.code.findbugs:jsr305:3.0.2")
166-
}
167-
168-
sonarqube {
169-
properties {
170-
property("sonar.projectKey", "hashgraph_hedera-sdk-java")
171-
property("sonar.organization", "hashgraph")
172-
property("sonar.host.url", "https://sonarcloud.io")
173-
property("sonar.exclusions", "examples/**")
174-
}
175-
}

gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts

+2-31
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ plugins {
2424
id("org.gradlex.jvm-dependency-conflict-resolution")
2525
}
2626

27-
// Do annotation processing on the classpath, because 'Error Prone' has many non-module dependencies
28-
sourceSets.all {
29-
configurations.getByName(annotationProcessorConfigurationName) {
30-
attributes { attribute(Attribute.of("javaModule", Boolean::class.javaObjectType), false) }
31-
}
32-
}
33-
3427
// Fix or enhance the metadata of third-party Modules. This is about the metadata in the
3528
// repositories: '*.pom' and '*.module' files.
3629
jvmDependencyConflicts.patch {
@@ -41,7 +34,6 @@ jvmDependencyConflicts.patch {
4134
"com.google.android:annotations",
4235
"com.google.code.findbugs:annotations",
4336
"com.google.code.findbugs:jsr305",
44-
"com.google.errorprone:error_prone_annotations",
4537
"com.google.guava:listenablefuture",
4638
"com.google.j2objc:j2objc-annotations",
4739
"org.checkerframework:checker-compat-qual",
@@ -76,21 +68,7 @@ extraJavaModuleInfo {
7668
module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal")
7769
module("com.google.guava:guava", "com.google.common") {
7870
exportAllPackages()
79-
requires("com.google.common.util.concurrent.internal")
80-
requires("java.logging")
81-
}
82-
module("guava-32.1.3-jre.jar", "com.google.common") {
83-
/**
84-
* Repetition of the rule above:
85-
*
86-
* There is an issue when the version is "android", but the selected Jar
87-
* with classifier is "jre". If this causes a problem depends on the local
88-
* Gradle dependency cache state (most likely).
89-
* This is an issue that needs to be investigated and fixed in
90-
* https://github.com/gradlex-org/extra-java-module-info
91-
*/
92-
exportAllPackages()
93-
requires("com.google.common.util.concurrent.internal")
71+
requireAllDefinedDependencies()
9472
requires("java.logging")
9573
}
9674
module("com.google.protobuf:protobuf-java", "com.google.protobuf") {
@@ -128,10 +106,7 @@ extraJavaModuleInfo {
128106
requires("java.logging")
129107
}
130108
module("io.perfmark:perfmark-api", "io.perfmark")
131-
module("javax.annotation:javax.annotation-api", "java.annotation") {
132-
exportAllPackages()
133-
mergeJar("com.google.code.findbugs:jsr305")
134-
}
109+
module("com.google.code.findbugs:jsr305", "java.annotation")
135110
module("org.jetbrains:annotations", "org.jetbrains.annotations")
136111

137112
// Full protobuf only
@@ -160,7 +135,3 @@ extraJavaModuleInfo {
160135
module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter")
161136
module("org.objenesis:objenesis", "org.objenesis")
162137
}
163-
164-
dependencies {
165-
javaModulesMergeJars("com.google.code.findbugs:jsr305:3.0.2")
166-
}

scripts/generate_contract_function_param_methods.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def add_with_param_type(bit_width, param_type, map_method_name, exception_commen
4747
"* @return {@code this}\n"
4848
"*/\n"
4949
"public ContractFunctionParameters addInt" + str(bit_width) + "Array(" + param_type + "[] intArray) {\n"
50-
" @Var ByteString arrayBytes = ByteString.copyFrom(\n"
50+
" ByteString arrayBytes = ByteString.copyFrom(\n"
5151
" J8Arrays.stream(intArray)." + map_method_name + "(i -> int256(i, " + str(bit_width) + "))\n"
5252
" .collect(Collectors.toList()));\n"
5353
"\n"
@@ -70,7 +70,7 @@ def add_with_param_type(bit_width, param_type, map_method_name, exception_commen
7070
exception_comment +
7171
"*/\n"
7272
"public ContractFunctionParameters addUint" + str(bit_width) + "Array(" + param_type + "[] intArray) {\n"
73-
" @Var ByteString arrayBytes = ByteString.copyFrom(\n"
73+
" ByteString arrayBytes = ByteString.copyFrom(\n"
7474
" J8Arrays.stream(intArray)." + map_method_name + "(i -> uint256(i, " + str(bit_width) + "))\n"
7575
" .collect(Collectors.toList()));\n"
7676
"\n"

sdk-dependency-versions/build.gradle.kts

+1-7
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ dependencies.constraints {
2626
api("com.esaulpaugh:headlong:12.1.0") {
2727
because("headlong")
2828
}
29-
api("com.github.spotbugs:spotbugs-annotations:4.8.6") {
30-
because("com.github.spotbugs.annotations")
31-
}
32-
api("com.google.errorprone:error_prone_annotations:2.21.1") {
33-
because("com.google.errorprone.annotations")
34-
}
3529
api("com.google.code.gson:gson:2.10.1") {
3630
because("com.google.gson")
3731
}
@@ -58,7 +52,7 @@ dependencies.constraints {
5852
api("io.grpc:grpc-stub:1.64.0") {
5953
because("io.grpc.stub")
6054
}
61-
api("javax.annotation:javax.annotation-api:1.3.2") {
55+
api("com.google.code.findbugs:jsr305:3.0.2") {
6256
because("java.annotation")
6357
}
6458
api("org.bouncycastle:bcpkix-jdk18on:1.78.1") {

sdk-full/src/main/java/module-info.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
requires org.bouncycastle.provider;
3434
requires org.slf4j;
3535

36-
requires static com.github.spotbugs.annotations;
37-
requires static com.google.errorprone.annotations;
38-
requires static java.annotation;
36+
requires static transitive java.annotation;
3937

4038
exports com.hedera.hashgraph.sdk;
4139
exports com.hedera.hashgraph.sdk.logger;

sdk/build.gradle.kts

-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ testModuleInfo {
3737
requires("org.mockito")
3838

3939
requiresStatic("java.annotation")
40-
requiresStatic("com.github.spotbugs.annotations")
41-
requiresStatic("com.google.errorprone.annotations")
4240

4341
runtimeOnly("io.grpc.netty.shaded")
4442
runtimeOnly("org.slf4j.simple")

sdk/src/main/java/com/hedera/hashgraph/sdk/AccountCreateTransaction.java

-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.hedera.hashgraph.sdk.proto.SchedulableTransactionBody;
2727
import com.hedera.hashgraph.sdk.proto.TransactionBody;
2828
import com.hedera.hashgraph.sdk.proto.TransactionResponse;
29-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3029
import io.grpc.MethodDescriptor;
3130
import java.time.Duration;
3231

@@ -194,10 +193,6 @@ public AccountCreateTransaction setProxyAccountId(AccountId proxyAccountId) {
194193
* @return the duration for auto-renew
195194
*/
196195
@Nullable
197-
@SuppressFBWarnings(
198-
value = "EI_EXPOSE_REP",
199-
justification = "A Duration can't actually be mutated"
200-
)
201196
public Duration getAutoRenewPeriod() {
202197
return autoRenewPeriod;
203198
}
@@ -214,10 +209,6 @@ public Duration getAutoRenewPeriod() {
214209
* @param autoRenewPeriod the auto renew period for this account.
215210
* @return {@code this}
216211
*/
217-
@SuppressFBWarnings(
218-
value = "EI_EXPOSE_REP2",
219-
justification = "A Duration can't actually be mutated"
220-
)
221212
public AccountCreateTransaction setAutoRenewPeriod(Duration autoRenewPeriod) {
222213
requireNotFrozen();
223214
Objects.requireNonNull(autoRenewPeriod);

0 commit comments

Comments
 (0)