Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/github/javafaker/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public String lastName() {
}

public String latitude() {
return String.format("%.8g", (faker.random().nextDouble() * 180) - 90);
return String.format("%.8g", faker.random().nextDouble() * 180 - 90);
}

public String longitude() {
return String.format("%.8g", (faker.random().nextDouble() * 360) - 180);
return String.format("%.8g", faker.random().nextDouble() * 360 - 180);
}

public String timeZone() {
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/com/github/javafaker/Code.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,28 @@ public String isbn13(boolean separator) {
return separator ? isbn13.toString() : stripIsbnSeparator(isbn13);
}

private final int isbn10CheckDigit(CharSequence t) {
private int isbn10CheckDigit(CharSequence t) {
String value = stripIsbnSeparator(t);
int sum = 0;
for (int i = 0; i < value.length(); i++) {
sum += ((i + 1) * toInt(value.substring(i, i + 1)));
sum += (i + 1) * toInt(value.substring(i, i + 1));
}
return sum % 11;
}
}

private final int isbn13CheckDigit(CharSequence t) {
private int isbn13CheckDigit(CharSequence t) {
String value = stripIsbnSeparator(t);
int sum = 0;
int multiplier = 0;
for (int i = 0; i < value.length(); i++) {
multiplier = i % 2 == 0 ? 1 : 3;
sum += multiplier * toInt(value.subSequence(i, i + 1).toString());
}

return (10 - sum % 10) % 10;
return sum % 10;
}

private final String stripIsbnSeparator(CharSequence t) {
return t.toString().replaceAll("-","");
private String stripIsbnSeparator(CharSequence t) {
return t.toString().replaceAll("-", "");
}

public String asin() {
Expand Down Expand Up @@ -180,7 +179,7 @@ public String imei() {
}

// Choose the last digit so that it causes the entire string to pass the checksum.
str[len - 1] = Character.forDigit(((10 - (sum % 10)) % 10), 10);
str[len - 1] = Character.forDigit((10 - (sum % 10)) % 10, 10);

return new String(str);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/javafaker/Finance.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String creditCard(CreditCardType creditCardType) {
int luhnSum = 0;
int multiplier = 1;
for (Integer digit : reversedAsInt) {
multiplier = (multiplier == 2 ? 1 : 2);
multiplier = multiplier == 2 ? 1 : 2;
luhnSum += sum(String.valueOf(digit * multiplier).split(""));
}
int luhnDigit = (10 - (luhnSum % 10)) % 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ private int calculateChecksum(String number) {
String calculatedNumber = calculateDigits(dateString + birthNumber);
int sum = calculateDigitSum(calculatedNumber);

int lastDigit = (sum % 10);
int lastDigit = sum % 10;
int difference = 10 - lastDigit;

return (difference % 10);
return difference % 10;
}

private String calculateDigits(String numbers) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public String letterify(String letterString) {
* @return
*/
public String letterify(String letterString, boolean isUpper) {
return letterHelper((isUpper) ? 65 : 97, letterString); // from ascii table
return letterHelper(isUpper ? 65 : 97, letterString); // from ascii table
}

private String letterHelper(int baseChar, String letterString) {
Expand Down