Skip to content

Commit

Permalink
(cqfn#215) LCOM4 static fields are now called by FQN (+cactoos-matche…
Browse files Browse the repository at this point in the history
…rs 0.13)
  • Loading branch information
ilyakharlamov committed Jan 25, 2019
1 parent 9198518 commit 63e7dc8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ SOFTWARE.
<version>9.8.0-5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.llorllale</groupId>
<artifactId>cactoos-matchers</artifactId>
<version>0.13</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/org/jpeek/skeleton/QualifiedName.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@
*/
package org.jpeek.skeleton;

import org.cactoos.Text;
import org.cactoos.iterable.IterableOf;
import org.cactoos.iterable.Joined;
import org.cactoos.text.JoinedText;
import org.cactoos.text.SplitText;
import org.cactoos.text.TextEnvelope;
import org.cactoos.text.TextOf;
import org.cactoos.text.UncheckedText;

/**
Expand All @@ -50,13 +45,9 @@ public QualifiedName(final String owner, final String attr) {
super(
new UncheckedText(
new JoinedText(
new TextOf("."),
new Joined<Text>(
new SplitText(owner, "/"),
new IterableOf<>(
new TextOf(attr)
)
)
".",
owner.replace('/', '.'),
attr
)
)
);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/jpeek/metrics/Lcom4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void methodMethodCalls() throws Exception {
).size()
);
report.assertVariable(Lcom4Test.ATTRIBUTES, 1);
report.assertValue(1.0F);
report.assertValue(1.0f);
}

/**
Expand All @@ -126,7 +126,7 @@ public void oneCommonAttribute() throws Exception {
);
report.assertVariable(Lcom4Test.ATTRIBUTES, 1);
report.assertVariable(Lcom4Test.PAIRS, 1);
report.assertValue(1.0F);
report.assertValue(1.0f);
}

/**
Expand All @@ -146,7 +146,7 @@ public void notCommonAttributes() throws Exception {
);
report.assertVariable(Lcom4Test.ATTRIBUTES, 2);
report.assertVariable(Lcom4Test.PAIRS, 0);
report.assertValue(2.0F);
report.assertValue(2.0f);
}

/**
Expand All @@ -162,6 +162,6 @@ public void notCommonAttributesWithAllArgsConstructor() throws Exception {
);
report.assertVariable(Lcom4Test.ATTRIBUTES, 2);
report.assertVariable(Lcom4Test.PAIRS, 0);
report.assertValue(2.0F);
report.assertValue(2.0f);
}
}
33 changes: 18 additions & 15 deletions src/test/java/org/jpeek/metrics/MetricBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
import com.jcabi.xml.XSLDocument;
import org.cactoos.io.ResourceOf;
import org.cactoos.text.FormattedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.cactoos.text.TextOf;
import org.hamcrest.number.IsCloseTo;
import org.jpeek.FakeBase;
import org.jpeek.skeleton.Skeleton;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.TextIs;

/**
* Metric test helper.
Expand Down Expand Up @@ -106,25 +107,27 @@ public Report(final String name, final XML xml) {
*/
public void assertVariable(final String variable,
final int expected) throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
new FormattedText(
"Variable '%s' is not calculated correctly for class '%s'",
variable,
this.name
).asString(),
this.xml.xpath(
String.format(
"//class[@id='%s']/vars/var[@id='%s']/text()",
this.name,
variable
)
).get(0),
new IsEqual<>(
() -> new TextOf(
this.xml.xpath(
new FormattedText(
"//class[@id='%s']/vars/var[@id='%s']/text()",
this.name,
variable
).asString()
).get(0)
),
new TextIs(
String.valueOf(
expected
)
)
);
).affirm();
}

/**
Expand All @@ -133,9 +136,9 @@ public void assertVariable(final String variable,
* @throws Exception String format exception
*/
public void assertValue(final double value) throws Exception {
MatcherAssert.assertThat(
new Assertion<>(
"The metric value is not calculated properly",
Double.parseDouble(
() -> Double.parseDouble(
this.xml.xpath(
new FormattedText(
"//class[@id='%s']/@value",
Expand All @@ -148,7 +151,7 @@ public void assertValue(final double value) throws Exception {
// @checkstyle MagicNumberCheck (1 line)
0.001d
)
);
).affirm();
}
}
}

0 comments on commit 63e7dc8

Please sign in to comment.