Skip to content

Commit 306c51d

Browse files
committed
Who am I? Why am I hear?
1 parent 80f0785 commit 306c51d

6 files changed

Lines changed: 49 additions & 30 deletions

File tree

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
uses: actions/setup-java@v4
3232
with:
3333
distribution: 'temurin'
34-
java-version: 18
34+
java-version: 21
3535
- name: Setup Gradle
3636
uses: gradle/actions/setup-gradle@v4
3737
- name: Build with Gradle

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java openjdk-25.0.1

build.gradle

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
plugins {
2-
id 'java'
3-
id 'com.adarshr.test-logger' version '4.0.0'
42
id 'checkstyle'
3+
id 'com.adarshr.test-logger' version '4.0.0'
4+
id "com.github.spotbugs" version "6.0.23"
55
id 'idea' // optional (to generate IntelliJ IDEA project files)
6+
id 'java'
67
}
78

89
group = 'com.example'
910
version = '1.0-SNAPSHOT'
1011

1112
java {
12-
sourceCompatibility = JavaVersion.VERSION_18
13+
sourceCompatibility = JavaVersion.VERSION_21
14+
targetCompatibility = JavaVersion.VERSION_21
1315
}
1416

1517
repositories {
@@ -18,36 +20,33 @@ repositories {
1820
}
1921

2022
dependencies {
21-
testImplementation(platform('org.junit:junit-bom:5.11.2'))
22-
testImplementation('org.junit.jupiter:junit-jupiter')
23-
testImplementation ('org.junit.jupiter:junit-jupiter-params')
24-
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
23+
testImplementation platform('org.junit:junit-bom:5.11.2')
24+
testImplementation 'org.junit.jupiter:junit-jupiter'
25+
testImplementation 'org.junit.jupiter:junit-jupiter-params'
26+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
27+
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.6'
28+
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
29+
testCompileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.6'
2530
}
2631

2732
test {
2833
useJUnitPlatform()
2934
}
3035

31-
apply plugin: 'checkstyle'
3236
checkstyle {
33-
toolVersion = '10.3' // Specify the Checkstyle version
34-
configFile = file('config/checkstyle/checkstyle.xml') // Path to your checkstyle.xml
35-
36-
ignoreFailures = false
37-
showViolations = true
37+
toolVersion '10.18.1'
38+
maxWarnings = 0
3839
}
3940

40-
checkstyleMain {
41-
source ='src/main/java'
42-
}
43-
44-
checkstyleTest {
45-
source ='src/test/java'
41+
configurations.checkstyle {
42+
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
43+
select("com.google.guava:guava:23.0")
44+
}
4645
}
4746

48-
tasks.withType(Checkstyle) {
47+
tasks.withType(Checkstyle).configureEach {
4948
reports {
50-
xml.required.set(false)
51-
html.required.set(true) // Enable HTML report
49+
xml.required = false
50+
html.required = true
5251
}
53-
}
52+
}

config/checkstyle/checkstyle.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@
271271
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
272272
</module>
273273
<module name="Indentation">
274-
<property name="basicOffset" value="2"/>
275-
<property name="braceAdjustment" value="2"/>
276-
<property name="caseIndent" value="2"/>
277-
<property name="throwsIndent" value="4"/>
274+
<property name="basicOffset" value="4"/>
275+
<property name="braceAdjustment" value="4"/>
276+
<property name="caseIndent" value="4"/>
277+
<property name="throwsIndent" value="8"/>
278278
<property name="lineWrappingIndentation" value="4"/>
279-
<property name="arrayInitIndent" value="2"/>
279+
<property name="arrayInitIndent" value="4"/>
280280
</module>
281281
<module name="AbbreviationAsWordInName">
282282
<property name="ignoreFinal" value="false"/>

src/main/java/com/example/Calculator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
package com.example;
22

3+
/**
4+
* A simple calculator class.
5+
*/
36
public class Calculator {
7+
8+
/**
9+
* Adds two integers.
10+
*
11+
* @param a The first integer to add
12+
* @param b The second integer to add
13+
* @return the sum of a and b
14+
*/
415
public int add(int a, int b) {
516
return a + b;
617
}

src/test/java/com/example/CalculatorTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import org.junit.jupiter.api.*;
5+
import org.junit.jupiter.api.AfterAll;
6+
import org.junit.jupiter.api.AfterEach;
7+
import org.junit.jupiter.api.BeforeAll;
8+
import org.junit.jupiter.api.BeforeEach;
9+
import org.junit.jupiter.api.DisplayName;
10+
import org.junit.jupiter.api.Test;
611
import org.junit.jupiter.params.ParameterizedTest;
712
import org.junit.jupiter.params.provider.CsvSource;
813

14+
/**
15+
* JUnit 5 Jupiter unit test of the Calculator class.
16+
*/
917
@DisplayName("Testing Calculator class")
1018
public class CalculatorTest {
1119

0 commit comments

Comments
 (0)