This repository was archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Coverage dashboard column #294
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
80600eb
Added customizable coverage dashboard column and advanced color utility
fo-code b54b15e
Merge branch 'jenkinsci:master' into coverage-visualization
fo-code 87b8025
Fixed import
fo-code 8fc810e
Fixed warnings
fo-code 4b32a0c
Fixed warnings
fo-code 46c44b8
Fixed import
fo-code 52e4a39
Adjusted colorization levels
fo-code 493ba4f
Merge branch 'master' into coverage-visualization
fo-code 39b1b2b
Resolved merge conflicts
fo-code efa0c9e
Merge branch 'jenkinsci:master' into coverage-visualization
fo-code 13a059a
Fixed test errors
fo-code b9427fb
Merge branch 'coverage-visualization' of https://github.com/fo-code/c…
fo-code dacd36c
Fixed test errors
fo-code e3c6dda
Merge branch 'master' into coverage-visualization
fo-code 9707cef
Adjusted dependencies
fo-code 9bedd54
Rework and advanced color handling
fo-code 2f65f01
Merge branch 'master' into coverage-visualization
fo-code 402ede9
Fixed tests
fo-code 79a6f32
Added tests and javadoc
fo-code 3aa8b5f
Style fixes
fo-code bf75d1e
Style fixes
fo-code dd13b4a
Adjusted color IDs
fo-code d6d5e85
Merge branch 'master' into coverage-visualization
fo-code f2959d1
Style fixes
fo-code 934e4c6
Dynamically compute localized text so that the client locale will be …
uhafner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
plugin/src/main/java/io/jenkins/plugins/coverage/model/util/FractionFormatter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| package io.jenkins.plugins.coverage.model.util; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| import org.apache.commons.lang3.math.Fraction; | ||
|
|
||
| /** | ||
| * Formats fraction and percentage values represented by {@link Fraction} and provides these values as formatted | ||
| * percentages dependent on the use case. | ||
| * | ||
| * @author Florian Orendi | ||
| */ | ||
| public class FractionFormatter { | ||
|
|
||
| private static final Fraction HUNDRED = Fraction.getFraction(100, 1); | ||
|
|
||
| private FractionFormatter() { | ||
| // prevents instantiation | ||
| } | ||
|
|
||
| /** | ||
| * Transforms a fraction within the range [0;1] to a percentage value within the range [0;100]. | ||
| * | ||
| * @param fraction | ||
| * The fraction to be transformed | ||
| * | ||
| * @return the fraction as percentage | ||
| */ | ||
| public static Fraction transformFractionToPercentage(final Fraction fraction) { | ||
| return fraction.multiplyBy(HUNDRED); | ||
| } | ||
|
|
||
| /** | ||
| * Formats a percentage to plain text and rounds the value to two decimals. | ||
| * | ||
| * @param percentage | ||
| * The percentage to be formatted | ||
| * @param locale | ||
| * The used locale | ||
| * | ||
| * @return the formatted percentage as plain text | ||
| */ | ||
| public static String formatPercentage(final Fraction percentage, final Locale locale) { | ||
| return String.format(locale, "%.2f%%", percentage.doubleValue()); | ||
| } | ||
|
|
||
| /** | ||
| * Formats a delta fraction to its plain text percentage representation with a leading sign and rounds the value to | ||
| * two decimals. | ||
| * | ||
| * @param fraction | ||
| * The fraction to be formatted | ||
| * @param locale | ||
| * The used locale | ||
| * | ||
| * @return the formatted delta fraction as plain text with a leading sign | ||
| */ | ||
| public static String formatDeltaFraction(final Fraction fraction, final Locale locale) { | ||
| return String.format(locale, "%+.2f%%", transformFractionToPercentage(fraction).doubleValue()); | ||
| } | ||
|
|
||
| /** | ||
| * Formats a delta percentage to its plain text representation with a leading sign and rounds the value to two | ||
| * decimals. | ||
| * | ||
| * @param percentage | ||
| * The percentage to be formatted | ||
| * @param locale | ||
| * The used locale | ||
| * | ||
| * @return the formatted delta percentage as plain text with a leading sign | ||
| */ | ||
| public static String formatDeltaPercentage(final Fraction percentage, final Locale locale) { | ||
| return String.format(locale, "%+.2f%%", percentage.doubleValue()); | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
...n/src/main/java/io/jenkins/plugins/coverage/model/visualization/colorization/ColorId.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package io.jenkins.plugins.coverage.model.visualization.colorization; | ||
|
|
||
| /** | ||
| * Provides IDs for colors which are used within this plugin in order to separate the color palette from the logic. | ||
| * | ||
| * @author Florian Orendi | ||
| */ | ||
| public enum ColorId { | ||
| INSUFFICIENT, | ||
| VERY_BAD, | ||
| BAD, | ||
| INADEQUATE, | ||
| BELOW_AVERAGE, | ||
| AVERAGE, | ||
| ABOVE_AVERAGE, | ||
| GOOD, | ||
| VERY_GOOD, | ||
| EXCELLENT, | ||
| OUTSTANDING, | ||
|
|
||
| BLACK, | ||
| WHITE | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.