Merge pull request #418 from valfirst/clean-up

Clean up
This commit is contained in:
Ricky Yim
2019-08-17 14:54:06 +10:00
committed by GitHub
11 changed files with 18 additions and 22 deletions
@@ -69,13 +69,13 @@ public class Company {
}
public String url() {
return join(new Object[]{
return join(
"www",
".",
FakerIDN.toASCII(domainName()),
".",
domainSuffix()
});
);
}
private String domainName(){
+1 -1
View File
@@ -24,6 +24,6 @@ public class File {
final String dir = dirOrNull == null ? faker.internet().slug() : dirOrNull;
final String name = nameOrNull == null ? faker.lorem().word().toLowerCase() : nameOrNull;
final String ext = extensionOrNull == null ? extension() : extensionOrNull;
return new StringBuilder(dir).append(sep).append(name).append(".").append(ext).toString();
return dir + sep + name + "." + ext;
}
}
@@ -51,7 +51,7 @@ public class Internet {
}
public String url() {
return join(new Object[]{
return join(
"www",
".",
FakerIDN.toASCII(
@@ -61,7 +61,7 @@ public class Internet {
),
".",
domainSuffix()
});
);
}
/**
+2 -2
View File
@@ -121,10 +121,10 @@ public class Name {
*/
public String username() {
String username = StringUtils.join(new String[]{
String username = StringUtils.join(
firstName().replaceAll("'", "").toLowerCase(),
".",
lastName().replaceAll("'", "").toLowerCase()}
lastName().replaceAll("'", "").toLowerCase()
);
return StringUtils.deleteWhitespace(username);
@@ -37,7 +37,7 @@ public class Relationships {
}
public String any() {
Method currentMethod = Relationships.class.getClass().getEnclosingMethod();
Method currentMethod = getClass().getEnclosingMethod();
try {
Method[] methods = Relationships.class.getDeclaredMethods();
@@ -57,4 +57,4 @@ public class Relationships {
}
}
}
}
@@ -14,8 +14,8 @@ public class EnIdNumber {
String ssn = f.regexify("[0-8]\\d{2}-\\d{2}-\\d{4}");
boolean isValid = true;
for (int i = 0; i < invalidSSNPatterns.length; i++) {
if (ssn.matches(invalidSSNPatterns[i])) {
for (String invalidSSNPattern : invalidSSNPatterns) {
if (ssn.matches(invalidSSNPattern)) {
isValid = false;
break;
}
@@ -13,18 +13,16 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class FakeValuesService {
private static final Pattern EXPRESSION_PATTERN = Pattern.compile("#\\{([a-z0-9A-Z_.]+)\\s?(?:'([^']+)')?(?:,'([^']+)')*\\}");
private static final Pattern EXPRESSION_PATTERN = Pattern.compile("#\\{([a-z0-9A-Z_.]+)\\s?(?:'([^']+)')?(?:,'([^']+)')*}");
private final Logger log = Logger.getLogger("faker");
@@ -108,7 +106,7 @@ public class FakeValuesService {
* with new Locale("pt","BR").
*/
private Locale normalizeLocale(Locale locale) {
final String[] parts = locale.toString().split("[-\\_]");
final String[] parts = locale.toString().split("[-_]");
if (parts.length == 1) {
return new Locale(parts[0]);
@@ -573,7 +571,7 @@ public class FakeValuesService {
* this is useful as we get to find the method and coerce the arguments in one
* shot, returning both when successful. This saves us from doing it more than once (coercing args).
*/
private class MethodAndCoercedArgs {
private static class MethodAndCoercedArgs {
private final Method method;
@@ -9,7 +9,7 @@ public class FoodTest extends AbstractFakerTest {
@Test
public void ingredient() {
assertThat(faker.food().ingredient(), matchesRegularExpression("[A-Za-z ]+"));
assertThat(faker.food().ingredient(), matchesRegularExpression("[A-Za-z- ]+"));
}
@Test
@@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.apache.commons.validator.routines.EmailValidator;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import java.util.List;
@@ -198,7 +197,7 @@ public class InternetTest extends AbstractFakerTest {
assertThat(faker.internet().ipV4Cidr(), countOf('/', is(1)));
for (int i = 0; i < 1000; i++) {
assertThat(parseInt(faker.internet().ipV4Cidr().split("\\/")[1]),
assertThat(parseInt(faker.internet().ipV4Cidr().split("/")[1]),
both(greaterThanOrEqualTo(1)).and(lessThan(32)));
}
}
@@ -257,7 +256,7 @@ public class InternetTest extends AbstractFakerTest {
assertThat(faker.internet().ipV6Cidr(), countOf('/', is(1)));
for (int i = 0; i < 1000; i++) {
assertThat(parseInt(faker.internet().ipV6Cidr().split("\\/")[1]),
assertThat(parseInt(faker.internet().ipV6Cidr().split("/")[1]),
both(greaterThanOrEqualTo(1)).and(lessThan(128)));
}
}
@@ -10,7 +10,7 @@ public class LeagueOfLegendsTest extends AbstractFakerTest {
@Test
public void champion() {
assertThat(faker.leagueOfLegends().champion(), matchesRegularExpression("^(\\w+\\.?-?'?\\s?)+$"));
assertThat(faker.leagueOfLegends().champion(), matchesRegularExpression("^(\\w+\\.?-?'?\\s?&?\\s?)+$"));
}
@Test
@@ -1,6 +1,5 @@
package com.github.javafaker;
import com.github.javafaker.repeating.Repeat;
import org.junit.Test;
import static com.github.javafaker.matchers.MatchesRegularExpression.matchesRegularExpression;