fix couple of sonar issues

This commit is contained in:
Ingmar Goudt 2019-06-23 23:22:21 +02:00
parent 41357c15ff
commit 1cf6d99515
5 changed files with 21 additions and 30 deletions

View file

@ -40,7 +40,7 @@ public enum TableManager {
// protected static ScheduledExecutorService expireExecutor = ThreadExecutor.getInstance().getExpireExecutor();
private final Logger logger = Logger.getLogger(TableManager.class);
private static final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
private final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
private final ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<>();
private final ReadWriteLock controllersLock = new ReentrantReadWriteLock();

View file

@ -50,13 +50,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
// checks for compatibility
EffectType needType = EffectType.CONTINUOUS;
if (effect != null && !effect.getEffectType().equals(needType)) {
if (effect.getEffectType() != needType) {
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
}
if (otherwiseEffect != null && !otherwiseEffect.getEffectType().equals(needType)) {
if (otherwiseEffect != null && otherwiseEffect.getEffectType() != needType) {
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
}
if (effect != null && otherwiseEffect != null && !effect.getEffectType().equals(otherwiseEffect.getEffectType())) {
if (otherwiseEffect != null && effect.getEffectType() != otherwiseEffect.getEffectType()) {
Assert.fail("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString());
}
}
@ -119,7 +119,7 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
if (condition == null && baseCondition != null) {
condition = baseCondition;
}
boolean conditionState = condition.apply(game, source);
boolean conditionState = condition != null && condition.apply(game, source);
if (conditionState) {
effect.setTargetPointer(this.targetPointer);
return effect.apply(game, source);
@ -127,10 +127,10 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
otherwiseEffect.setTargetPointer(this.targetPointer);
return otherwiseEffect.apply(game, source);
}
if (!conditionState && effect.getDuration() == Duration.OneUse) {
if (effect.getDuration() == Duration.OneUse) {
used = true;
}
if (!conditionState && effect.getDuration() == Duration.Custom) {
if (effect.getDuration() == Duration.Custom) {
this.discard();
}
return false;

View file

@ -1,6 +1,5 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
@ -9,8 +8,9 @@ import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class FightTargetsEffect extends OneShotEffect {
@ -57,27 +57,23 @@ public class FightTargetsEffect extends OneShotEffect {
return creature1.fight(creature2, source, game);
}
}
if (!game.isSimulation()) {
game.informPlayers(card.getName() + " has been fizzled.");
}
}
if (!game.isSimulation()) {
game.informPlayers(card.getName() + " has been fizzled.");
}
return false;
}
@Override
public FightTargetsEffect
copy() {
public FightTargetsEffect copy() {
return new FightTargetsEffect(this);
}
@Override
public String
getText(Mode mode
) {
if (staticText
!= null && !staticText
.isEmpty()) {
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
@ -86,4 +82,4 @@ public class FightTargetsEffect extends OneShotEffect {
.getTargets().get(1).getTargetName();
}
}
}

View file

@ -10,7 +10,6 @@ import mage.game.permanent.Permanent;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
@ -47,7 +46,7 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
while (creature.getAbilities().contains(ability)) {
if (!creature.getAbilities().remove(ability)) {
// Something went wrong - ability has an other id?
logger.warn("ability" + ability.getRule() + "couldn't be removed.");
logger.warn("ability" + ability.getRule() + "couldn't be removed.");
}
}
}
@ -59,12 +58,8 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
StringBuilder sb = new StringBuilder();
sb.append(attachmentType.verb());
sb.append(" creature ");
if (duration == Duration.WhileOnBattlefield) {
sb.append("loses ");
} else {
sb.append("loses ");
}
sb.append(ability.getRule());
sb.append("loses ");
sb.append(ability.getRule());
staticText = sb.toString();
}

View file

@ -118,7 +118,7 @@ public class TurnMods extends ArrayList<TurnMod> {
ListIterator<TurnMod> it = this.listIterator(this.size());
while (it.hasPrevious()) {
TurnMod turnMod = it.previous();
if (turnMod.getExtraPhase() != null && turnMod.getPlayerId().equals(playerId) && turnMod.getExtraPhase() != null && (turnMod.getAfterPhase() == null || turnMod.getAfterPhase() == afterPhase)) {
if (turnMod.getExtraPhase() != null && turnMod.getPlayerId().equals(playerId) && (turnMod.getAfterPhase() == null || turnMod.getAfterPhase() == afterPhase)) {
it.remove();
return turnMod;
}