Skip to content

Commit

Permalink
Ensure spaces after double points in messages (#12986)
Browse files Browse the repository at this point in the history
Regex:
- (throw.*):" \+
- (return.*):" \+
- ([a-z]+):" \+
- ([a-z1-9]+[a-z1-9]+):" \+
+ $1: " +
  • Loading branch information
frigoref authored Nov 6, 2024
1 parent a10dd81 commit 9a1f926
Show file tree
Hide file tree
Showing 89 changed files with 164 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private IChatChannel getChatBroadcaster() {
@Override
public Collection<ChatParticipant> joinChat() {
final INode node = MessageContext.getSender();
log.info("Chatter:" + node + " is joining chat:" + chatName);
log.info("Chatter: " + node + " is joining chat: " + chatName);
final Tag tag = Tag.NONE;
synchronized (mutex) {
final PlayerChatId id = PlayerChatId.newId();
Expand Down Expand Up @@ -156,6 +156,6 @@ private void leaveChatInternal(final INode node) {
chatters.remove(node);
}
getChatBroadcaster().speakerRemoved(node.getPlayerName());
log.info("Chatter:" + node + " has left chat:" + chatName);
log.info("Chatter: " + node + " has left chat: " + chatName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public Change invert() {

@Override
public String toString() {
return "Bombing unit damage change. Hits:" + hits + " undoHits:" + undoHits;
return "Bombing unit damage change. Hits: " + hits + " undoHits: " + undoHits;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public UnitHolder getUnitHolder(final String name, final String type) {
case UnitHolder.TERRITORY:
return map.getTerritory(name);
default:
throw new IllegalStateException("Invalid type:" + type);
throw new IllegalStateException("Invalid type: " + type);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public GameObjectStreamData(final Named named) {
} else if (named instanceof ProductionFrontier) {
type = GameType.PRODUCTIONFRONTIER;
} else {
throw new IllegalArgumentException("Wrong type:" + named);
throw new IllegalArgumentException("Wrong type: " + named);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean isNull() {
@Getter
private String whoAmI =
// @TODO why : separation, no_one also used in ServerSetupPanel; create constant
"null:" + "no_one";
"null: " + "no_one";

private TechAttachment techAttachment;

Expand Down Expand Up @@ -124,7 +124,7 @@ public boolean isNull() {

@Override
public String toString() {
return "PlayerId named:" + getName();
return "PlayerId named: " + getName();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ private static boolean collectionsAreEqual(final Collection<Unit> a, final Colle

@Override
public String toString() {
return "Move message route:" + route + " units:" + getUnits();
return "Move message route: " + route + " units: " + getUnits();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public ProductionFrontier(

public void addRule(final ProductionRule rule) {
if (rules.contains(rule)) {
throw new IllegalStateException("Rule already added:" + rule);
throw new IllegalStateException("Rule already added: " + rule);
}
rules.add(rule);
cachedRules = null;
}

public void removeRule(final ProductionRule rule) {
if (!rules.contains(rule)) {
throw new IllegalStateException("Rule not present:" + rule);
throw new IllegalStateException("Rule not present: " + rule);
}
rules.remove(rule);
cachedRules = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public Relationship(final RelationshipType relationshipType, final int roundValu

@Override
public String toString() {
return roundCreated + ":" + relationshipType;
return roundCreated + ": " + relationshipType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public RepairFrontier(final String name, final GameData data, final List<RepairR

public void addRule(final RepairRule rule) {
if (rules.contains(rule)) {
throw new IllegalStateException("Rule already added:" + rule);
throw new IllegalStateException("Rule already added: " + rule);
}
rules.add(rule);
cachedRules = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public int getQuantity(final String name) {
try (GameData.Unlocker ignored = getData().acquireReadLock()) {
final Resource resource = getData().getResourceList().getResource(name);
if (resource == null) {
throw new IllegalArgumentException("No resource named:" + name);
throw new IllegalArgumentException("No resource named: " + name);
}
return getQuantity(resource);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ private void add(final Territory territory) {
if (r1.numberOfSteps() == 0) {
if (!r1.getStart().equals(r2.getStart())) {
throw new IllegalArgumentException(
"Cannot join, r1 doesnt end where r2 starts. r1:" + r1 + " r2:" + r2);
"Cannot join, r1 doesnt end where r2 starts. r1: " + r1 + " r2: " + r2);
}
} else {
if (!r1.getEnd().equals(r2.getStart())) {
throw new IllegalArgumentException(
"Cannot join, r1 doesnt end where r2 starts. r1:" + r1 + " r2:" + r2);
"Cannot join, r1 doesnt end where r2 starts. r1: " + r1 + " r2: " + r2);
}
}
final Collection<Territory> c1 = new ArrayList<>(r1.steps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Rule {
default void addResult(final NamedAttachable obj, final int quantity) {
if (!(obj instanceof UnitType) && !(obj instanceof Resource)) {
throw new IllegalArgumentException(
"results must be units or resources, not:" + obj.getClass().getName());
"results must be units or resources, not: " + obj.getClass().getName());
}

getResults().put(obj, quantity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void addAdvance(final List<TechAdvance> list) {

public void removeAdvance(final TechAdvance t) {
if (!techs.contains(t)) {
throw new IllegalStateException("Advance not present:" + t);
throw new IllegalStateException("Advance not present: " + t);
}
techs.remove(t);
getData().getTechTracker().clearCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Collection<Unit> getUnits(final UnitType type, final int maxUnits) {
return new ArrayList<>();
}
if (maxUnits < 0) {
throw new IllegalArgumentException("value must be positive. Instead its:" + maxUnits);
throw new IllegalArgumentException("value must be positive. Instead its: " + maxUnits);
}
final Collection<Unit> units = new ArrayList<>();
for (final Unit current : this.units) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ private Collection<Unit> buildUnitsWithOwner(final GameState data) {

@Override
public String toString() {
return "Add unit change. Add to:" + name + " units:" + units;
return "Add unit change. Add to: " + name + " units: " + units;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ protected void perform(final GameState data) {

@Override
public String toString() {
return "Remove unit change. Remove from:" + name + " units:" + units;
return "Remove unit change. Remove from: " + name + " units: " + units;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void shutDown() {
final Player gp = this.gamePlayers.get(player);
if (gp == null) {
throw new IllegalStateException(
"Game player not found. Player:" + player + " on:" + messengers.getLocalNode());
"Game player not found. Player: " + player + " on: " + messengers.getLocalNode());
}
gp.start(stepName);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public VerifiedRandomNumbers(final String annotation, final int[] values) {

@Override
public String toString() {
return "Rolled :" + MyFormatter.asDice(values) + " for " + annotation;
return "Rolled : " + MyFormatter.asDice(values) + " for " + annotation;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public PlayerListing(

@Override
public String toString() {
return "PlayerListingMessage:" + playerToNodeListing;
return "PlayerListingMessage: " + playerToNodeListing;
}

public Map<String, PlayerTypes.Type> getLocalPlayerTypeMap(final PlayerTypes playerTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static String[] classesToString(final Class<?>[] classes, final Object[]

@Override
public String toString() {
return "Remote method call, method name:" + methodName + " remote name:" + remoteName;
return "Remote method call, method name: " + methodName + " remote name: " + remoteName;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public RemoteName(final String name, final Class<?> clazz) {

@Override
public String toString() {
return name + ":" + clazz.getSimpleName();
return name + ": " + clazz.getSimpleName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void invoke(final HubInvoke hubInvoke, final Collection<INode> remote, f
if (hubInvoke.needReturnValues) {
if (remote.size() != 1) {
throw new IllegalStateException(
"Too many nodes:" + remote + " for remote name " + hubInvoke.call);
"Too many nodes: " + remote + " for remote name " + hubInvoke.call);
}
final InvocationInProgress invocationInProgress =
new InvocationInProgress(CollectionUtils.getAny(remote), hubInvoke, from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public boolean hasSingleImplementor() {
*/
boolean removeImplementor(final Object implementor) {
if (!implementors.remove(implementor)) {
throw new IllegalStateException("Not removed, impl:" + implementor + " have " + implementors);
throw new IllegalStateException(
"Not removed, impl: " + implementor + " have " + implementors);
}
return implementors.isEmpty();
}
Expand Down Expand Up @@ -138,7 +139,7 @@ private RemoteMethodCallResults invokeSingle(
} catch (final InvocationTargetException e) {
return new RemoteMethodCallResults(e.getTargetException());
} catch (final IllegalAccessException | IllegalArgumentException e) {
log.error("error in call:" + call, e);
log.error("error in call: " + call, e);
return new RemoteMethodCallResults(e);
} finally {
MessageContext.setSenderNodeForThread(null);
Expand All @@ -147,6 +148,11 @@ private RemoteMethodCallResults invokeSingle(

@Override
public String toString() {
return "Name:" + name + " singleThreaded:" + singleThreaded + " implementors:" + implementors;
return "Name: "
+ name
+ " singleThreaded: "
+ singleThreaded
+ " implementors: "
+ implementors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public HasEndPointImplementor(final String endPointName) {

@Override
public String toString() {
return this.getClass().getName() + ":" + endPointName;
return this.getClass().getName() + ": " + endPointName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public InvocationResults(final RemoteMethodCallResults results, final UUID metho

@Override
public String toString() {
return "Invocation results for method id:" + methodCallId + " results:" + results;
return "Invocation results for method id: " + methodCallId + " results: " + results;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public RemoteMethodCallResults invokeAndWait(
+ remoteCall.getRemoteName());
}
if (results.size() > 1) {
throw new IllegalStateException("Too many implementors, got back:" + results);
throw new IllegalStateException("Too many implementors, got back: " + results);
}
return results.get(0);
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public void removeImplementor(final String name, final Object implementor) {
synchronized (endPointMutex) {
final EndPoint endPoint = localEndPoints.get(name);
if (endPoint == null) {
throw new IllegalStateException("No end point for:" + name);
throw new IllegalStateException("No end point for: " + name);
}
final boolean noneLeft = endPoint.removeImplementor(implementor);
if (noneLeft) {
Expand Down Expand Up @@ -350,11 +350,11 @@ private void processMessage(final EndPoint local, final SpokeInvoke invoke, fina

private void assertIsServer(final INode from) {
Preconditions.checkState(
from.equals(messenger.getServerNode()), "Not from server! Instead from:" + from);
from.equals(messenger.getServerNode()), "Not from server! Instead from: " + from);
}

@Override
public String toString() {
return "Server:" + messenger.isServer() + " EndPoints:" + localEndPoints;
return "Server: " + messenger.isServer() + " EndPoints: " + localEndPoints;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public int getRandom(final int max, final String annotation) {
@Override
public int[] getRandom(final int max, final int count, final String annotation) {
if (count <= 0) {
throw new IllegalArgumentException("Invalid count:" + count);
throw new IllegalArgumentException("Invalid count: " + count);
}
final Vault vault = game.getVault();
// generate numbers locally, and put them in the vault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void rollInSeparateThread() {
waitForWindowToBecomeVisible();

appendText(subjectMessage + "\n");
appendText("Contacting " + diceServer.getDisplayName() + "\n");
appendText("Contacting " + diceServer.getDisplayName() + "\n");
try {
final String text = diceServer.postRequest(sides, count, subjectMessage, gameId);
if (text.isEmpty()) {
Expand All @@ -226,7 +226,7 @@ private void rollInSeparateThread() {
notifyError();
}
if (!test) {
appendText("Contacted :" + text + "\n");
appendText("Contacted: " + text + "\n");
}
diceRoll = diceServer.getDice(text, count);
appendText("Success!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void addLockedValue(final VaultId id, final byte[] data) {
return;
}
if (unverifiedValues.putIfAbsent(id, data) != null) {
throw new IllegalStateException("duplicate values for id:" + id);
throw new IllegalStateException("duplicate values for id: " + id);
}
synchronized (waitForLock) {
waitForLock.notifyAll();
Expand Down Expand Up @@ -105,7 +105,7 @@ public void unlock(final VaultId id, final byte[] secretKeyBytes) {
final byte[] data = new byte[decrypted.length - KNOWN_VAL.length];
System.arraycopy(decrypted, KNOWN_VAL.length, data, 0, data.length);
if (verifiedValues.putIfAbsent(id, data) != null) {
throw new IllegalStateException("duplicate values for id:" + id);
throw new IllegalStateException("duplicate values for id: " + id);
}
synchronized (waitForLock) {
waitForLock.notifyAll();
Expand All @@ -126,7 +126,7 @@ public Vault(final IChannelMessenger channelMessenger) {
secretKeyFactory = SecretKeyFactory.getInstance(ALGORITHM);
keyGen = KeyGenerator.getInstance(ALGORITHM);
} catch (final NoSuchAlgorithmException e) {
throw new IllegalStateException("Nothing known about algorithm:" + ALGORITHM, e);
throw new IllegalStateException("Nothing known about algorithm: " + ALGORITHM, e);
}
}

Expand Down Expand Up @@ -169,7 +169,7 @@ public VaultId lock(final byte[] data) {
final VaultId id = new VaultId(channelMessenger.getLocalNode());
final SecretKey key = keyGen.generateKey();
if (secretKeys.putIfAbsent(id, key) != null) {
throw new IllegalStateException("duplicate id:" + id);
throw new IllegalStateException("duplicate id: " + id);
}
// we already know it, so might as well keep it
verifiedValues.put(id, data);
Expand Down Expand Up @@ -238,7 +238,7 @@ public byte[] get(final VaultId id) throws NotUnlockedException {
} else if (unverifiedValues.containsKey(id)) {
throw new NotUnlockedException();
} else {
throw new IllegalStateException("Nothing known about id:" + id);
throw new IllegalStateException("Nothing known about id: " + id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ INode getGeneratedOn() {

@Override
public String toString() {
return "VaultId generated on:" + generatedOn + " id:" + uniqueId;
return "VaultId generated on: " + generatedOn + " id: " + uniqueId;
}
}
Loading

0 comments on commit 9a1f926

Please sign in to comment.