Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cb20e2c
#536: Resolve Sonar findings of June 2026 up to Linker.java
redcatbear Jun 3, 2026
73734c9
#536: Resolve Sonar findings of June 2026 up to TestSpecificationItem…
redcatbear Jun 3, 2026
59b9901
Merge branch 'main' into refactoring/536_Resolve_Sonar_cloud_findings
redcatbear Jun 3, 2026
2e8ec57
#536: Resolve Sonar findings of June 2026 up to TestSpecificationItem…
redcatbear Jun 3, 2026
b8cf02f
#536: Resolve Sonar findings of June 2026 up to ExporterFactory.java
redcatbear Jun 3, 2026
d2b714b
#536: Resolve Sonar findings of June 2026 up to MultiFileImporterImpl…
redcatbear Jun 3, 2026
f8fb51e
#536: Resolve Sonar findings of June 2026 up to SpecificationItemId.java
redcatbear Jun 4, 2026
b125ad5
#536: Maded pattern private in PlainTextReport.
redcatbear Jun 4, 2026
08b616a
#536: Up to TextFormatterFactory.
redcatbear Jun 4, 2026
ed28a94
#536: Up to ZipFileImporter.
redcatbear Jun 4, 2026
af6f33e
#536: Wrapped overlong line.
redcatbear Jun 4, 2026
710fd99
#536: Added missing curly braces.
redcatbear Jun 4, 2026
07636a5
#536: Fixed some more Sonar findings.
redcatbear Jun 4, 2026
22ef28e
#536: Added suppression for S4968 when Hamcrest Matcher requires gene…
redcatbear Jun 5, 2026
c486d37
#536: Removed redundant unmodifiable wrappers for collections. The bu…
redcatbear Jun 5, 2026
f3ed0b8
#536: Fixed review findings of @kaklakariada.
redcatbear Jun 6, 2026
c34e8c8
#536: Added missing method return type.
redcatbear Jun 6, 2026
c8c265b
#536: Fixed problem with list that still needs to be modifiable.
redcatbear Jun 8, 2026
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.itsallcode.openfasttrace.api;

import java.util.Collections;
import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -34,6 +35,7 @@ public Set<String> getArtifactTypes()
*
* @return artifact types that must be matched
*/

public Set<String> getTags()
{
return this.tags;
Expand Down Expand Up @@ -82,58 +84,16 @@ public boolean isAnyCriteriaSet()
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result
+ ((this.artifactTypes == null) ? 0 : this.artifactTypes.hashCode());
result = prime * result + (this.withoutTags ? 1231 : 1237);
result = prime * result + ((this.tags == null) ? 0 : this.tags.hashCode());
return result;
return Objects.hash(this.artifactTypes, this.tags, this.withoutTags);
Comment thread
kaklakariada marked this conversation as resolved.
}

