Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It provides all necessary resources for a Java project to enforce this coding st
- [SpotBugs](https://spotbugs.github.io)
- [Error Prone](https://errorprone.info)

❗This project requires a JDK version of 17 or higher.❗
❗This project requires a JDK version of 21 or higher.❗

Moreover, this project provides some sample classes that already use this style guide.
These classes can be used as such but are not required in this project.
Expand Down Expand Up @@ -54,4 +54,4 @@ Source code (snippets, examples, and classes) are using the [MIT license](https:

[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://en.wikipedia.org/wiki/MIT_License)
[![License: CC BY 4.0](https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
![JDK17](https://img.shields.io/badge/jdk-17-blue.svg)
![JDK21](https://img.shields.io/badge/jdk-21-blue.svg)
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle</artifactId>
<version>5.26.0-SNAPSHOT</version>
<version>6.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Java coding style</name>
Expand Down Expand Up @@ -47,7 +47,7 @@
<properties>
<source.encoding>UTF-8</source.encoding>
<project.build.sourceEncoding>${source.encoding}</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>21</java.version>
<java.jdk.version>21</java.jdk.version>

<module.name>${project.groupId}.codingstyle</module.name>
Expand Down Expand Up @@ -360,7 +360,7 @@
<recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe>
<recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe>
<recipe>org.openrewrite.staticanalysis.RemoveExtraSemicolons</recipe>
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
<recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>
<recipe>org.openrewrite.java.migrate.util.SequencedCollection</recipe>
<recipe>org.openrewrite.java.migrate.lang.var.UseVarForObject</recipe>
<recipe>org.openrewrite.java.migrate.net.JavaNetAPIs</recipe>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/hm/hafner/util/FilteredLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
*/
public class FilteredLog implements Serializable {
@Serial
private static final long serialVersionUID = -8552323621953159904L;
private static final long serialVersionUID = 6956036398485594488L;

private static final int DEFAULT_MAX_LINES = 20;

private final String title;
private final int maxLines;
private int lines;

@SuppressWarnings("serial")
private final List<String> infoMessages = new ArrayList<>();
@SuppressWarnings("serial")
private final List<String> errorMessages = new ArrayList<>();
@SuppressWarnings("PMD.LooseCoupling")
private final ArrayList<String> infoMessages = new ArrayList<>();
@SuppressWarnings("PMD.LooseCoupling")
private final ArrayList<String> errorMessages = new ArrayList<>();

private transient ReentrantLock lock = new ReentrantLock();

Expand Down
8 changes: 3 additions & 5 deletions src/main/java/edu/hm/hafner/util/Generated.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

/**
* This annotation is used to mark source code that has been generated or is somehow not relevant for style checking or
* code coverage analysis. It is quite similar to the JSR305 annotation. The
* main difference is that it has class retention, so it is available for tools that work on bytecode (like JaCoCo,
* PIT, or SpotBugs).
* code coverage analysis. It is quite similar to the annotation of the abandoned JSR305 project. The main difference is
* that it has class retention, so it is available for tools that work on bytecode (like JaCoCo, PIT, or SpotBugs).
*/
@Retention(CLASS)
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD,
LOCAL_VARIABLE, PARAMETER})
@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD, LOCAL_VARIABLE, PARAMETER})
public @interface Generated {
/**
* An optional property that identifies the code generator.
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/edu/hm/hafner/util/EnsureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void shouldNotThrowExceptionIfContractIsValid() {
Ensure.that("").isNotNull();
Ensure.that("", "").isNotNull();
Ensure.that(null, (Object) null).isNull();
Ensure.that(new String[] {""}).isNotEmpty();
Ensure.that(new String[]{""}).isNotEmpty();
Ensure.that(SOME_STRING).isNotEmpty();
Ensure.that(SOME_STRING).isNotBlank();
Ensure.that("").isInstanceOf(String.class);
Expand Down Expand Up @@ -116,7 +116,7 @@ void shouldThrowExceptionIfEmpty() {
Ensure.that(Lists.newArrayList("", null, "")).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(
AssertionError.class);
assertThatThrownBy(() ->
Ensure.that(new String[] {"", null, ""}).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
Ensure.that(new String[]{"", null, ""}).isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
assertThatThrownBy(() ->
Ensure.that("").isNotEmpty(ERROR_MESSAGE)).isInstanceOf(AssertionError.class);
assertThatThrownBy(() ->
Expand All @@ -128,7 +128,7 @@ void shouldThrowExceptionIfEmpty() {
assertThatThrownBy(() ->
Ensure.that(Lists.newArrayList("", null, "")).isNotEmpty()).isInstanceOf(AssertionError.class);
assertThatThrownBy(() ->
Ensure.that(new String[] {"", null, ""}).isNotEmpty()).isInstanceOf(AssertionError.class);
Ensure.that(new String[]{"", null, ""}).isNotEmpty()).isInstanceOf(AssertionError.class);
assertThatThrownBy(() ->
Ensure.that("").isNotEmpty()).isInstanceOf(AssertionError.class);
assertThatThrownBy(() ->
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/edu/hm/hafner/util/LineRangeListTest.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package edu.hm.hafner.util;

import java.util.List;

import org.junit.jupiter.api.Test;

import java.util.List;

import static org.assertj.core.api.Assertions.*;

/**
Expand Down Expand Up @@ -43,17 +43,17 @@ void shouldSupportSetOperations() {
var range = new LineRange(1, 2);
list.add(range);

assertThat(list.get(0)).isEqualTo(range);
assertThat(list.get(0)).isNotSameAs(range);
assertThat(list.getFirst()).isEqualTo(range);
assertThat(list.getFirst()).isNotSameAs(range);
assertThat(list).hasSize(1);

var other = new LineRange(3, 4);
assertThat(list.set(0, other)).isEqualTo(range);
assertThat(list.get(0)).isEqualTo(other);
assertThat(list.get(0)).isNotSameAs(other);
assertThat(list.getFirst()).isEqualTo(other);
assertThat(list.getFirst()).isNotSameAs(other);
assertThat(list).hasSize(1);

assertThat(list.remove(0)).isEqualTo(other);
assertThat(list.removeFirst()).isEqualTo(other);
assertThat(list).hasSize(0);
}

Expand Down
Loading