Skip to content

Commit

Permalink
bump net.sourceforge.pmd:pmd-java from 6.55.0 to 7.3.0 (via #1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jul 5, 2024
1 parent 5649230 commit 5edb2e2
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ public class AllureAwaitilityListener implements ConditionEvaluationListener<Obj

private String currentConditionStepUUID;

private static InheritableThreadLocal<AllureLifecycle> lifecycle = new InheritableThreadLocal<AllureLifecycle>() {
private static final InheritableThreadLocal<AllureLifecycle> LIFECYCLE
= new InheritableThreadLocal<AllureLifecycle>() {
@Override
protected AllureLifecycle initialValue() {
return Allure.getLifecycle();
}
};

public static AllureLifecycle getLifecycle() {
return lifecycle.get();
return LIFECYCLE.get();
}

/**
Expand Down Expand Up @@ -250,7 +251,7 @@ public void exceptionIgnored(final IgnoredException ignoredException) {
* @param allure allure lifecycle to set
*/
public static void setLifecycle(final AllureLifecycle allure) {
lifecycle.set(allure);
LIFECYCLE.set(allure);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ public class TemporalDuration implements TemporalAccessor {

@Override
public boolean isSupported(final TemporalField field) {
if (!temporal.isSupported(field)) {
return false;
}
return temporal.getLong(field) - BASE.getLong(field) != 0L;
return temporal.isSupported(field) && temporal.getLong(field) - BASE.getLong(field) != 0L;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public boolean isKnown() {

private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

public boolean isResultTag(final PickleTag tag) {
return Arrays.asList(new String[]{FLAKY, KNOWN, MUTED})
return Arrays.asList(FLAKY, KNOWN, MUTED)
.contains(tag.getName().toUpperCase());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,8 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
final StringBuilder dataTableCsv = new StringBuilder();
for (List<String> columns : rowsInTable) {
if (!columns.isEmpty()) {
for (int i = 0; i < columns.size(); i++) {
if (i == columns.size() - 1) {
dataTableCsv.append(columns.get(i));
} else {
dataTableCsv.append(columns.get(i));
dataTableCsv.append('\t');
}
}
dataTableCsv.append('\n');
final String rowValue = columns.stream().collect(Collectors.joining("\t", "", "\n"));
dataTableCsv.append(rowValue);
}
}
final String attachmentSource = lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public boolean isKnown() {

private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

public boolean isResultTag(final String tag) {
return Arrays.asList(new String[]{FLAKY, KNOWN, MUTED})
return Arrays.asList(FLAKY, KNOWN, MUTED)
.contains(tag.toUpperCase());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,8 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
final StringBuilder dataTableCsv = new StringBuilder();
for (List<String> columns : rowsInTable) {
if (!columns.isEmpty()) {
for (int i = 0; i < columns.size(); i++) {
if (i == columns.size() - 1) {
dataTableCsv.append(columns.get(i));
} else {
dataTableCsv.append(columns.get(i));
dataTableCsv.append('\t');
}
}
dataTableCsv.append('\n');
final String rowValue = columns.stream().collect(Collectors.joining("\t", "", "\n"));
dataTableCsv.append(rowValue);
}
}
final String attachmentSource = lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public boolean isKnown() {

private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTagsList().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTagsList().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

public boolean isResultTag(final String tag) {
return Arrays.asList(new String[]{FLAKY, KNOWN, MUTED})
return Arrays.asList(FLAKY, KNOWN, MUTED)
.contains(tag.toUpperCase());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,8 @@ private void createDataTableAttachment(final DataTableArgument dataTableArgument
final StringBuilder dataTableCsv = new StringBuilder();
for (List<String> columns : rowsInTable) {
if (!columns.isEmpty()) {
for (int i = 0; i < columns.size(); i++) {
if (i == columns.size() - 1) {
dataTableCsv.append(columns.get(i));
} else {
dataTableCsv.append(columns.get(i));
dataTableCsv.append('\t');
}
}
dataTableCsv.append('\n');
final String rowValue = columns.stream().collect(Collectors.joining("\t", "", "\n"));
dataTableCsv.append(rowValue);
}
}
final String attachmentSource = lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public boolean isKnown() {

private boolean getStatusDetailByTag(final String tagName) {
return scenario.getTags().stream()
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
.anyMatch(tag -> tag.equalsIgnoreCase(tagName))
|| feature.getTags().stream()
.anyMatch(tag -> tag.getName().equalsIgnoreCase(tagName));
}

public boolean isResultTag(final String tag) {
return Arrays.asList(new String[]{FLAKY, KNOWN, MUTED})
return Arrays.asList(FLAKY, KNOWN, MUTED)
.contains(tag.toUpperCase());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void processScenarioDefinition(
for (Step step : child.getSteps()) {
nodeMap.put(step.getLocation().getLine(), createAstNode(step, childNode));
}
if (child.getExamples().size() > 0) {
if (!child.getExamples().isEmpty()) {
processScenarioOutlineExamples(nodeMap, child, childNode);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
}

final String docs = rawDocs.trim();
if ("".equals(docs)) {
if (docs.isEmpty()) {
return;
}

Expand Down
23 changes: 10 additions & 13 deletions allure-grpc/src/main/java/io/qameta/allure/grpc/AllureGrpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,21 @@ public AllureGrpc interceptResponseMetadata(final boolean value) {
return this;
}

@SuppressWarnings({"PMD.MethodArgumentCouldBeFinal", "PMD.NPathComplexity"})
@SuppressWarnings({"PMD.NPathComplexity"})
@Override
public <T, A> ClientCall<T, A> interceptCall(MethodDescriptor<T, A> method,
CallOptions callOptions,
Channel next) {
public <T, A> ClientCall<T, A> interceptCall(final MethodDescriptor<T, A> method,
final CallOptions callOptions,
final Channel next) {
final AttachmentProcessor<AttachmentData> processor = new DefaultAttachmentProcessor();

return new ForwardingClientCall.SimpleForwardingClientCall<T, A>(
next.newCall(method, callOptions.withoutWaitForReady())) {

private String stepUuid;
private List<String> parsedResponses = new ArrayList<>();
private final List<String> parsedResponses = new ArrayList<>();

@SuppressWarnings("PMD.MethodArgumentCouldBeFinal")
@Override
public void sendMessage(T message) {
public void sendMessage(final T message) {
stepUuid = UUID.randomUUID().toString();
Allure.getLifecycle().startStep(stepUuid, (new StepResult()).setName(
"Send gRPC request to "
Expand All @@ -126,18 +125,17 @@ public void sendMessage(T message) {
}
}

@SuppressWarnings("PMD.MethodArgumentCouldBeFinal")
@SuppressWarnings({"PMD.NcssCount"})
@Override
public void start(Listener<A> responseListener, Metadata headers) {
public void start(final Listener<A> responseListener, final Metadata headers) {
final ClientCall.Listener<A> listener = new ForwardingClientCallListener<A>() {
@Override
protected Listener<A> delegate() {
return responseListener;
}

@SuppressWarnings({"PMD.MethodArgumentCouldBeFinal", "PMD.AvoidLiteralsInIfCondition"})
@Override
public void onClose(io.grpc.Status status, Metadata trailers) {
public void onClose(final io.grpc.Status status, final Metadata trailers) {
GrpcResponseAttachment.Builder responseAttachmentBuilder = null;

if (parsedResponses.size() == 1) {
Expand Down Expand Up @@ -183,9 +181,8 @@ public void onClose(io.grpc.Status status, Metadata trailers) {
super.onClose(status, trailers);
}

@SuppressWarnings("PMD.MethodArgumentCouldBeFinal")
@Override
public void onMessage(A message) {
public void onMessage(final A message) {
try {
parsedResponses.add(JSON_PRINTER.print((MessageOrBuilder) message));
super.onMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* @author a-simeshin (Simeshin Artem)
*/
@SuppressWarnings("PMD.MethodArgumentCouldBeFinal")
public class AllureHttpClient5Request implements HttpRequestInterceptor {

private final AttachmentRenderer<AttachmentData> renderer;
Expand Down Expand Up @@ -62,7 +61,9 @@ public AllureHttpClient5Request(final AttachmentRenderer<AttachmentData> rendere
* @param context the HTTP context
*/
@Override
public void process(HttpRequest request, EntityDetails entity, HttpContext context) {
public void process(final HttpRequest request,
final EntityDetails entity,
final HttpContext context) {
final String attachmentName = getAttachmentName(request);
final HttpRequestAttachment.Builder builder = create(attachmentName, request.getRequestUri());
builder.setMethod(request.getMethod());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
*/
@SuppressWarnings({
"checkstyle:ParameterAssignment",
"PMD.MethodArgumentCouldBeFinal",
"PMD.AvoidReassigningParameters"})
public class AllureHttpClient5Response implements HttpResponseInterceptor {
private final AttachmentRenderer<AttachmentData> renderer;
Expand Down Expand Up @@ -69,7 +68,9 @@ public AllureHttpClient5Response(final AttachmentRenderer<AttachmentData> render
* @throws IOException if an I/O error occurs
*/
@Override
public void process(HttpResponse response, EntityDetails entity, HttpContext context) throws IOException {
public void process(final HttpResponse response,
EntityDetails entity,
final HttpContext context) throws IOException {
final HttpResponseAttachment.Builder builder = create("Response");
builder.setResponseCode(response.getCode());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.qameta.allure.internal;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -32,7 +33,7 @@ public class AllureThreadContext {
* Returns last (most recent) uuid.
*/
public Optional<String> getCurrent() {
final LinkedList<String> uuids = context.get();
final Deque<String> uuids = context.get();
return uuids.isEmpty()
? Optional.empty()
: Optional.of(uuids.getFirst());
Expand All @@ -42,7 +43,7 @@ public Optional<String> getCurrent() {
* Returns first (oldest) uuid.
*/
public Optional<String> getRoot() {
final LinkedList<String> uuids = context.get();
final Deque<String> uuids = context.get();
return uuids.isEmpty()
? Optional.empty()
: Optional.of(uuids.getLast());
Expand All @@ -62,7 +63,7 @@ public void start(final String uuid) {
* @return removed uuid.
*/
public Optional<String> stop() {
final LinkedList<String> uuids = context.get();
final Deque<String> uuids = context.get();
if (!uuids.isEmpty()) {
return Optional.of(uuids.pop());
}
Expand All @@ -79,15 +80,15 @@ public void clear() {
/**
* Thread local context that stores information about not finished tests and steps.
*/
private static final class Context extends InheritableThreadLocal<LinkedList<String>> {
private static final class Context extends InheritableThreadLocal<Deque<String>> {

@Override
public LinkedList<String> initialValue() {
public Deque<String> initialValue() {
return new LinkedList<>();
}

@Override
protected LinkedList<String> childValue(final LinkedList<String> parentStepContext) {
protected Deque<String> childValue(final Deque<String> parentStepContext) {
return new LinkedList<>(parentStepContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public void reportingEntryPublished(final TestIdentifier testIdentifier,

}

@SuppressWarnings("PMD.InefficientEmptyStringCheck")
private Map<String, String> unwrap(final Map<String, String> data) {
final Map<String, String> res = new HashMap<>();
data.forEach((key, value) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ private Optional<String> getDisplayName(final Description result) {
.map(DisplayName::value);
}

@SuppressWarnings("PMD.AvoidLiteralsInIfCondition")
private Optional<String> getDescription(final Description result) {
final io.qameta.allure.Description annotation = result
.getAnnotation(io.qameta.allure.Description.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ static class CucumberCheck implements Serializable {

@Override
public boolean equals(final Object obj) {
if (Objects.isNull(obj)) {
return false;
}
return "io.cucumber.junit.PickleRunners.PickleId"
return !Objects.isNull(obj) && "io.cucumber.junit.PickleRunners.PickleId"
.equals(obj.getClass().getCanonicalName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public Map<String, String> buildFailureEvent(final String type,
return map;
}

@SuppressWarnings("PMD.InefficientEmptyStringCheck")
public Map<String, String> wrap(final Map<String, String> data) {
final Map<String, String> res = new HashMap<>();
data.forEach((key, value) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public enum Stage {
* @return the stage
*/
public static Stage fromValue(final String v) {
for (Stage c : Stage.values()) {
for (Stage c : values()) {
if (c.value.equals(v)) {
return c;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public enum Status {
* @return the status
*/
public static Status fromValue(final String v) {
for (Status c : Status.values()) {
for (Status c : values()) {
if (c.value.equals(v)) {
return c;
}
Expand Down
Loading

0 comments on commit 5edb2e2

Please sign in to comment.