Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Add trailing spaces checkstyle rule
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Aug 28, 2017
1 parent d7fee35 commit 9b08433
Show file tree
Hide file tree
Showing 47 changed files with 160 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public interface CaseRepository {
* @return a case
*/
List<Network> load(DateTime date, CaseType type, Country country);

/**
* Check if the all the data of a case is available
*
*
* @param date date of the case
* @param type type of the case, snapshot (SN) or forecast (FO)
* @param country case perimeter, merge if null
Expand Down
7 changes: 7 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

<module name="NewlineAtEndOfFile"/>

<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>

<module name="Translation"/>

<module name="TreeWalker">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ITeslaException() {
public ITeslaException(String msg) {
super(msg);
}

public ITeslaException(Throwable throwable) {
super(throwable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ public XmlPlatformConfig(FileSystem fileSystem, Path configDir, Path cacheDir, S
LOGGER.info("Platform configuration XML file {} not found", file);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ public void closed(String streamName) {
});
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
public interface MemoryMappedFile extends AutoCloseable {

boolean exists();

ByteBuffer getBuffer(int size) throws IOException;

@Override
void close() throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface MemoryMappedFileFactory {

MemoryMappedFile create(Path path) throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class MemoryMappedFileImpl implements MemoryMappedFile {

private final File file;

private RandomAccessFile raf;

public MemoryMappedFileImpl(File file) throws IOException {
Expand All @@ -46,5 +46,5 @@ public void close() throws IOException {
raf.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@

/**
* A thread safe service loader.
*
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class ServiceLoaderCache<S> {

private final Class<S> serviceClass;

private List<S> services;

public ServiceLoaderCache(Class<S> serviceClass) {
this.serviceClass = Objects.requireNonNull(serviceClass);
}

public synchronized List<S> getServices() {
if (services == null) {
services = Lists.newArrayList(ServiceLoader.load(serviceClass));
}
return services;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public class XmlPlatformConfigTest {

public XmlPlatformConfigTest() {
}

Expand Down Expand Up @@ -88,7 +88,7 @@ public void moduleConfigTest() throws IOException, XMLStreamException, SAXExcept
modConfig.getDoubleProperty("d2");
fail();
} catch (Exception ignored) {
}
}
assertEquals(4.5d, modConfig.getDoubleProperty("d2", 4.5d), 0d);
assertEquals(ArrayList.class, modConfig.getClassProperty("c", List.class));
assertEquals(Arrays.asList("a", "b", "c"), modConfig.getStringListProperty("sl1"));
Expand Down Expand Up @@ -149,12 +149,12 @@ public void properties2XmlConvertionTest() throws IOException, XMLStreamExceptio
assertEquals("thanks", propsConfig.getModuleConfig("mod2").getStringProperty("c"));
String xmlConfigName = "config";
PropertiesPlatformConfig.writeXml(cfgDir, cfgDir.resolve(xmlConfigName + ".xml"));

XmlPlatformConfig xmlConfig = new XmlPlatformConfig(cfgDir, xmlConfigName, fileSystem);
assertEquals("hello", xmlConfig.getModuleConfig("mod1").getStringProperty("a"));
assertEquals("bye", xmlConfig.getModuleConfig("mod1").getStringProperty("b"));
assertEquals("thanks", xmlConfig.getModuleConfig("mod2").getStringProperty("c"));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void test() throws IOException {
} catch (IllegalArgumentException ignored) {
}
}

private void testAddMapping(StringToIntMapper<TestSubset> mapper) throws IOException {
String value = "value1";
assertFalse(mapper.isMapped(TestSubset.TYPE, value));
Expand All @@ -78,7 +78,7 @@ private void testAddMapping(StringToIntMapper<TestSubset> mapper) throws IOExcep
assertEquals(2, num);
assertEquals(value, mapper.getId(TestSubset.TYPE, 2));
assertEquals(2, mapper.getInt(TestSubset.TYPE, value));

String content = String.join(System.lineSeparator(), "TYPE;value1;1", "TYPE;value2;2");
try (Writer writer = new StringWriter()) {
mapper.dump(writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public interface MpiStatistics extends AutoCloseable {

/**
* Export tasks statistics to CSV.
*
*
* @param writer
*/
void exportTasksToCsv(Writer writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ interface SubCommand {
List<String> getArgs(int executionNumber);

int getTimeout();

// only used for display
String toString(int executionNumber);

}

List<SubCommand> getSubCommands();

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static class SubCommandImpl implements SubCommand {
private final Function<Integer, List<String>> args;

private final int timeout;

SubCommandImpl(String program, Function<Integer, List<String>> args, int timeout) {
this.program = program;
this.args = args;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ public interface SimpleCommand extends Command {
List<String> getArgs(int executionNumber);

int getTimeout();

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SimpleCommandImpl extends AbstractCommand implements SimpleCommand {
private final Function<Integer, List<String>> args;

private final int timeout;

SimpleCommandImpl(String id, String program, Function<Integer, List<String>> args, int timeout,
List<InputFile> inputFiles, List<OutputFile> outputFiles) {
super(id, inputFiles, outputFiles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface ContingenciesProviderFactory {
default <T extends ContingenciesProvider> T create(Path contingenciesFile) {
return create();
}

default <T extends ContingenciesProvider> T create(InputStream data) {
return create();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @author Massimo Ferraro <massimo.ferraro@techrain.it>
*/
public class ContingencyDeserializer extends StdDeserializer<Contingency> {

public ContingencyDeserializer() {
super(Contingency.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Objects;

public class ContingencyJsonTest extends AbstractConverterTest {

private static Contingency create() {
List<ContingencyElement> elements = new ArrayList<>();
elements.add(new BranchContingency("NHV1_NHV2_2", "VLHV1"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ private EnergySource(boolean intermittent) {
public boolean isIntermittent() {
return intermittent;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/**
* Base class for <code>Generator</code> reactive limits.
*
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
public interface ReactiveLimits {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* ...
* .add();
*</pre>
*
*
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
* @see ShuntCompensator
* @see VoltageLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public interface StateManager {
* @throws eu.itesla_project.commons.ITeslaException if the state is not found
*/
void setWorkingState(String stateId);

/**
* Create a new state by cloning an existing one.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ public static int getCcNum(Bus b) {
}
return ccNum;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public static void loadNetworks(Path dir, boolean parallel, Consumer<Network> co
public static void loadNetworks(Path dir, Consumer<Network> consumer) throws IOException, InterruptedException, ExecutionException {
loadNetworks(dir, false, LocalComputationManager.getDefault(), CONFIG.get(), consumer);
}

public static Network loadNetwork(String filename, InputStream data, ComputationManager computationManager, ImportConfig config, Properties parameters) {
return loadNetwork(filename, data, computationManager, config, parameters, LOADER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public void printTopology(PrintStream out, ShortIdDictionary dict) {
.append(" status=").append(aSwitch.isOpen() ? "open" : "closed");
return builder.toString();
};

graph.print(out, vertexToString, edgeToString);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static Network read(InputStream is, XmlImportConfig config, Anonymizer an
case TieLineXml.ROOT_ELEMENT_NAME:
TieLineXml.INSTANCE.read(network, context);
break;

case HvdcLineXml.ROOT_ELEMENT_NAME:
HvdcLineXml.INSTANCE.read(network, context);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class AbstractValidationFormatterWriter implements ValidationWri

protected TableFormatter formatter;

protected TableFormatter createTableFormatter(String id, Class<? extends TableFormatterFactory> formatterFactoryClass,
protected TableFormatter createTableFormatter(String id, Class<? extends TableFormatterFactory> formatterFactoryClass,
TableFormatterConfig formatterConfig, Writer writer, ValidationType validationType) {
try {
TableFormatterFactory factory = formatterFactoryClass.newInstance();
Expand All @@ -40,7 +40,7 @@ public abstract void write(String branchId, double p1, double p1Calc, double q1,
double u1, double u2, double theta1, double theta2, double z, double y, double ksi) throws IOException;

@Override
public abstract void write(String generatorId, float p, float q, float v, float targetP, float targetQ, float targetV,
public abstract void write(String generatorId, float p, float q, float v, float targetP, float targetQ, float targetV,
boolean connected, boolean voltageRegulatorOn, float minQ, float maxQ) throws IOException;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static boolean checkFlows(String id, double r, double x, double rho1, dou
}

public static boolean checkFlows(String id, double r, double x, double rho1, double rho2, double u1, double u2, double theta1, double theta2, double alpha1,
double alpha2, double g1, double g2, double b1, double b2, float p1, float q1, float p2, float q2, ValidationConfig config,
double alpha2, double g1, double g2, double b1, double b2, float p1, float q1, float p2, float q2, ValidationConfig config,
ValidationWriter flowsWriter) {
boolean ok = true;
try {
Expand Down Expand Up @@ -249,7 +249,7 @@ public static boolean checkFlows(Network network, ValidationConfig config, Valid

return linesOk && transformersOk;
}

public static boolean checkGenerators(Network network, ValidationConfig config, Path file) throws IOException {
Objects.requireNonNull(file);
try (Writer writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
Expand All @@ -276,7 +276,7 @@ public static boolean checkGenerators(Network network, ValidationConfig config,
.reduce(Boolean::logicalAnd).orElse(true);
return generatorsOk;
}

public static boolean checkGenerators(Generator gen, ValidationConfig config, Writer writer) {
Objects.requireNonNull(gen);
Objects.requireNonNull(config);
Expand Down Expand Up @@ -313,7 +313,7 @@ public static boolean checkGenerators(Generator gen, ValidationConfig config, Va
}
return true;
}

public static boolean checkGenerators(String id, float p, float q, float v, float targetP, float targetQ, float targetV,
boolean voltageRegulatorOn, float minQ, float maxQ, ValidationConfig config, Writer writer) {
Objects.requireNonNull(id);
Expand All @@ -334,7 +334,7 @@ public static boolean checkGenerators(String id, float p, float q, float v, floa
generatorsWriter.write(id, p, q, v, targetP, targetQ, targetV, true, voltageRegulatorOn, minQ, maxQ);
// a validation error should be detected if there is both a voltage and a target but no p or q
if (Float.isNaN(p) || Float.isNaN(q)) {
if ((!Float.isNaN(targetP) && targetP != 0)
if ((!Float.isNaN(targetP) && targetP != 0)
|| (!Float.isNaN(targetQ) && targetQ != 0)) {
LOGGER.warn(id + ": P=" + p + " targetP=" + targetP + " - Q=" + q + " targetP=" + targetQ);
return false;
Expand All @@ -352,13 +352,13 @@ public static boolean checkGenerators(String id, float p, float q, float v, floa
LOGGER.warn(id + ": voltage regulator off - Q=" + q + " targetQ=" + targetQ);
ok = false;
}
// if voltageRegulatorOn="true" then
// if voltageRegulatorOn="true" then
// either q is equal to g.getReactiveLimits().getMinQ(p) and V is lower than g.getTargetV()
// or q is equal to g.getReactiveLimits().getMaxQ(p) and V is higher than g.getTargetV()
// or V at the connected bus is equal to g.getTargetV()
if (voltageRegulatorOn
&& (Math.abs(q + minQ) > config.getThreshold() || (v - targetV) >= config.getThreshold())
&& (Math.abs(q + maxQ) > config.getThreshold() || (targetV - v) >= config.getThreshold())
if (voltageRegulatorOn
&& (Math.abs(q + minQ) > config.getThreshold() || (v - targetV) >= config.getThreshold())
&& (Math.abs(q + maxQ) > config.getThreshold() || (targetV - v) >= config.getThreshold())
&& Math.abs(v - targetV) > config.getThreshold()) {
LOGGER.warn(id + ": voltage regulator on - Q=" + q + " minQ=" + minQ + " maxQ=" + maxQ + " - V=" + v + " targetV=" + targetV);
ok = false;
Expand Down

0 comments on commit 9b08433

Please sign in to comment.