Commit 4d6c9024 authored by Alexandre CAILLIAUD's avatar Alexandre CAILLIAUD
Browse files

Merge branch '7-prettier-configuration-and-hooks' into 'master'

Resolve "prettier configuration and hooks"

Closes #7

See merge request !6
parents c247b5c5 baa7c380
......@@ -197,4 +197,7 @@ buildNumber.properties
# Ignore all local history of files
.history
### Node ###
node_modules/
# End of https://www.toptal.com/developers/gitignore/api/eclipse,intellij,visualstudiocode,java,maven
module.exports = {
hooks: {
"pre-commit": "lint-staged"
}
};
.git
node_modules
package-lock.json
**/node_modules
**/package-lock.json
**/target
# Prettier configuration
overrides:
- files: "**/*.java"
options:
# js and ts rules
arrowParens: avoid
# jsx and tsx rules
jsxBracketSameLine: false
printWidth: 140
tabWidth: 2
useTabs: false
singleQuote: true
- files:
- "**/*.{yml,yaml}"
options:
singleQuote: false
This diff is collapsed.
{
"name": "live-coding-fr",
"version": "0.0.0",
"description": "Repository for Ippon twitch kata",
"private": true,
"license": "Apache2",
"cacheDirectories": [
"node_modules"
],
"devDependencies": {
"husky": "1.3.1",
"lint-staged": "8.1.4",
"prettier": "^1.19.1",
"prettier-plugin-java": "^0.6.0"
},
"engines": {
"node": ">= 12.16.1",
"npm": ">= 6.13.4"
},
"lint-staged": {
"**/*.{md,json,js,ts,tsx,css,scss,yml,yaml,java}": [
"prettier --write",
"git add"
]
},
"scripts": {
"prettier:java": "prettier --write \"**/*.java\" --plugin=./node_modules/prettier-plugin-java",
"prettier:java:watch": "onchange '**/*.java' -- prettier --write {{changed}} --plugin=./node_modules/prettier-plugin-java",
"prettier:java:check": "prettier --check \"**/*.java\" --plugin=./node_modules/prettier-plugin-java"
}
}
......@@ -4,11 +4,9 @@ import java.util.NavigableMap;
import java.util.TreeMap;
public final class Numerals {
private static final NavigableMap<Integer, Roman> CONVERSIONS = buildConversions();
private Numerals() {
}
private Numerals() {}
public static String toRoman(int arabic) {
if (arabic <= 0) {
......@@ -17,11 +15,9 @@ public final class Numerals {
Integer highestKnownConversion = CONVERSIONS.floorKey(arabic);
String highestKnownRepresentation = CONVERSIONS.get(highestKnownConversion)
.getRepresentation();
String highestKnownRepresentation = CONVERSIONS.get(highestKnownConversion).getRepresentation();
return highestKnownRepresentation
+ toRoman(arabic - highestKnownConversion);
return (highestKnownRepresentation + toRoman(arabic - highestKnownConversion));
}
private static NavigableMap<Integer, Roman> buildConversions() {
......@@ -34,6 +30,5 @@ public final class Numerals {
conversions.put(10, Roman.TEN);
return conversions;
}
}
package fr.ippon.kata.roman;
public enum Roman {
ONE("I"),
FOUR("IV"),
FIVE("V"),
NINE("IX"),
TEN("X");
ONE("I"),
FOUR("IV"),
FIVE("V"),
NINE("IX"),
TEN("X");
private String representation;
private String representation;
private Roman(String representation) {
this.representation = representation;
}
private Roman(String representation) {
this.representation = representation;
}
public String getRepresentation() {
return this.representation;
}
public String getRepresentation() {
return this.representation;
}
}
package fr.ippon.kata.roman;
import org.junit.jupiter.api.Test;
import static fr.ippon.kata.roman.Numerals.toRoman;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
class NumeralsTest {
@Test
......@@ -51,5 +51,4 @@ class NumeralsTest {
void shouldConvertFourteenToXIV() {
assertThat(toRoman(14)).isEqualTo("XIV");
}
}
\ No newline at end of file
}
package fr.ippon.kata.wrapper;
public class Wrapper {
private static final String SPACE = " ";
private static final String BREAK = "\n";
private int columns;
......@@ -28,8 +27,7 @@ public class Wrapper {
int spaceIndex = left.lastIndexOf(SPACE);
if (spaceIndex != -1) {
return join(sentence.substring(0, spaceIndex),
sentence.substring(spaceIndex + 1));
return join(sentence.substring(0, spaceIndex), sentence.substring(spaceIndex + 1));
}
return join(left, right);
......
package fr.ippon.kata.wrapper;
import org.junit.jupiter.api.Test;
import static fr.ippon.kata.wrapper.Wrapper.wrap;
import static org.assertj.core.api.Assertions.*;
import java.util.Arrays;
import java.util.stream.Collectors;
import static fr.ippon.kata.wrapper.Wrapper.wrap;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test;
class WrapperTest {
......@@ -32,18 +31,15 @@ class WrapperTest {
@Test
void shouldWrapAfterWord() {
assertThat(wrap("Once upon a time", 9))
.isEqualTo(join("Once upon", "a time"));
assertThat(wrap("Once upon a time", 9)).isEqualTo(join("Once upon", "a time"));
}
@Test
void shouldWrapBetweenWords() {
assertThat(wrap("Once upon a time in Hollywood", 13))
.isEqualTo(join("Once upon a", "time in", "Hollywood"));
assertThat(wrap("Once upon a time in Hollywood", 13)).isEqualTo(join("Once upon a", "time in", "Hollywood"));
}
private static String join(String... parts) {
return Arrays.stream(parts).collect(Collectors.joining("\n"));
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment