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

Useless parentheses around expressions should be removed #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ protected void renderCellBackground(Graphics g, int xCell, int yCell) {
int width = g.getClipBounds().width;
int height = g.getClipBounds().height;

boolean isBlue = (yCell == 0) || (yCell == 5);
boolean isBlack = ((xCell == 0) || (xCell == 5)) && !isBlue;
boolean isBlue = yCell == 0 || yCell == 5;
boolean isBlack = (xCell == 0 || xCell == 5) && !isBlue;

if(isBlue) {
CommonGraphics.drawBubbles(g, xCell*11+yCell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void observe(Event event) {
// moved off into a new thread
int stepNum = stepCount;
stepCount++;
boolean atEnd = (tabs.getSelectedIndex() == tabs.getTabCount()-1);
boolean atEnd = tabs.getSelectedIndex() == tabs.getTabCount()-1;

for(int i = tabs.getTabCount(); i < stepNum; i++)
tabs.add(new Integer(i+1).toString(), new JPanel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionExce
long start = System.currentTimeMillis();

List<Move> moves = getStateMachine().getLegalMoves(getCurrentState(), getRole());
Move selection = (moves.get(new Random().nextInt(moves.size())));
Move selection = moves.get(new Random().nextInt(moves.size()));

long stop = System.currentTimeMillis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionExce
long finishBy = timeout - 1000;

List<Move> moves = theMachine.getLegalMoves(getCurrentState(), getRole());
Move selection = (moves.get(theRandom.nextInt(moves.size())));
Move selection = moves.get(theRandom.nextInt(moves.size()));

// Shuffle the moves into a random order, so that when we find the first
// move that doesn't give our opponent a forced win, we aren't always choosing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ private Map<Proposition, Proposition> makeLegalInputMap() {
// Create a mapping from Body->Input.
Map<List<GdlTerm>, Proposition> inputPropsByBody = new HashMap<List<GdlTerm>, Proposition>();
for(Proposition inputProp : inputPropositions.values()) {
List<GdlTerm> inputPropBody = (inputProp.getName()).getBody();
List<GdlTerm> inputPropBody = inputProp.getName().getBody();
inputPropsByBody.put(inputPropBody, inputProp);
}
// Use that mapping to map Input->Legal and Legal->Input
// based on having the same Body proposition.
for(Set<Proposition> legalProps : legalPropositions.values()) {
for(Proposition legalProp : legalProps) {
List<GdlTerm> legalPropBody = (legalProp.getName()).getBody();
List<GdlTerm> legalPropBody = legalProp.getName().getBody();
if (inputPropsByBody.containsKey(legalPropBody)) {
Proposition inputProp = inputPropsByBody.get(legalPropBody);
legalInputMap.put(inputProp, legalProp);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/ggp/base/util/prover/aima/AimaProver.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void askOr(GdlOr or, LinkedList<GdlLiteral> goals, KnowledgeBase context
isConstant &= isConstantRet.value;
goals.removeFirst();

if (askOne && (results.size() > 0))
if (askOne && results.size() > 0)
{
break;
}
Expand All @@ -171,7 +171,7 @@ private void askSentence(GdlSentence sentence, LinkedList<GdlLiteral> goals, Kno
{
ask(goals, context, theta.compose(thetaPrime), cache, renamer, askOne, results, recursionHandler, isConstantRet);
isConstant &= isConstantRet.value;
if (askOne && (results.size() > 0))
if (askOne && results.size() > 0)
{
break;
}
Expand Down Expand Up @@ -275,7 +275,7 @@ private Collection<Substitution> findSentenceResults(GdlSentence sentence,
}

List<Substitution> cachedResults = fixedAnswerCache.get(sentence, varRenamedSentence);
isConstantRet.value = (cachedResults != null);
isConstantRet.value = cachedResults != null;
if (cachedResults == null) {
cachedResults = cache.get(sentence, varRenamedSentence);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean contains(GdlVariable variable)
@Override
public boolean equals(Object o)
{
if ((o != null) && (o instanceof Substitution))
if (o != null && o instanceof Substitution)
{
Substitution substitution = (Substitution) o;
return substitution.contents.equals(contents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static boolean unifyTerm(GdlTerm x, GdlTerm y, Substitution theta)
{
if(x.equals(y))
return true;
if ((x instanceof GdlConstant) && (y instanceof GdlConstant))
if (x instanceof GdlConstant && y instanceof GdlConstant)
{
if (!x.equals(y))
{
Expand All @@ -42,7 +42,7 @@ else if (y instanceof GdlVariable)
if (!unifyVariable((GdlVariable) y, x, theta))
return false;
}
else if ((x instanceof GdlFunction) && (y instanceof GdlFunction))
else if (x instanceof GdlFunction && y instanceof GdlFunction)
{
GdlFunction xFunction = (GdlFunction) x;
GdlFunction yFunction = (GdlFunction) y;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static boolean unifyVariable(GdlVariable var, GdlTerm x, Substitution th
{
return unifyTerm(theta.get(var), x, theta);
}
else if ((x instanceof GdlVariable) && theta.contains((GdlVariable) x))
else if (x instanceof GdlVariable && theta.contains((GdlVariable) x))
{
return unifyTerm(var, theta.get((GdlVariable) x), theta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public String toString()
@Override
public boolean equals(Object o)
{
if ((o != null) && (o instanceof MachineState))
if (o != null && o instanceof MachineState)
{
MachineState state = (MachineState) o;
return state.getContents().equals(getContents());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/ggp/base/util/statemachine/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Move create(String contents) {
@Override
public boolean equals(Object o)
{
if ((o != null) && (o instanceof Move)) {
if (o != null && o instanceof Move) {
Move move = (Move) o;
return move.contents.equals(contents);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/ggp/base/util/statemachine/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static Role create(String name) {
@Override
public boolean equals(Object o)
{
if ((o != null) && (o instanceof Role))
if (o != null && o instanceof Role)
{
Role role = (Role) o;
return role.name.equals(name);
Expand Down