Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump net.sourceforge.pmd:pmd-java from 6.55.0 to 7.0.0 #2444

Merged
merged 2 commits into from
Apr 8, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,12 @@ public static Status convert(final ru.yandex.qatools.allure.model.Status status)
}

private List<Parameter> getParameters(final TestCaseResult source) {
final TreeSet<Parameter> parametersSet = new TreeSet<>(
comparing(Parameter::getName, nullsFirst(naturalOrder()))
.thenComparing(Parameter::getValue, nullsFirst(naturalOrder()))
);
parametersSet.addAll(convertList(source.getParameters(), this::hasArgumentType, this::convert));
final List<Parameter> parameters = convertList(source.getParameters(), this::hasArgumentType, this::convert);
if (Objects.isNull(parameters)) {
return new ArrayList<>();
}
final Set<Parameter> parametersSet = new TreeSet<>(PARAMETER_COMPARATOR);
parametersSet.addAll(parameters);
return new ArrayList<>(parametersSet);
}

Expand Down Expand Up @@ -467,7 +468,7 @@ private Optional<TestSuiteResult> readXmlTestSuiteFile(final Path source) {
try (InputStream is = Files.newInputStream(source)) {
return Optional.of(xmlMapper.readValue(is, TestSuiteResult.class));
} catch (IOException e) {
LOGGER.error("Could not read xml result {}: {}", source, e);
LOGGER.error("Could not read xml result {}", source, e);
}
return Optional.empty();
}
Expand All @@ -476,7 +477,7 @@ private Optional<TestSuiteResult> readJsonTestSuiteFile(final Path source) {
try (InputStream is = Files.newInputStream(source)) {
return Optional.of(jsonMapper.readValue(is, TestSuiteResult.class));
} catch (IOException e) {
LOGGER.error("Could not read json result {}: {}", source, e);
LOGGER.error("Could not read json result {}", source, e);
return Optional.empty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public class Allure2Plugin implements Reader {
nullsLast(comparing(Time::getStart, nullsLast(naturalOrder())))
);

private static final Comparator<Parameter> PARAMETER_COMPARATOR =
comparing(Parameter::getName, nullsFirst(naturalOrder()))
.thenComparing(Parameter::getValue, nullsFirst(naturalOrder()));

private final ObjectMapper mapper = JsonMapper.builder()
.enable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS)
Expand Down Expand Up @@ -316,11 +320,16 @@ private Time convert(final Long start, final Long stop) {
}

private List<Parameter> getParameters(final TestResult result) {
final TreeSet<Parameter> parametersSet = new TreeSet<>(
comparing(Parameter::getName, nullsFirst(naturalOrder()))
.thenComparing(Parameter::getValue, nullsFirst(naturalOrder()))
final List<Parameter> parameters = convertList(
result.getParameters(),
p -> !HIDDEN.equals(p.getMode()),
this::convert
);
parametersSet.addAll(convertList(result.getParameters(), p -> !HIDDEN.equals(p.getMode()), this::convert));
if (Objects.isNull(parameters)) {
return new ArrayList<>();
}
final Set<Parameter> parametersSet = new TreeSet<>(PARAMETER_COMPARATOR);
parametersSet.addAll(parameters);
return new ArrayList<>(parametersSet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import static io.qameta.allure.allure1.Allure1Plugin.ENVIRONMENT_BLOCK_NAME;
Expand Down Expand Up @@ -51,13 +50,11 @@ protected List<EnvironmentItem> getData(final List<LaunchResults> launches) {
return launchEnvironments.stream()
.collect(groupingBy(Map.Entry::getKey, LinkedHashMap::new, mapping(Map.Entry::getValue, toSet())))
.entrySet().stream()
.map(Allure1EnvironmentPlugin::aggregateItem)
.map(entry -> new EnvironmentItem()
.setName(entry.getKey())
.setValues(new ArrayList<>(entry.getValue()))
)
.collect(toList());
}

private static EnvironmentItem aggregateItem(final Map.Entry<String, Set<String>> entry) {
return new EnvironmentItem()
.setName(entry.getKey())
.setValues(new ArrayList<>(entry.getValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class RetryTrendItem extends TrendItem {

private static final String RETRY_KEY = "retry";

@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
public RetryTrendItem() {
this.setMetric(RETRY_KEY, 0L);
this.setMetric(RUN_KEY, 0L);
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ subprojects {
dependency("commons-beanutils:commons-beanutils:1.9.4")
dependency("commons-io:commons-io:2.16.0")
dependency("javax.xml.bind:jaxb-api:2.3.1")
dependency("net.sourceforge.pmd:pmd-java:6.55.0")
dependency("net.sourceforge.pmd:pmd-java:7.0.0")
dependency("org.allurefw:allure1-model:1.0")
dependency("org.apache.commons:commons-collections4:4.4")
dependency("org.apache.commons:commons-lang3:3.14.0")
Expand Down Expand Up @@ -173,6 +173,7 @@ subprojects {
toolVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]!!
ruleSets = listOf()
ruleSetFiles = rootProject.files("gradle/quality-configs/pmd/pmd.xml")
targetJdk = TargetJdk.VERSION_1_7
}

spotbugs {
Expand Down
12 changes: 3 additions & 9 deletions gradle/quality-configs/pmd/pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@

<!-- Code style (https://pmd.github.io/pmd-6.0.1/pmd_rules_java_codestyle.html) -->
<rule ref="category/java/codestyle.xml">
<exclude name="AbstractNaming"/>
<exclude name="AtLeastOneConstructor"/>
<exclude name="AvoidFinalLocalVariable"/>
<exclude name="CallSuperInConstructor"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="ConfusingTernary"/>
<exclude name="DefaultPackage"/>
<exclude name="GenericsNaming"/>
<exclude name="LinguisticNaming"/>
<exclude name="LocalHomeNamingConvention"/> <!-- earlier j2ee group-->
Expand All @@ -48,6 +45,7 @@
<exclude name="ShortVariable"/>
<exclude name="TooManyStaticImports"/>
<exclude name="UnnecessaryAnnotationValueElement"/>
<exclude name="UseDiamondOperator"/>
<exclude name="UselessParentheses"/>
</rule>

Expand All @@ -60,16 +58,13 @@
<!-- Design (https://pmd.github.io/pmd-6.0.1/pmd_rules_java_design.html) -->
<rule ref="category/java/design.xml">
<exclude name="AvoidCatchingGenericException"/>
<exclude name="CouplingBetweenObjects"/>
<exclude name="DataClass"/>
<exclude name="ExcessiveClassLength"/> <!-- replaced by NcssCount -->
<exclude name="ExcessiveImports"/>
<exclude name="ExcessiveMethodLength"/> <!-- replaced by NcssCount -->
<exclude name="LawOfDemeter"/>
<exclude name="CyclomaticComplexity"/> <!-- disabled in favour of checkstyle's CyclomaticComplexity check -->
<exclude name="LoosePackageCoupling"/>
<exclude name="ModifiedCyclomaticComplexity"/>
<exclude name="SignatureDeclareThrowsException"/>
<exclude name="StdCyclomaticComplexity"/>
<exclude name="TooManyFields"/>
</rule>
<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts">
Expand Down Expand Up @@ -106,13 +101,12 @@
<rule ref="category/java/errorprone.xml">
<exclude name="AvoidCatchingThrowable"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="DataflowAnomalyAnalysis"/>
<exclude name="AvoidLiteralsInIfCondition"/>
<exclude name="EmptyFinalizer"/>
<exclude name="FinalizeDoesNotCallSuperFinalize"/>
<exclude name="FinalizeOnlyCallsSuperFinalize"/>
<exclude name="JUnitSpelling"/>
<exclude name="JUnitStaticSuite"/>
<exclude name="LoggerIsNotStaticFinal"/>
<exclude name="MissingSerialVersionUID"/>
<exclude name="NullAssignment"/> <!-- disabled due to false positive for initialization with ternary operator -->
<exclude name="StaticEJBFieldShouldBeFinal"/> <!-- earlier j2ee group-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ private ResultsUtils() {
public static TestResult getTestResult(final Map<String, Object> props) {
return new TestResult()
.setUid(UUID.randomUUID().toString())
.setName(ResultsUtils.getTestName(props))
.setStatus(ResultsUtils.getTestStatus(props))
.setFullName(ResultsUtils.getFullName(props))
.setTime(ResultsUtils.getTestTime(props))
.setName(getTestName(props))
.setStatus(getTestStatus(props))
.setFullName(getFullName(props))
.setTime(getTestTime(props))
.setTestStage(new StageResult());
}

Expand Down Expand Up @@ -102,8 +102,8 @@ private static Time getStepTime(final Map<String, Object> props) {
}

private static long parseTime(final String time) {
final Double doubleTime = Double.parseDouble(time);
final int seconds = doubleTime.intValue();
return seconds * 1000;
final double doubleTime = Double.parseDouble(time);
final int seconds = (int) doubleTime;
return seconds * 1000L;
}
}
Loading