Skip to content

Conversation

marchof
Copy link
Member

@marchof marchof commented Aug 30, 2019

Fixes #783

To avoid common misconfigurations of coverage limits where users provide
ratio as percentage value (without "%") we now issue a rule violation in
such situations.

  • Update documentation to make clear that the range for ratios is [0,1]
  • Use new naming conventions in corresponding unit tests
  • Remove unnecessary config elements from Ant tests
  • Fix local variable name

To avoid common misconfigurations of coverage limits where users provide
ratio as percentage value (without "%") we now issue a rule violation in
such situations.

* Update documentation to make clear that the range for ratios is [0,1]
* Use new naming conventions in corresponding unit tests
* Remove unnecessary config elements from Ant tests
* Fix local variable name
@marchof
Copy link
Member Author

marchof commented Aug 30, 2019

While the rules could be validated once I decided to include it in the existing check methods. This leads to repeated execution but on the other hand allows to keep the existin IViolationOutput API.

@@ -161,8 +161,8 @@ private boolean canCheckCoverage() {
}

@Override
public void executeMojo() throws MojoExecutionException,
MojoExecutionException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate in throws clause - fixed in master.

@Godin
Copy link
Member

Godin commented Sep 24, 2019

@marchof we have really nice statement on Development Conventions page

Pull requests handling various topics ("I fixed this and that") are typically difficult in handling

So I cherry-picked non-functional changes as separate commits into master - 02682c9 and 9f1efb2 This really helps to focus on functional changes 😉

in the range from 0.0 to 1.0 where the number of decimal places will
also determine the precision in error messages. A limit ratio may
optionally be declared as a percentage where 0.80 and 80% represent
the same value.</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and other HTML files use spaces for indentation, so for consistency tab characters should be removed.

@@ -80,10 +80,11 @@ public CounterEntity getEntity() {

/**
* Sets the counter entity to check.
*
* TODO: use CounterEntity directly once Maven 3 is required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only this Maven-ism affected API, but also this TODO-comment is visible in documentation 😞 And while we already require Maven 3 (#821), I propose to just move this TODO-comment outside of javadoc.

@@ -98,10 +99,11 @@ public CounterValue getValue() {

/**
* Sets the value to check.
*
* TODO: use CounterValue directly once Maven 3 is required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above - let's move this TODO-comment outside of javadoc.

<ul>
<li>The coverage check API and tools (Ant, Maven) now report an error, when
a coverage ratio limit is configured outside the range [0,1] to avoid
common configuration mistakes.
Copy link
Member

@Godin Godin Sep 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already dot after reference to ticket as like in all existing places, so this one should be removed for consistency.


private String checkRatioLimit(final String minmax, final BigDecimal v) {
if (v != null && (v.compareTo(BigDecimal.ZERO) == -1
|| v.compareTo(BigDecimal.ONE) == 1)) {
Copy link
Member

@Godin Godin Sep 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While BigDecimal.compareTo clearly specifies return values as -1, 0, or 1,
< 0 (less than zero) and > 0 (greater than zero) look clearer to my taste,
also Comparable.compareTo specifies return values as a negative integer, zero, or a positive.

@Godin Godin merged commit 4c83d07 into master Sep 24, 2019
@Godin Godin deleted the check-ratio-limit branch September 24, 2019 16:51
@Godin
Copy link
Member

Godin commented Sep 24, 2019

@marchof merged! Nice trick to not change API 👍Hope you don't mind that I fixed little things mentioned above.

Also given that people do not read documentation wanna hope that such message will be enough without maybe you forgot "%" 😆

@marchof
Copy link
Member Author

marchof commented Sep 24, 2019

@Godin Many thanks for cleaning up my mess! 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

limit > 1 breaks rule config
2 participants