Skip to content

Commit 8dbf80f

Browse files
committed
feat: add checkstyle linter and github actions
1 parent 6fb4dee commit 8dbf80f

10 files changed

Lines changed: 66 additions & 16 deletions

File tree

.github/workflows/lint.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
checkstyle:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-java@v4
15+
with:
16+
distribution: temurin
17+
java-version: '21'
18+
19+
- uses: gradle/actions/setup-gradle@v4
20+
21+
- run: chmod +x gradlew
22+
- run: ./gradlew checkstyleMain checkstyleTest

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
# CivilWar
1+
# Civil War
22

33
[![Build](https://github.com/martinnicolas/CivilWar/actions/workflows/build.yml/badge.svg)](https://github.com/martinnicolas/CivilWar/actions/workflows/build.yml)
44

5+
[![Lint](https://github.com/martinnicolas/CivilWar/actions/workflows/lint.yml/badge.svg)](https://github.com/martinnicolas/CivilWar/actions/workflows/lint.yml)
6+
57
3D Game, FPS (First Person Shooter)
68

79
# Requirements
810

9-
+ JMonkeyEngine 3.8.1 Stable
10-
+ JDK 21
11+
+ Java 21
12+
+ [jMonkeyEngine 3.8.1 Stable](https://jmonkeyengine.org/)
13+
+ Gradle
1114

1215
<p align="center">
1316
<img src="https://user-images.githubusercontent.com/5104496/61678559-8c1b7080-acd9-11e9-9828-932e21c7c888.png" alt="CivilWar1" width="350" height="200"/> <img src="https://user-images.githubusercontent.com/5104496/61678611-bc630f00-acd9-11e9-8350-4997ef8ba1d1.png" alt="CivilWar3" width="350" height="200"/>

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java'
33
id 'application'
4+
id 'checkstyle'
45
}
56

67
group 'com.mygame'
@@ -93,3 +94,7 @@ java {
9394
wrapper {
9495
gradleVersion = '8.6'
9596
}
97+
98+
checkstyle {
99+
toolVersion = '10.26.1'
100+
}

config/checkstyle/checkstyle.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE module PUBLIC
2+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
3+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
4+
5+
<module name="Checker">
6+
<property name="charset" value="UTF-8"/>
7+
8+
<module name="TreeWalker">
9+
<module name="UnusedImports"/>
10+
<module name="AvoidStarImport"/>
11+
<module name="NeedBraces"/>
12+
<module name="ConstantName"/>
13+
<module name="ModifierOrder"/>
14+
<module name="EmptyBlock"/>
15+
<module name="FallThrough"/>
16+
<module name="ModifierOrder"/>
17+
<module name="RedundantImport"/>
18+
<module name="WhitespaceAfter"/>
19+
<module name="WhitespaceAround"/>
20+
</module>
21+
</module>

src/main/java/com/mygame/characters/Player.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*
3434
* @author martin
3535
*/
36-
public class Player implements ActionListener{
36+
public class Player implements ActionListener {
3737

3838
private Vector3f walkDirection = Vector3f.ZERO;
3939
private SimpleApplication app;
@@ -87,7 +87,7 @@ private void setUpProperties() {
8787
* Setup player weapon
8888
*/
8989
private void setUpPlayerWeapon() {
90-
AK47Weapon ak47 = new AK47Weapon(this.getApp().getAssetManager(), new Vector3f(-1f,-1.1f, 2f));
90+
AK47Weapon ak47 = new AK47Weapon(this.getApp().getAssetManager(), new Vector3f(-1f, -1.1f, 2f));
9191
ak47.getSpatial().setLocalRotation(new Quaternion(0f, -1f, 0f, 1f));
9292
//Create camera node for weapon spatial
9393
CameraNode cameraNode = new CameraNode("camera_node", this.getApp().getCamera());

src/main/java/com/mygame/controls/TerrainTrackControl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
*/
2121
public class TerrainTrackControl extends AbstractControl {
2222

23-
private final Ray ray = new Ray(Vector3f.ZERO.clone(), new Vector3f(0,-1,0));
24-
private final Vector3f up = new Vector3f(0, 50 , 0);
23+
private final Ray ray = new Ray(Vector3f.ZERO.clone(), new Vector3f(0, -1, 0));
24+
private final Vector3f up = new Vector3f(0, 50, 0);
2525
private final CollisionResults results = new CollisionResults();
2626
private final float offset = 0.1745207f;
2727
private Spatial terrain;
@@ -40,16 +40,16 @@ protected void controlUpdate(float tpf) {
4040
terrain.collideWith(ray, results);
4141
for (CollisionResult collisionResult : results) {
4242
if (isTerrain(collisionResult.getGeometry())) {
43-
Vector3f loc = collisionResult.getContactPoint();
44-
spatial.setLocalTranslation(spatial.getLocalTranslation().setY(loc.getY() - offset));
43+
Vector3f location = collisionResult.getContactPoint();
44+
spatial.setLocalTranslation(spatial.getLocalTranslation().setY(location.getY() - offset));
4545
return;
4646
}
4747
}
4848
}
4949
}
5050

5151
private boolean isTerrain(Spatial spat) {
52-
while(true) {
52+
while (true) {
5353
if (spat == null) {
5454
return false;
5555
} else if (spat.getName().contains("terrain")) {

src/main/java/com/mygame/levels/Level.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ public void removeSettings() {
231231
this.getAudioNode().removeFromParent();
232232
}
233233
ViewPort viewPort = this.getApp().getViewPort();
234-
for(SceneProcessor processor: viewPort.getProcessors()){
235-
if(processor instanceof FilterPostProcessor filterPostProcessor){
234+
for (SceneProcessor processor: viewPort.getProcessors()) {
235+
if (processor instanceof FilterPostProcessor filterPostProcessor) {
236236
filterPostProcessor.removeAllFilters();
237237
}
238238
viewPort.removeProcessor(processor);

src/main/java/com/mygame/levels/Level1.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import com.mygame.bonuses.AmmoBonus;
3636
import com.mygame.bonuses.HealthBonus;
3737
import com.mygame.characters.Player;
38-
import com.mygame.controls.PlayerHUDControl;
3938

4039
/**
4140
*
@@ -376,7 +375,7 @@ private void pickBonus(Spatial bonusSpatial) {
376375
if (bonusSpatial == null) { return; }
377376

378377
RigidBodyControl spatialControl = bonusSpatial.getControl(RigidBodyControl.class);
379-
if(spatialControl != null && spatialControl.isEnabled()) {
378+
if (spatialControl != null && spatialControl.isEnabled()) {
380379
this.getPlayer().plusPickedBonus(bonusSpatial);
381380
spatialControl.setEnabled(false);
382381
this.getBulletAppState().getPhysicsSpace().remove(spatialControl);

src/main/java/com/mygame/screens/PauseScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author martin
2222
*/
23-
public class PauseScreen extends AbstractScreen implements ScreenController{
23+
public class PauseScreen extends AbstractScreen implements ScreenController {
2424

2525
private Level level;
2626
private Element popUpExit;

src/main/java/com/mygame/screens/StartScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class StartScreen extends AbstractScreen implements ScreenController {
2626
@Override
2727
public void initialize(AppStateManager stateManager, Application app) {
2828
super.initialize(stateManager, app); //To change body of generated methods, choose Tools | Templates.
29-
this.setApp((Main)app);
29+
this.setApp((Main) app);
3030
this.setAudioNode(new AudioNode(this.getApp().getAssetManager(), "Sounds/Music/ambientmain_0.ogg", AudioData.DataType.Stream));
3131
this.getAudioNode().setName("audio_start_screen");
3232
this.getAudioNode().setLooping(true); // activate continuous playing

0 commit comments

Comments
 (0)