@Override
public boolean equals(final Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (!(obj instanceof FilterSettings))
{
return false;
}
final FilterSettings other = (FilterSettings) obj;
if (this.artifactTypes == null)
{
if (other.artifactTypes != null)
{
return false;
}
}
else if (!this.artifactTypes.equals(other.artifactTypes))
{
return false;
}
if (this.withoutTags != other.withoutTags)
{
return false;
}
if (this.tags == null)
{
if (other.tags != null)
{
return false;
}
}
else if (!this.tags.equals(other.tags))
{
public boolean equals(final Object other) {
if (!(other instanceof final FilterSettings that)) {
return false;
}
return true;
return withoutTags == that.withoutTags && Objects.equals(artifactTypes, that.artifactTypes)
&& Objects.equals(tags, that.tags);
}

/**
Expand All @@ -160,7 +120,7 @@ public static Builder builder()
/**
* Builder for {@link FilterSettings}
*/
public static class Builder
public static final class Builder
{
private Set<String> artifactTypes = Collections.emptySet();
private Set<String> tags = Collections.emptySet();
Expand All @@ -180,7 +140,7 @@ private Builder()
*/
public Builder artifactTypes(final Set<String> artifactTypes)
{
this.artifactTypes = artifactTypes;
this.artifactTypes = Set.copyOf(artifactTypes);
return this;
}

Expand All @@ -193,7 +153,7 @@ public Builder artifactTypes(final Set<String> artifactTypes)
*/
public Builder tags(final Set<String> tags)
{
this.tags = tags;
this.tags = Set.copyOf(tags);
return this;
}

Expand All @@ -220,4 +180,4 @@ public FilterSettings build()
return new FilterSettings(this);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This class implements a parameter object to control the settings of OFT's
* report mode.
*/
public class ReportSettings
public final class ReportSettings
{
private final ReportVerbosity verbosity;
private final boolean showOrigin;
Expand Down Expand Up @@ -112,12 +112,12 @@ public static Builder builder()
/**
* Builder for {@link ReportSettings}
*/
public static class Builder
public static final class Builder
{
private DetailsSectionDisplay detailsSectionDisplay = DetailsSectionDisplay.COLLAPSE;
private Newline newline = Newline.UNIX;
private String outputFormat = ReportConstants.DEFAULT_REPORT_FORMAT;
private boolean showOrigin = false;
private boolean showOrigin;
private ReportVerbosity verbosity = ReportVerbosity.FAILURE_DETAILS;
private ColorScheme colorScheme = ColorScheme.BLACK_AND_WHITE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public interface DirectoryService
* @return current directory
*/
String getCurrent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ public enum DeepCoverageStatus

private final int badness;

private DeepCoverageStatus(final int badness)
DeepCoverageStatus(final int badness)
{
this.badness = badness;
}

/**
* Get the worse of two coverage status
* Get the worst of two coverage statuses
*
* @param a
* left status to compare
* @param b
* right status to compare
* @return worse of both provided status
* @return worse of both provided statuses
*/
public static DeepCoverageStatus getWorst(final DeepCoverageStatus a,
final DeepCoverageStatus b)
{
return (b.badness > a.badness) ? b : a;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.itsallcode.openfasttrace.api.core;

import java.util.Locale;

/**
* This enumeration represents the different statuses of an item.
*/
Expand Down Expand Up @@ -47,6 +49,6 @@ public static ItemStatus parseString(final String text)
@Override
public String toString()
{
return this.name().toLowerCase();
return this.name().toLowerCase(Locale.ENGLISH);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public enum LinkStatus
private final String shortTag;
private final String text;

private LinkStatus(final String shortTag, final String text)
LinkStatus(final String shortTag, final String text)
{
this.shortTag = shortTag;
this.text = text;
Expand Down Expand Up @@ -92,8 +92,10 @@ public boolean isOutgoing()
*/
public boolean isBadOutgoing()
{
return (this == PREDATED) || (this == OUTDATED) || (this == AMBIGUOUS) || (this == UNWANTED)
|| (this == ORPHANED);
return switch (this) {
case PREDATED, OUTDATED, AMBIGUOUS, UNWANTED, ORPHANED -> true;
default -> false;
};
}

/**
Expand Down Expand Up @@ -148,4 +150,4 @@ public String toString()
{
return this.text;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void cacheOverCoveredArtifactType(final LinkedSpecificationItem overcove
*/
public Map<LinkStatus, List<LinkedSpecificationItem>> getLinks()
{
return this.links;
return new EnumMap<>(this.links);
Comment thread
kaklakariada marked this conversation as resolved.
}

/**
Expand Down Expand Up @@ -243,13 +243,13 @@ public List<String> getNeedsArtifactTypes()
}

/**
* Get the artifact type which are covered.
* Get the artifact types that are covered.
*
* @return the set of covered artifact types.
*/
public Set<String> getCoveredArtifactTypes()
{
return this.coveredArtifactTypes;
return Collections.unmodifiableSet(this.coveredArtifactTypes);
}

/**
Expand All @@ -259,7 +259,7 @@ public Set<String> getCoveredArtifactTypes()
*/
public Set<String> getCoveredApprovedArtifactTypes()
{
return this.coveredArtifactTypesFromApprovedItems;
return Collections.unmodifiableSet(this.coveredArtifactTypesFromApprovedItems);
}

/**
Expand All @@ -270,7 +270,7 @@ public Set<String> getCoveredApprovedArtifactTypes()
public Set<String> getOverCoveredArtifactTypes()
{

return this.overCoveredArtifactTypes;
return Collections.unmodifiableSet(this.overCoveredArtifactTypes);
}

/**
Expand Down Expand Up @@ -416,9 +416,9 @@ private List<LinkedSpecificationItem> getIncomingItems()
public boolean isDefect()
{
return hasDuplicates() //
|| (getStatus() != ItemStatus.REJECTED) //
|| ((getStatus() != ItemStatus.REJECTED) //
&& (hasBadLinks()
|| (getDeepCoverageStatus() != DeepCoverageStatus.COVERED));
|| (getDeepCoverageStatus() != DeepCoverageStatus.COVERED)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.itsallcode.openfasttrace.api.core;

import java.util.Objects;

/**
* The location of a coverage item.
*/
Expand Down Expand Up @@ -112,58 +114,23 @@ public int getColumn()
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + this.column;
result = prime * result + this.line;
result = prime * result + ((this.path == null) ? 0 : this.path.hashCode());
return result;
return Objects.hash(this.column, this.line, this.path);
}

@Override
public boolean equals(final Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Location other = (Location) obj;
if (this.column != other.column)
{
return false;
}
if (this.line != other.line)
{
return false;
}
if (this.path == null)
{
if (other.path != null)
{
return false;
}
}
else if (!this.path.equals(other.path))
{
public boolean equals(final Object other) {
if (!(other instanceof final Location location)) {
return false;
}
return true;
return line == location.line && column == location.column && Objects.equals(path, location.path);
}

@Override
public String toString()
{
return this.path //
+ (this.line != NO_LINE ? ":" + this.line : "") //
+ (this.column != NO_COLUMN ? ":" + this.column : "");
+ ((this.line != NO_LINE) ? (":" + this.line) : "") //
+ ((this.column != NO_COLUMN) ? (":" + this.column) : "");
}

/**
Expand All @@ -180,7 +147,7 @@ public static Builder builder()
* A builder for {@link Location}. Use {@link Location#builder()} to create
* a new builder and call {@link #build()} to build a {@link Location}.
*/
public static class Builder
public static final class Builder
{
private String path;
private int line = NO_LINE;
Expand Down Expand Up @@ -250,4 +217,4 @@ public boolean isCompleteEnough()
return this.path != null && !this.path.isEmpty();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum Newline
private static final Pattern ANY_NEWLINE_PATTERN = Pattern.compile(ANY_NEWLINE_REG_EX);
private final String representation;

private Newline(final String representation)
Newline(final String representation)
{
this.representation = representation;
}
Expand All @@ -38,18 +38,14 @@ public String toString()
*/
public static Newline fromRepresentation(final String representation)
{
switch (representation)
return switch (representation)
{
case "\n":
return UNIX;
case "\r\n":
return WINDOWS;
case "\r":
return OLDMAC;
default:
throw new IllegalArgumentException(
case "\n" -> UNIX;
case "\r\n" -> WINDOWS;
case "\r" -> OLDMAC;
default -> throw new IllegalArgumentException(
"Line separator not supported: '" + representation + "'");
}
};
}

/**
Expand Down
Loading
Loading