Skip to content

Commit

Permalink
Merge pull request #1012 from jenkinsci/remove-line-range
Browse files Browse the repository at this point in the history
Replace `LineRange` with codingstyle version
  • Loading branch information
uhafner authored Feb 23, 2024
2 parents a7526aa + b4e82d6 commit 7fc181c
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 801 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
- name: Build with Maven
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
cache: maven

- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
- name: Generate coverage with JaCoCo
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quality-monitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.5
maven-version: 3.9.6
- name: Build with Maven
env:
BROWSER: chrome-container
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-badges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
check-latest: true
cache: 'maven'
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.5
maven-version: 3.9.6
- name: Build and test with Maven
run: mvn -V --color always -ntp clean verify -Dgpg.skip -Pdepgraph | tee maven.log
- name: Run Quality Monitor
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>edu.hm.hafner</groupId>
<artifactId>codingstyle-pom</artifactId>
<version>3.42.0</version>
<version>3.43.0</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -53,7 +53,7 @@

<properties>
<scmTag>HEAD</scmTag>
<revision>11.21.0</revision>
<revision>12.0.0</revision>
<changelist>-SNAPSHOT</changelist>

<module.name>edu.hm.hafner.analysis.model</module.name>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/hm/hafner/analysis/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.apache.commons.lang3.StringUtils;

import edu.hm.hafner.util.Ensure;
import edu.hm.hafner.util.LineRange;
import edu.hm.hafner.util.LineRangeList;
import edu.hm.hafner.util.PathUtil;
import edu.hm.hafner.util.TreeString;
import edu.umd.cs.findbugs.annotations.CheckForNull;
Expand Down
37 changes: 8 additions & 29 deletions src/main/java/edu/hm/hafner/analysis/IssueBuilder.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package edu.hm.hafner.analysis;

import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.UUID;

import org.apache.commons.lang3.StringUtils;

import com.google.errorprone.annotations.CanIgnoreReturnValue;

import edu.hm.hafner.util.LineRange;
import edu.hm.hafner.util.LineRangeList;
import edu.hm.hafner.util.PathUtil;
import edu.hm.hafner.util.TreeString;
import edu.hm.hafner.util.TreeStringBuilder;
Expand Down Expand Up @@ -42,6 +39,7 @@ public class IssueBuilder implements AutoCloseable {
private static final String UNDEFINED = "-";
private static final TreeString UNDEFINED_TREE_STRING = TreeString.valueOf(UNDEFINED);
private static final TreeString EMPTY_TREE_STRING = TreeString.valueOf(StringUtils.EMPTY);
private static final PathUtil PATH_UTIL = new PathUtil();

private final TreeStringBuilder fileNameBuilder = new TreeStringBuilder();
private final TreeStringBuilder packageNameBuilder = new TreeStringBuilder();
Expand Down Expand Up @@ -88,7 +86,7 @@ public class IssueBuilder implements AutoCloseable {
private UUID id = UUID.randomUUID();

/**
* Sets the unique ID of the issue. If not set then an ID will be generated.
* Sets the unique ID of the issue. If not set, then an ID will be generated.
*
* @param id
* the ID
Expand All @@ -102,7 +100,7 @@ public IssueBuilder setId(final UUID id) {
}

/**
* Sets additional properties from the statical analysis tool. This object could be used to store tool specific
* Sets additional properties from the statical analysis tool. This object could be used to store tool-specific
* information.
*
* @param additionalProperties
Expand Down Expand Up @@ -153,11 +151,11 @@ TreeString internFileName(@CheckForNull final String unsafeFileName) {
return UNDEFINED_TREE_STRING;
}
else {
if (directory != null && isAbsolutePath(normalizeFileName(unsafeFileName))) {
if (directory != null && PATH_UTIL.isAbsolute(normalizeFileName(unsafeFileName))) {
return fileNameBuilder.intern(normalizeFileName(unsafeFileName));
}
return fileNameBuilder.intern(normalizeFileName(
new PathUtil().createAbsolutePath(directory, unsafeFileName)));
PATH_UTIL.createAbsolutePath(directory, unsafeFileName)));
}
}

Expand Down Expand Up @@ -467,7 +465,7 @@ public IssueBuilder setMessage(@CheckForNull final String message) {
}

/**
* Sets an additional description for this issue. Static analysis tools might provide some additional information
* Sets an additional description for this issue. Static analysis tools might provide some additional information
* about this issue. This description may contain valid HTML.
*
* @param description
Expand Down Expand Up @@ -614,25 +612,6 @@ private void clean() {
additionalProperties = null;
}

private static boolean isAbsolutePath(final String stringPath) {
try {
URI uri = new URI(stringPath);
if (uri.isAbsolute()) {
return true;
}
}
catch (URISyntaxException e) {
// Catch and ignore as system paths are not URI and we need to check them separately.
}
try {
Path path = Paths.get(stringPath);
return path.isAbsolute();
}
catch (InvalidPathException e) {
return true;
}
}

private static String normalizeFileName(@CheckForNull final String platformFileName) {
return defaultString(StringUtils.replace(
StringUtils.strip(platformFileName), "\\", "/"));
Expand Down
132 changes: 0 additions & 132 deletions src/main/java/edu/hm/hafner/analysis/LineRange.java

This file was deleted.

Loading

0 comments on commit 7fc181c

Please sign in to comment.