Skip to content

Commit 89a96b0

Browse files
authored
Add support for checking code formatting (#16)
* Add spotless plugin * Apply spotless to files
1 parent 3bc2158 commit 89a96b0

10 files changed

Lines changed: 64 additions & 18 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ Specify optionally `-times <n>` to run the input sequence multiple times.
9797
- `py/**` is based on work done in [apferscher/ble-learning](https://github.com/apferscher/ble-learning) and [Matheus-Garbelini/sweyntooth_bluetooth_low_energy_attacks](https://github.com/Matheus-Garbelini/sweyntooth_bluetooth_low_energy_attacks)
9898
- `experiments/targets/nRF52840` is based on an example in [NordicDeveloperAcademy/bt-fund](https://github.com/NordicDeveloperAcademy/bt-fund/tree/main/l5/l5_e1)
9999
- `experiments/targets/RPiPico2W` is based on an example in [raspberrypi/pico-examples](https://github.com/raspberrypi/pico-examples/tree/master/pico_w/bt/standalone)
100-
- `scripts/diff_hyps.sh` is copied from [protocol-fuzzing/edhoc-fuzzer](https://github.com/protocol-fuzzing/edhoc-fuzzer/blob/main/scripts/diff_hyps.sh)
100+
- `scripts/diff_hyps.sh` is copied from [protocol-fuzzing/edhoc-fuzzer](https://github.com/protocol-fuzzing/edhoc-fuzzer/blob/main/scripts/diff_hyps.sh)

pom.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,54 @@
5454
</pluginManagement>
5555

5656
<plugins>
57+
<!-- Format the source code -->
58+
<plugin>
59+
<groupId>com.diffplug.spotless</groupId>
60+
<artifactId>spotless-maven-plugin</artifactId>
61+
<version>3.4.0</version>
62+
<configuration>
63+
<formats>
64+
<format>
65+
<includes>
66+
<include>**/*.md</include>
67+
<!--<include>**/*.xml</include>-->
68+
</includes>
69+
<excludes>
70+
<exclude>experiments/**</exclude>
71+
<exclude>target/**</exclude>
72+
</excludes>
73+
<endWithNewline />
74+
<trimTrailingWhitespace />
75+
<indent>
76+
<spaces>true</spaces>
77+
<spacesPerTab>4</spacesPerTab>
78+
</indent>
79+
</format>
80+
</formats>
81+
<java>
82+
<importOrder>
83+
<!-- the empty string is for all imports not specified explicitly, '|' joins groups without blank line -->
84+
<order>,javax|java</order>
85+
</importOrder>
86+
<removeUnusedImports />
87+
<formatAnnotations />
88+
<endWithNewline />
89+
<trimTrailingWhitespace />
90+
<indent>
91+
<spaces>true</spaces>
92+
<spacesPerTab>4</spacesPerTab>
93+
</indent>
94+
</java>
95+
</configuration>
96+
<executions>
97+
<execution>
98+
<goals>
99+
<goal>check</goal>
100+
</goals>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
57105
<plugin>
58106
<groupId>org.apache.maven.plugins</groupId>
59107
<artifactId>maven-shade-plugin</artifactId>

src/main/java/com/github/protocolfuzzing/blefuzzer/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public static void main(String[] args) {
1818

1919
commandLineParser.parse(args, true);
2020
}
21-
}
21+
}

src/main/java/com/github/protocolfuzzing/blefuzzer/MapperBLE.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.protocolfuzzing.blefuzzer;
22

33
import com.github.protocolfuzzing.blefuzzer.symbols.InputBLE;
4+
import com.github.protocolfuzzing.blefuzzer.symbols.OutputBLE;
45
import com.github.protocolfuzzing.blefuzzer.symbols.OutputBuilderBLE;
56
import com.github.protocolfuzzing.blefuzzer.symbols.OutputCheckerBLE;
6-
import com.github.protocolfuzzing.blefuzzer.symbols.OutputBLE;
77
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.mapper.Mapper;
88
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.mapper.abstractsymbols.OutputBuilder;
99
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.mapper.abstractsymbols.OutputChecker;
@@ -32,5 +32,5 @@ public OutputBuilder<OutputBLE> getOutputBuilder() {
3232
public OutputChecker<OutputBLE> getOutputChecker() {
3333
return outputChecker;
3434
}
35-
35+
3636
}

src/main/java/com/github/protocolfuzzing/blefuzzer/MultiBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ public TestRunner build(TestRunnerEnabler testRunnerEnabler) {
7676
public TimingProbe build(TimingProbeEnabler timingProbeEnabler) {
7777
return new TimingProbeStandard<InputBLE, OutputBLE, Object, ExecutionContextBLE>(timingProbeEnabler, alphabetBuilder, sulBuilder, sulWrapper).initialize();
7878
}
79-
}
79+
}

src/main/java/com/github/protocolfuzzing/blefuzzer/SulBLE.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.protocolfuzzing.blefuzzer;
22

3-
import org.apache.logging.log4j.LogManager;
4-
import org.apache.logging.log4j.Logger;
5-
63
import com.github.protocolfuzzing.blefuzzer.symbols.InputBLE;
74
import com.github.protocolfuzzing.blefuzzer.symbols.OutputBLE;
85
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.core.AbstractSul;
@@ -11,8 +8,9 @@
118
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.core.sulwrappers.DynamicPortProvider;
129
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.mapper.Mapper;
1310
import com.github.protocolfuzzing.protocolstatefuzzer.utils.CleanupTasks;
14-
1511
import jep.SharedInterpreter;
12+
import org.apache.logging.log4j.LogManager;
13+
import org.apache.logging.log4j.Logger;
1614

1715
public class SulBLE implements AbstractSul<InputBLE, OutputBLE, ExecutionContextBLE> {
1816
private static final Logger LOGGER = LogManager.getLogger();
@@ -32,7 +30,7 @@ public SulBLE(SulConfig sulConfig, CleanupTasks cleanupTasks) {
3230
if(config.getMapper() != null) {
3331
mapper += "_" + config.getMapper();
3432
}
35-
33+
3634
// Set up the python interpreter for our mapper
3735
interp = new SharedInterpreter();
3836
interp.exec("import sys; sys.path.insert(0, 'py')");

src/main/java/com/github/protocolfuzzing/blefuzzer/SulServerConfigBLE.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.github.protocolfuzzing.blefuzzer;
22

3-
import java.io.PrintWriter;
4-
53
import com.beust.jcommander.Parameter;
64
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.core.config.SulServerConfig;
75

6+
import java.io.PrintWriter;
7+
88
public class SulServerConfigBLE implements SulServerConfig {
9-
9+
1010
@Parameter(names = "-adapter", required = true,
1111
description = "The serial port of the test adapter")
1212
protected String serialPort = null;
@@ -31,7 +31,7 @@ public String getMapper() {
3131
public String getTargetMacAddr() {
3232
return targetMacAddr;
3333
}
34-
34+
3535

3636
@Override
3737
public String getHost() {

src/main/java/com/github/protocolfuzzing/blefuzzer/symbols/AlphabetPojoXmlBLE.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ public static class InputPojoXmlBLE {
3333
@XmlAttribute(name = "name", required = true)
3434
private String name;
3535
}
36-
}
36+
}

src/main/java/com/github/protocolfuzzing/blefuzzer/symbols/InputBLE.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ public void postReceiveUpdate(OutputBLE output, OutputChecker<OutputBLE> outputC
2727
public Object generateProtocolMessage(ExecutionContextBLE context) {
2828
throw new UnsupportedOperationException("Unimplemented method 'generateProtocolMessage'");
2929
}
30-
30+
3131
}

src/main/java/com/github/protocolfuzzing/blefuzzer/symbols/OutputBLE.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.protocolfuzzing.blefuzzer.symbols;
22

3-
import java.util.Collections;
4-
53
import com.github.protocolfuzzing.protocolstatefuzzer.components.sul.mapper.abstractsymbols.AbstractOutput;
64

5+
import java.util.Collections;
6+
77
public class OutputBLE extends AbstractOutput<OutputBLE, Object> {
88
public OutputBLE(String name) {
99
super(name);

0 commit comments

Comments
 (0)