Skip to content

Commit ac8fa74

Browse files
committed
feat(ci): improve code quality
- replace deprecated string templates with `String.format` - updated `.markdown-link-check.json` to ignore `localhost` links - added `java-pmd-ruleset.xml` to disable PMD rules for specific code patterns - upgrade `jackson-databind` to version 2.18.1 - disabled spell checking linters in `.mega-linter.yml`.
1 parent a9e6659 commit ac8fa74

File tree

16 files changed

+163
-77
lines changed

16 files changed

+163
-77
lines changed

.github/workflows/maven.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
---
12
name: Build and Test
23

34
on:
45
push:
5-
branches: [ "main" ]
6+
branches:
7+
- "main"
68
pull_request:
7-
branches: [ "main" ]
9+
branches:
10+
- "main"
11+
12+
permissions:
13+
contents: read
14+
actions: none
815

916
jobs:
1017
build:
@@ -14,8 +21,8 @@ jobs:
1421
- name: Set up JDK 21
1522
uses: actions/setup-java@v4
1623
with:
17-
java-version: '21'
18-
distribution: 'corretto'
24+
java-version: "21"
25+
distribution: "corretto"
1926
cache: maven
2027
- name: Build all modules
2128
run: mvn -B package

.github/workflows/mega-linter.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
uses: actions/checkout@v4
2828

2929
- name: Setup Java
30-
uses: actions/setup-java@v3
30+
uses: actions/setup-java@v4
3131
with:
32-
java-version: 21
33-
distribution: corretto
32+
java-version: "21"
33+
distribution: "corretto"
3434

3535
- name: MegaLinter
3636
uses: oxsecurity/megalinter/flavors/[email protected]
@@ -45,4 +45,4 @@ jobs:
4545
name: MegaLinter reports
4646
path: |
4747
megalinter-reports
48-
mega-linter.log
48+
mega-linter.log

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ JEP*/.idea/
55
*.iml
66
*/target/
77

8-
target
8+
target
9+
10+
megalinter-reports

.lycheeignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
http://localhost
2+
http://localhost/*

.markdown-link-check.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "^http://localhost"
5+
}
6+
]
7+
}

.mega-linter.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
DISABLE_LINTERS:
3+
- COPYPASTE_JSCPD
4+
- JAVA_CHECKSTYLE
5+
- JAVA_PMD
6+
- SPELL_CSPELL

JEP431/src/main/java/com/jep/JEP431.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ public static void main( String[] args ) {
3737
orderedSet.addLast("two");
3838
orderedSet.addLast("three");
3939

40-
System.out.println(STR."Original set: \{orderedSet}");
41-
System.out.println(STR."First element: \{orderedSet.getFirst()}");
42-
System.out.println(STR."Last element: \{orderedSet.getLast()}");
40+
System.out.println("Original set: " + orderedSet);
41+
System.out.println("First element: " + orderedSet.getFirst());
42+
System.out.println("Last element: " + orderedSet.getLast());
4343

4444
// Reverse the order of the set
45-
System.out.println(STR."Reversed set: \{orderedSet.reversed()}");
45+
System.out.println("Reversed set: " + orderedSet.reversed());
4646

4747
// Move an existing element to the first position
4848
orderedSet.addFirst("two");
49-
System.out.println(STR."Set with 'two' moved to the first position: \{orderedSet}");
49+
System.out.println("Set with 'two' moved to the first position: " + orderedSet);
5050

5151
// Example with SequencedSet using LinkedHashMap
5252
SequencedMap<String, Integer> orderedMap = new LinkedHashMap<>();
@@ -55,15 +55,15 @@ public static void main( String[] args ) {
5555
orderedMap.putLast("two", 2);
5656
orderedMap.putLast("three", 3);
5757

58-
System.out.println(STR."Original map: \{orderedMap}");
59-
System.out.println(STR."First entry: \{orderedMap.firstEntry()}");
60-
System.out.println(STR."Last entry: \{orderedMap.lastEntry()}");
58+
System.out.println("Original map: " + orderedMap);
59+
System.out.println("First entry: " + orderedMap.firstEntry());
60+
System.out.println("Last entry: " + orderedMap.lastEntry());
6161

6262
// Reverse the order of the map
63-
System.out.println(STR."Reversed map: \{orderedMap.reversed()}");
63+
System.out.println("Reversed map: " + orderedMap.reversed());
6464

6565
// Move an existing entry to the first position
6666
orderedMap.putFirst("two", 2);
67-
System.out.println(STR."Map with 'two' moved to the first position: \{orderedMap}");
67+
System.out.println("Map with 'two' moved to the first position: " + orderedMap);
6868
}
6969
}

