Skip to content

Commit 71f7363

Browse files
authored
General review (#41)
* General review * Improving CHANGELOG
1 parent 3adf98a commit 71f7363

13 files changed

+161
-23
lines changed

.cursor/rules/101-java-maven-plugins.mdc renamed to .cursor/rules/101-java-maven-deps-and-plugins.mdc

Lines changed: 141 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
description: Maven plugins
2+
description: Update pom.xlm to add Maven dependencies & plugins
33
globs: pom.xml
44
alwaysApply: false
55
---
6-
# Maven plugins
6+
# Update pom.xlm to add Maven dependencies & plugins
77

88
Explain how to update a pom.xml file defining a set of maven plugins
99

@@ -32,8 +32,15 @@ Update the pom.xml with this set of properties:
3232
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3333

3434
<!-- Dependencies -->
35+
<jspecify.version>1.0.0</jspecify.version>
3536

3637
<!-- Test dependencies -->
38+
<junit.version>5.12.0</junit.version>
39+
<mockito.version>5.18.0</mockito.version>
40+
<assertj.version>3.27.3</assertj.version>
41+
42+
<!-- Maven Extensions -->
43+
<maven-extensions-build-cache.version>1.2.0</maven-extensions-build-cache.version>
3744

3845
<!-- Maven Plugins -->
3946
<maven-plugins-flatten.version>1.7.0</maven-plugins-flatten.version>
@@ -47,13 +54,27 @@ Update the pom.xml with this set of properties:
4754
<maven-plugins-jacoco.version>0.8.13</maven-plugins-jacoco.version>
4855
<maven-plugins-versions.version>2.18.0</maven-plugins-versions.version>
4956
<maven-plugins-git-commit-id.version>4.9.10</maven-plugins-git-commit-id.version>
57+
<maven-plugins-pitest.version>1.19.4</maven-plugins-pitest.version>
58+
<maven-plugins-pitest-junit5.version>1.2.3</maven-plugins-pitest-junit5.version>
59+
<maven-plugins-dependency-check.version>12.1.1</maven-plugins-dependency-check.version>
5060

5161
<!-- Coverage -->
5262
<coverage.level>80</coverage.level>
5363
</properties>
5464
```
5565

56-
## Rule 2: Add flatten-maven-plugin
66+
## Rule 2: Add JSpecify to increase null safety
67+
68+
```xml
69+
<!-- Null Safety Annotations -->
70+
<dependency>
71+
<groupId>org.jspecify</groupId>
72+
<artifactId>jspecify</artifactId>
73+
<version>${jspecify.version}</version>
74+
</dependency>
75+
```
76+
77+
## Rule 3: Add flatten-maven-plugin
5778

5879
Update the pom.xml with this new plugin:
5980

@@ -83,7 +104,7 @@ Update the pom.xml with this new plugin:
83104
</plugin>
84105
```
85106

86-
## Rule 3: Add maven-plugins-enforcer
107+
## Rule 4: Add maven-plugins-enforcer
87108

88109
Update the pom.xml with this new plugin:
89110

@@ -121,7 +142,7 @@ Update the pom.xml with this new plugin:
121142
</plugin>
122143
```
123144

124-
## Rule 4: Add maven-plugins-compiler
145+
## Rule 5: Add maven-plugins-compiler
125146

126147
Create/Update the file $(pwd)/.mvn/jvm.config with the following content:
127148

@@ -179,7 +200,7 @@ Update the pom.xml with this new plugin:
179200
</plugin>
180201
```
181202

182-
## Rule 5: Add maven-plugins-surefire
203+
## Rule 6: Add maven-plugins-surefire
183204

184205
Update the pom.xml with this new plugin:
185206

@@ -200,7 +221,7 @@ Update the pom.xml with this new plugin:
200221
</plugin>
201222
```
202223

203-
## Rule 6: Add maven-failsafe-plugin
224+
## Rule 7: Add maven-failsafe-plugin
204225

205226
Update the pom.xml with this new plugin:
206227

@@ -227,7 +248,7 @@ Update the pom.xml with this new plugin:
227248
</plugin>
228249
```
229250

230-
## Rule 7: Add versions-maven-plugin
251+
## Rule 8: Add versions-maven-plugin
231252

232253
Update the pom.xml with this new plugin:
233254

@@ -242,7 +263,7 @@ Update the pom.xml with this new plugin:
242263
</plugin>
243264
```
244265

245-
## Rule 8: Add git-commit-id-plugin
266+
## Rule 9: Add git-commit-id-plugin
246267

247268
Update the pom.xml with this new plugin:
248269

@@ -268,7 +289,7 @@ Update the pom.xml with this new plugin:
268289
</plugin>
269290
```
270291

271-
## Rule 9: Add jacoco-maven-plugin
292+
## Rule 10: Add jacoco-maven-plugin
272293

273294
Update the pom.xml with this profile to run jacoco:
274295

@@ -333,7 +354,7 @@ Update the pom.xml with this profile to run jacoco:
333354
</profiles>
334355
```
335356

336-
## Rule 10: Add test reports
357+
## Rule 11: Add test reports
337358

338359
Update the pom.xml with this reporting section:
339360

@@ -359,4 +380,113 @@ Update the pom.xml with this reporting section:
359380
</plugin>
360381
</plugins>
361382
</reporting>
383+
```
384+
385+
## Rule 12: Add Pitest profile to analyze the quality of your asserts
386+
387+
```xml
388+
<profile>
389+
<id>pitest</id>
390+
<activation>
391+
<activeByDefault>false</activeByDefault>
392+
</activation>
393+
<build>
394+
<plugins>
395+
<plugin>
396+
<groupId>org.pitest</groupId>
397+
<artifactId>pitest-maven</artifactId>
398+
<version>${maven-plugins-pitest.version}</version>
399+
<configuration>
400+
<targetClasses>
401+
<param>info.jab.cli.*</param>
402+
</targetClasses>
403+
<targetTests>
404+
<param>info.jab.cli.*</param>
405+
</targetTests>
406+
<outputFormats>
407+
<outputFormat>HTML</outputFormat>
408+
<outputFormat>XML</outputFormat>
409+
</outputFormats>
410+
<mutationThreshold>${coverage.level}</mutationThreshold>
411+
<coverageThreshold>${coverage.level}</coverageThreshold>
412+
<timestampedReports>false</timestampedReports>
413+
<verbose>false</verbose>
414+
</configuration>
415+
<dependencies>
416+
<dependency>
417+
<groupId>org.pitest</groupId>
418+
<artifactId>pitest-junit5-plugin</artifactId>
419+
<version>${maven-plugins-pitest-junit5.version}</version>
420+
</dependency>
421+
</dependencies>
422+
<executions>
423+
<execution>
424+
<id>pitest-mutation-testing</id>
425+
<goals>
426+
<goal>mutationCoverage</goal>
427+
</goals>
428+
<phase>verify</phase>
429+
</execution>
430+
</executions>
431+
</plugin>
432+
</plugins>
433+
</build>
434+
</profile>
435+
```
436+
437+
## Rule 13: Add security profile to execute dependency-check
438+
439+
```xml
440+
<profile>
441+
<id>security</id>
442+
<activation>
443+
<activeByDefault>false</activeByDefault>
444+
</activation>
445+
<build>
446+
<plugins>
447+
<plugin>
448+
<groupId>org.owasp</groupId>
449+
<artifactId>dependency-check-maven</artifactId>
450+
<version>${maven-plugins-dependency-check.version}</version>
451+
<configuration>
452+
<outputDirectory>${project.build.directory}/dependency-check</outputDirectory>
453+
<format>ALL</format>
454+
<failBuildOnCVSS>7</failBuildOnCVSS>
455+
<skipProvidedScope>false</skipProvidedScope>
456+
<skipRuntimeScope>false</skipRuntimeScope>
457+
<skipSystemScope>false</skipSystemScope>
458+
<skipTestScope>false</skipTestScope>
459+
<!-- Performance and reliability improvements -->
460+
<nvdApiDelay>4000</nvdApiDelay>
461+
<nvdMaxRetryCount>3</nvdMaxRetryCount>
462+
<nvdValidForHours>24</nvdValidForHours>
463+
<!-- Skip analyzers that might cause issues -->
464+
<nodeAnalyzerEnabled>false</nodeAnalyzerEnabled>
465+
<retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
466+
</configuration>
467+
<executions>
468+
<execution>
469+
<id>dependency-check</id>
470+
<goals>
471+
<goal>check</goal>
472+
</goals>
473+
<phase>verify</phase>
474+
</execution>
475+
</executions>
476+
</plugin>
477+
</plugins>
478+
</build>
479+
</profile>
480+
```
481+
482+
# Rule 14: Add extensions
483+
484+
```xml
485+
<extensions>
486+
<extension>
487+
<groupId>org.apache.maven.extensions</groupId>
488+
<artifactId>maven-build-cache-extension</artifactId>
489+
<version>${maven-extensions-build-cache.version}</version>
490+
</extension>
491+
</extensions>
362492
```

.cursor/rules/113-java-general-guidelines.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: General java rules
2+
description: Java General Guidelines
33
globs: **/*.java
44
alwaysApply: false
55
---

.cursor/rules/114-java-secure-coding.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java Secure coding guidelines
33
globs: **/*.java
44
alwaysApply: false
55
---
6-
# Java Secure Coding Guidelines
6+
# Java Secure coding guidelines
77

88
This document provides essential Java secure coding guidelines, focusing on five key areas: validating all untrusted inputs to prevent attacks like injection and path traversal; protecting against injection attacks (e.g., SQL injection) by using parameterized queries or prepared statements; minimizing the attack surface by adhering to the principle of least privilege and reducing exposure; employing strong, current cryptographic algorithms for hashing, encryption, and digital signatures while avoiding deprecated ones; and handling exceptions securely by avoiding the exposure of sensitive information in error messages to users and logging detailed, non-sensitive diagnostic information for developers.
99

.cursor/rules/115-java-concurrency.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java rules for Concurrency objects
33
globs: **/*.java
44
alwaysApply: false
55
---
6-
# Java Concurrency
6+
# Java rules for Concurrency objects
77

88
Effective Java concurrency relies on understanding thread safety fundamentals, using `java.util.concurrent` utilities, and managing thread pools with `ExecutorService`. Key practices include implementing concurrent design patterns like Producer-Consumer, leveraging `CompletableFuture` for asynchronous tasks, and ensuring thread safety through immutability and safe publication. Performance aspects like lock contention and memory consistency must be considered. Thorough testing, including stress tests and thread dump analysis, is crucial. Modern Java offers virtual threads for enhanced scalability, structured concurrency for simplified task management, and scoped values for safer thread-shared data as alternatives to thread-locals.
99

.cursor/rules/116-java-logging.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Java rules to apply logging guidelines in Java applications
2+
description: Java Logging Best Practices
33
globs: **/*.java
44
alwaysApply: false
55
---

.cursor/rules/121-java-unit-testing.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java Unit testing guidelines
33
globs: **/*Test.java
44
alwaysApply: false
55
---
6-
# Java Unit testing
6+
# Java Unit testing guidelines
77

88
Effective Java unit testing involves using JUnit 5 annotations and AssertJ for fluent assertions. Tests should follow the Given-When-Then structure with descriptive names for clarity. Each test must have a single responsibility, be independent, and leverage parameterized tests for data variations. Mocking dependencies with frameworks like Mockito is crucial for isolating the unit under test. While code coverage is a useful guide, the focus should be on meaningful tests for critical logic and edge cases. Test classes and methods should typically be package-private. Strategies for code splitting include small test methods and helper functions. Anti-patterns like testing implementation details, hard-coded values, and ignoring failures should be avoided. Proper state management involves isolated state and immutable objects, and error handling should include testing for expected exceptions and their messages.
99

.cursor/rules/122-java-integration-testing.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java Integration testing guidelines
33
globs: **/*IT.java
44
alwaysApply: false
55
---
6-
# Java Integration Testing Guidelines
6+
# Java Integration testing guidelines
77

88
These guidelines aim to ensure consistency, reliability, and maintainability of integration tests within the project.
99

.cursor/rules/131-java-refactoring-with-modern-features.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Java rules to apply modern features released in java8+
2+
description: Modern Java Development Guidelines (Java 8+)
33
globs: **/*.java
44
alwaysApply: false
55
---

.cursor/rules/132-java-functional-programming.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
description: Java rules for Functional programming
2+
description: Java Functional Programming rules
33
globs: **/*.java
44
alwaysApply: false
55
---
6-
# Java Functional Programming
6+
# Java Functional Programming rules
77

88
Java functional programming revolves around immutable objects and state transformations, ensuring functions are pure (no side effects, depend only on inputs). It leverages functional interfaces, concise lambda expressions, and the Stream API for collection processing. Core paradigms include function composition, `Optional` for null safety, and higher-order functions. Modern Java features like Records enhance immutable data transfer, while pattern matching (for `instanceof` and `switch`) and switch expressions improve conditional logic. Sealed classes and interfaces enable controlled, exhaustive hierarchies, and upcoming Stream Gatherers will offer advanced custom stream operations.
99

.cursor/rules/133-java-data-oriented-programming.mdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java rules to apply data oriented programming style
33
globs: **/*.java
44
alwaysApply: false
55
---
6-
# Java Data-Oriented Programming
6+
# Java rules to apply data oriented programming style
77

88
Java Data-Oriented Programming emphasizes separating code (behavior) from data structures, which should ideally be immutable (e.g., using records). Data manipulation should occur via pure functions that transform data into new instances. It's often beneficial to keep data structures flat and denormalized (using IDs for references) where appropriate, and to start with generic data representations (like `Map<String, Object>`) converting to specific types only when necessary. Data integrity is ensured through pure validation functions. Flexible, generic data access layers facilitate working with various data types and storage mechanisms. All data transformations should be explicit, traceable, and composed of clear, pure functional steps.
99

0 commit comments

Comments
 (0)