Skip to content

Commit 5acb615

Browse files
authored
Merge pull request #110 from Noars/master
Add spotbugs
2 parents cd0f3a3 + 7004d91 commit 5acb615

12 files changed

Lines changed: 93 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Continuous Integration
2+
3+
# Trigger the workflow on push or pull request
4+
on: [push, pull_request]
5+
6+
jobs:
7+
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Set up JDK 11
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 11
18+
19+
- name: Run tests with Gradle
20+
run: |
21+
chmod +x ./gradlew
22+
./gradlew --stacktrace --info spotbugsMain
23+
- name: Upload Artifacts
24+
uses: actions/upload-artifact@v2
25+
if: always()
26+
with:
27+
name: 'Spotbugs Reports'
28+
path: ./build/reports/

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
id 'de.undercouch.download' version '3.2.0'
1515
id 'org.openjfx.javafxplugin' version '0.0.8'
1616
id 'io.freefair.lombok' version '4.1.4'
17+
id 'com.github.spotbugs' version '2.0.0'
1718
}
1819

1920
ext.javafxVersion = "11.0.2"
@@ -34,6 +35,7 @@ apply plugin: 'distribution'
3435
apply plugin: 'maven-publish'
3536
apply plugin: 'maven'
3637
apply plugin: 'jacoco'
38+
apply plugin: 'com.github.spotbugs'
3739
apply plugin: 'distribution'
3840

3941
apply from: "${rootDir}/gradle/package.gradle"
@@ -48,6 +50,14 @@ sourceSets {
4850
}
4951
}
5052

53+
spotbugs {
54+
toolVersion = '4.0.0-beta3'
55+
56+
//ignoreFailures = false
57+
//effort = "max"
58+
//reportLevel = "high"
59+
}
60+
5161
jar {
5262
manifest {
5363
attributes 'Main-Class': 'main.Main'

lombok.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# This file is generated by the 'io.freefair.lombok' Gradle plugin
22
config.stopBubbling = true
33
lombok.addLombokGeneratedAnnotation = true
4+
lombok.extern.findbugs.addSuppressFBWarnings = true

src/main/java/main/ConfigurationBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public static ConfigurationBuilder createFromPropertiesResource() {
4141
if(!Files.exists(path)){
4242
Files.createDirectories(path);
4343
File f = new File(CONFIGPATH);
44-
f.createNewFile();
44+
boolean createFile = f.createNewFile();
45+
log.info("File created, path = " + createFile);
4546
}
4647
properties = loadProperties();
4748
} catch (FileNotFoundException e) {

src/main/java/main/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void start(Stage primaryStage) {
6666
public void handle(KeyEvent t) {
6767
if (t.getCode() == KeyCode.E) {
6868
Platform.exit();
69-
System.exit(0);
7069
}
7170
}
7271
});

src/main/java/main/UI/I18NButton.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public I18NButton(Translator translator, String... textKeys) {
1919
translator.registerLanguageChangeListener(this);
2020
}
2121

22-
public void setTextKeys(String[] value) {
22+
/*public void setTextKeys(String[] value) {
2323
this.textKeys = value;
2424
languageChanged();
25-
}
25+
}*/
2626

2727
@Override
2828
public void languageChanged() {

src/main/java/main/UI/menu/HomeScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public HomeScreen(GraphicalMenus graphicalMenus, UpdateManager updateManager, Ma
6060

6161
this.getChildren().add(UtilsUI.createBackground(graphicalMenus));
6262

63-
String tobiiNotConnected = Arrays.toString(Tobii.gazePosition());
63+
//String tobiiNotConnected = Arrays.toString(Tobii.gazePosition());
6464

6565
centerMenu = new VBox();
6666

src/main/java/main/UI/menu/UpdateMenu.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.io.BufferedReader;
2929
import java.io.IOException;
3030
import java.io.InputStreamReader;
31+
import java.nio.charset.StandardCharsets;
3132

3233
@Slf4j
3334
public class UpdateMenu extends BorderPane {
@@ -482,11 +483,13 @@ void startUpdateOnlyInterAACtionInterface(){
482483
}
483484

484485
void progressPercent(Process p, int index) {
486+
485487
Thread t = new Thread(() -> {
486488
String s;
489+
BufferedReader stdout = null;
487490
try {
488-
BufferedReader stdout = new BufferedReader(
489-
new InputStreamReader(p.getInputStream()));
491+
stdout = new BufferedReader(
492+
new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8));
490493
while ((s = stdout.readLine()) != null) {
491494
int indexPercent = s.indexOf('%');
492495
if (indexPercent != -1) {
@@ -505,6 +508,14 @@ void progressPercent(Process p, int index) {
505508
}
506509
} catch (IOException e) {
507510
//DO NOTHING
511+
} finally {
512+
try {
513+
if (stdout != null){
514+
stdout.close();
515+
}
516+
}catch (IOException e2){
517+
e2.printStackTrace();
518+
}
508519
}
509520
});
510521
t.setDaemon(true);

src/main/java/main/process/CloseGoogleChromeProcessCreator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package main.process;
22

3+
import lombok.extern.slf4j.Slf4j;
4+
35
import java.io.File;
46
import java.io.IOException;
57

8+
@Slf4j
69
public class CloseGoogleChromeProcessCreator {
710

811
ProcessBuilder processBuilder;
@@ -18,10 +21,12 @@ Process waitForCloseRequest() {
1821
File fileFR = new File("~/Téléchargements/close161918.txt");
1922
File fileEN = new File("~/Downloads/close161918.txt");
2023
if(fileFR.exists()) {
21-
fileFR.delete();
24+
boolean deleteFrFile = fileFR.delete();
25+
log.info("File delete = " + deleteFrFile);
2226
}
2327
if(fileEN.exists()) {
24-
fileEN.delete();
28+
boolean deleteEnFile = fileEN.delete();
29+
log.info("File delete = " + deleteEnFile);
2530
}
2631
return this.processBuilder.inheritIO().start();
2732
} catch (IOException e) {

src/main/java/main/process/xdotoolProcess/XdotoolProcessCreator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ static void startWindowIdSearcher(GraphicalMenus graphicalMenus, String name) {
1818
err.printStackTrace();
1919
}
2020
}
21-
file.delete();
21+
boolean deleteFile = file.delete();
22+
System.out.println(deleteFile);
2223
Platform.runLater(
2324
() -> {
2425
graphicalMenus.primaryStage.hide();
@@ -33,7 +34,8 @@ static void startWindowIdSearcher(GraphicalMenus graphicalMenus, String name) {
3334
static Process getStartingProcess(ProcessBuilder processBuilder, GraphicalMenus graphicalMenus, String name) {
3435
try {
3536
File file = new File(name + "_windowId.txt");
36-
file.delete();
37+
boolean deleteFile = file.delete();
38+
System.out.println(deleteFile);
3739
XdotoolProcessCreator.startWindowIdSearcher(graphicalMenus, name);
3840
return processBuilder.inheritIO().start();
3941
} catch (IOException e) {

0 commit comments

Comments
 (0)