JEP444/JEP_444/src/main/java/com/jep/PlatformThread.java

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import java.util.concurrent.Executors;
77
import java.util.concurrent.TimeUnit;
88

9-
import static com.jep.SimulatedIOTask.execute;
10-
119
/**
1210
* Demonstrates the use of traditional Platform Threads for comparison with Virtual Threads.
1311
*

JEP444/VirtualThreadExample/docs/index.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
## Overview
44

5-
This project compares the performance of platform threads and virtual threads in Java for making concurrent API requests to a locally hosted PokeAPI instance.
5+
This project compares the performance of platform threads and virtual threads in Java for making concurrent API
6+
requests to a locally hosted PokeAPI instance.
67

78
## Setup
89

9-
- **API**: Locally hosted PokeAPI (http://localhost/api/v2/pokemon/)
10+
- **API**: Locally hosted PokeAPI (<http://localhost/api/v2/pokemon/>)
1011
- **Number of Requests**: 1025
1112
- **Java Version**: Java 21 (for virtual thread support)
1213

@@ -27,10 +28,10 @@ For detailed setup instructions and troubleshooting, refer to the [official Poke
2728

2829
## Results
2930

30-
| Thread Type | Execution Time |
31-
|-------------|----------------|
32-
| Platform Threads | 1403 ms |
33-
| Virtual Threads | 1017 ms |
31+
| Thread Type | Execution Time |
32+
|------------------|----------------|
33+
| Platform Threads | 1403 ms |
34+
| Virtual Threads | 1017 ms |
3435

3536
Virtual threads showed a performance improvement of approximately 27.5% compared to platform threads.
3637

JEP444/VirtualThreadExample/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<dependency>
2222
<groupId>com.fasterxml.jackson.core</groupId>
2323
<artifactId>jackson-databind</artifactId>
24-
<version>2.13.0</version>
24+
<version>2.18.1</version>
2525
</dependency>
2626
<dependency>
2727
<groupId>junit</groupId>

JEP444/VirtualThreadExample/src/main/java/com/jep/PlatformThreadPokemonFetcher.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public static void main(String[] args) {
3535

3636
executorService.shutdown();
3737
long end = System.currentTimeMillis();
38+
long durationTime = end - start;
3839

39-
LOGGER.info(STR."Time taken: \{end - start}ms");
40+
LOGGER.info(String.format("Time taken: %dms", durationTime));
4041
}
4142
}

JEP444/VirtualThreadExample/src/main/java/com/jep/PokemonService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static void fetchPokemon(int pokemonId) {
2020

2121
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
2222

23-
LOGGER.info(STR."Fetched Pokemon \{pokemonId}: \{response.body()}");
23+
LOGGER.info(String.format("Fetched Pokemon %s: %s", pokemonId, response.body()));
2424
} catch (Exception e) {
25-
LOGGER.severe(STR."Error fetching Pokemon: \{pokemonId}");
25+
LOGGER.severe(String.format("Error fetching Pokemon: %s", pokemonId));
2626
e.printStackTrace();
2727
}
2828
}

JEP444/VirtualThreadExample/src/main/java/com/jep/VirtualThreadPokemonFetcher.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public static void main( String[] args ) {
3535
}
3636

3737
long endTime = System.currentTimeMillis();
38-
LOGGER.info(STR."Total execution time: \{endTime - startTime} milliseconds");
38+
long durationTime = endTime - startTime;
39+
LOGGER.info(String.format("Total execution time: %d milliseconds", durationTime));
3940
}
4041
}

0 commit comments

Comments
 (0)