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

Start checkstyle setup 2 #217

Merged
merged 1 commit into from Sep 3, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions build.gradle
Expand Up @@ -6,6 +6,7 @@ group = "org.hamcrest"
version = "2.2-SNAPSHOT"

subprojects {
apply plugin: 'checkstyle'
apply plugin: 'java-library'

sourceCompatibility = JavaVersion.VERSION_1_7
Expand All @@ -18,6 +19,27 @@ subprojects {
mavenCentral()
}

checkstyle {

project.ext.checkstyleVersion = '6.18'
//works with a JDK 7 version which is supposed to be supported although
//deprecated, see https://github.com/hamcrest/JavaHamcrest/pull/211 for
//the discussion about the support

sourceSets = [ project.sourceSets.main, project.sourceSets.test ]
ignoreFailures = false
configFile = file("${project.rootDir}/checkstyle.xml")

configurations {
checkstyle
}

dependencies{
assert project.hasProperty("checkstyleVersion")
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
}
}

test {
testLogging {
exceptionFormat = 'full'
Expand Down
11 changes: 11 additions & 0 deletions checkstyle.xml
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<!-- Checks that there are no tab characters ('\t') in the source code. -->
<module name="FileTabCharacter">
<!-- Report on each line in each file -->
<property name="eachLine" value="true"/>
</module>
</module>
Expand Up @@ -44,7 +44,7 @@ public static <E> Matcher<Collection<? extends E>> hasSize(Matcher<? super Integ
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <E> Matcher<Collection<? extends E>> hasSize(int size) {
return (Matcher)IsCollectionWithSize.hasSize(equalTo(size));
return (Matcher)IsCollectionWithSize.hasSize(equalTo(size));
}

}
Expand Up @@ -129,7 +129,7 @@ public static <E> Matcher<Iterable<? extends E>> contains(Matcher<? super E>...
// required for JDK 1.6
//noinspection RedundantTypeArguments
final List<Matcher<? super E>> nullSafeWithExplicitTypeMatchers = NullSafety.<E>nullSafe(itemMatchers);
return contains(nullSafeWithExplicitTypeMatchers);
return contains(nullSafeWithExplicitTypeMatchers);
}

/**
Expand Down
Expand Up @@ -55,7 +55,7 @@ public void testHasAReadableDescription() {
}

public void testCanHandleNullMatchers() {
assertMatches(contains(null, null), asList(null, null));
assertMatches(contains(null, null), asList(null, null));
}

public static class WithValue {
Expand Down
20 changes: 10 additions & 10 deletions hamcrest/src/test/java/org/hamcrest/object/HasToStringTest.java
Expand Up @@ -26,30 +26,30 @@ public String toString() {

@Test public void
matchesWhenUtilisingANestedMatcher() {
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));

assertMatches(matcher, TEST_OBJECT);
assertDoesNotMatch(matcher, new Object());
assertMatches(matcher, TEST_OBJECT);
assertDoesNotMatch(matcher, new Object());
}

@Test public void
matchesWhenUsingShortcutForHasToStringEqualTo() {
final Matcher<Object> matcher = hasToString(TO_STRING_RESULT);
assertMatches(matcher, TEST_OBJECT);
assertDoesNotMatch(matcher, new Object());
final Matcher<Object> matcher = hasToString(TO_STRING_RESULT);
assertMatches(matcher, TEST_OBJECT);
assertDoesNotMatch(matcher, new Object());
}

@Test public void
describesItself() {
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));
assertDescription("with toString() \"toString result\"", matcher);
}

@Test public void
describesAMismatch() {
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));
String expectedMismatchString = "toString() was \"Cheese\"";
final Matcher<Object> matcher = hasToString(equalTo(TO_STRING_RESULT));
String expectedMismatchString = "toString() was \"Cheese\"";
assertMismatchDescription(expectedMismatchString, matcher, "Cheese");
}
}
Expand Up @@ -19,26 +19,26 @@ public final class IsEqualIgnoringCaseTest {
@Test public void
ignoresCaseOfCharsInString() {
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertMatches(matcher, "HELLO");
assertMatches(matcher, "hello");
assertMatches(matcher, "HelLo");
assertDoesNotMatch(matcher, "bye");
assertDoesNotMatch(matcher, "bye");
}

@Test public void
mismatchesIfAdditionalWhitespaceIsPresent() {
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertDoesNotMatch(matcher, "hello ");
assertDoesNotMatch(matcher, " hello");
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertDoesNotMatch(matcher, "hello ");
assertDoesNotMatch(matcher, " hello");
}

@Test public void
mismatchesNull() {
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertDoesNotMatch(matcher, null);
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertDoesNotMatch(matcher, null);
}

@Test(expected=IllegalArgumentException.class) public void
Expand All @@ -49,14 +49,14 @@ public final class IsEqualIgnoringCaseTest {

@Test public void
describesItself() {
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
assertDescription("a string equal to \"heLLo\" ignoring case", matcher);
}

@Test public void
describesAMismatch() {
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
String expectedMismatchString = "was \"Cheese\"";
final Matcher<String> matcher = equalToIgnoringCase("heLLo");
String expectedMismatchString = "was \"Cheese\"";
assertMismatchDescription(expectedMismatchString, matcher, "Cheese");
}
}