From dedc75ebc4d9c53d3fa9389caeecc3c222979239 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:29:26 +0200 Subject: [PATCH] Fix Reports Success/Warning icons, counts --- .../ordering/AbstractVersionComparator.java | 13 ++----------- .../reporting/AbstractVersionsReportRenderer.java | 1 + .../versions/reporting/PluginOverviewStats.java | 10 +++++----- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java index 1baeea0a35..ecc87f1a39 100644 --- a/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java +++ b/src/main/java/org/codehaus/mojo/versions/ordering/AbstractVersionComparator.java @@ -59,17 +59,8 @@ public final int getSegmentCount( ArtifactVersion v ) */ public final ArtifactVersion incrementSegment( ArtifactVersion v, Segment segment ) throws InvalidSegmentException { - if ( VersionComparators.isSnapshot( v ) ) - { - return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), - segment ) ); - } - int segmentCount = getSegmentCount( v ); - if ( segment.value() >= segmentCount ) - { - throw new InvalidSegmentException( segment, segmentCount, v ); - } - return innerIncrementSegment( v, segment ); + return VersionComparators.copySnapshot( v, innerIncrementSegment( VersionComparators.stripSnapshot( v ), + segment ) ); } protected abstract ArtifactVersion innerIncrementSegment( ArtifactVersion v, Segment segment ) diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index ba1c0a6bab..266dc10bc2 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -421,6 +421,7 @@ protected void renderTableHeaderCells( String... keys ) protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) { + if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) ) { return getText( "report.latestSubIncremental" ); diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 5275c17e4f..2d215b75cf 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -55,7 +55,7 @@ public void incrementDependencies() * * @param updates collection of all version updates, typically from {@linkplain PluginUpdatesModel#getAllUpdates()} * @param cache if not null, cache to retrieve the version information, initialised with - * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param always equal to {@linkplain PluginOverviewStats} * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information @@ -66,19 +66,19 @@ public static T fromUpdate PluginOverviewStats stats = new PluginOverviewStats(); updates.forEach( details -> { - if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) { stats.incrementMajor(); }