Skip to content

Commit 2b50559

Browse files
committed
Fix sonar findings
1 parent 1e43d25 commit 2b50559

File tree

20 files changed

+43
-40
lines changed

20 files changed

+43
-40
lines changed

api/src/main/java/org/itsallcode/whiterabbit/api/features/MonthDataStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public interface MonthDataStorage extends PluginFeature
5959
/**
6060
* A {@link ModelFactory} allows creating new instances of the data model.
6161
*/
62-
public interface ModelFactory
62+
interface ModelFactory
6363
{
6464
/**
6565
* Create a new {@link MonthData} instance.
@@ -82,4 +82,4 @@ public interface ModelFactory
8282
*/
8383
ActivityData createActivityData();
8484
}
85-
}
85+
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/ActivityData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ public interface ActivityData
6161
* the new comment.
6262
*/
6363
void setComment(String comment);
64-
}
64+
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/DayData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ public interface DayData
130130
* new new activities.
131131
*/
132132
void setActivities(List<ActivityData> activities);
133-
}
133+
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/DayType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public enum DayType
2020

2121
private final boolean workDay;
2222

23-
private DayType(final boolean workDay)
23+
DayType(final boolean workDay)
2424
{
2525
this.workDay = workDay;
2626
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/MonthData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ public interface MonthData
6868
* the new {@link DayData}s.
6969
*/
7070
void setDays(List<DayData> days);
71-
}
71+
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/Project.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ public interface Project
2626
* @return the cost carrier of this project.
2727
*/
2828
String getCostCarrier();
29-
}
29+
}

api/src/main/java/org/itsallcode/whiterabbit/api/model/ProjectReport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public interface ProjectReport
2828
* @return the activities in this project report.
2929
*/
3030
List<ProjectReportActivity> getProjects();
31-
}
31+
}

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/JavaFxUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import javafx.application.Platform;
99

10-
public class JavaFxUtil
10+
public final class JavaFxUtil
1111
{
1212
private JavaFxUtil()
1313
{

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/OsCheck.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ else if (os.indexOf("linux") >= 0)
4949
{
5050
return OSType.LINUX;
5151
}
52-
return OSType.OTHER;
52+
else
53+
{
54+
return OSType.OTHER;
55+
}
5356
}
5457

5558
public boolean isDesktopSupported()

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/UiActions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import javafx.stage.Modality;
3434
import javafx.stage.Stage;
3535

36-
public class UiActions
36+
public final class UiActions
3737
{
3838
private static final Logger LOG = LogManager.getLogger(UiActions.class);
3939

@@ -95,7 +95,7 @@ private void createAndOpenDirectory(final Path directory)
9595
openFileWithDefaultProgram(directory);
9696
}
9797

98-
private void createDir(final Path directory)
98+
private static void createDir(final Path directory)
9999
{
100100
try
101101
{
@@ -195,14 +195,14 @@ private String formatAboutHeaderText()
195195
return "White Rabbit version " + properties.getVersion() + " (" + properties.getBuildDate() + ")";
196196
}
197197

198-
private String formatSystemPropertyValues(final Map<String, String> properties)
198+
private static String formatSystemPropertyValues(final Map<String, String> properties)
199199
{
200200
return properties.entrySet().stream() //
201201
.map(entry -> entry.getKey() + ": " + System.getProperty(entry.getValue())) //
202202
.collect(joining("\n"));
203203
}
204204

205-
private Map<String, String> getProperties()
205+
private static Map<String, String> getProperties()
206206
{
207207
final Map<String, String> properties = new LinkedHashMap<>();
208208
properties.put("Java Vendor", "java.vendor");

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/property/ClockPropertyFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import javafx.beans.property.SimpleObjectProperty;
1616

17-
public class ClockPropertyFactory
17+
public final class ClockPropertyFactory
1818
{
1919
private static final Logger LOG = LogManager.getLogger(ClockPropertyFactory.class);
2020

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/service/DesktopService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
public interface DesktopService
1010
{
11+
1112
static DesktopService create()
1213
{
1314
final Logger log = LogManager.getLogger(DesktopService.class);

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/service/RealDesktopService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class RealDesktopService implements DesktopService
1414
private static final Logger LOG = LogManager.getLogger(RealDesktopService.class);
1515
private final Desktop desktop;
1616

17-
RealDesktopService(Desktop desktop)
17+
RealDesktopService(final Desktop desktop)
1818
{
1919
this.desktop = desktop;
2020
}
2121

2222
@Override
23-
public void open(Path file)
23+
public void open(final Path file)
2424
{
2525
SwingUtil.invokeInAwtEventQueue(() -> {
2626
LOG.info("Opening file {} with default application", file);
@@ -34,4 +34,4 @@ public void open(Path file)
3434
}
3535
});
3636
}
37-
}
37+
}

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/splashscreen/SplashScreenLoader.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public class SplashScreenLoader extends Preloader
2424
{
2525
private static final Logger LOG = LogManager.getLogger(SplashScreenLoader.class);
2626

27-
private Stage splashScreen;
27+
private Stage splashScreen = null;
2828

2929
@Override
30-
public void start(Stage stage)
30+
public void start(final Stage stage)
3131
{
3232
splashScreen = stage;
3333
splashScreen.initStyle(StageStyle.UNDECORATED);
@@ -49,7 +49,7 @@ public Scene createScene()
4949
return new Scene(root, 300, 300);
5050
}
5151

52-
private Image loadImage(String resourceName)
52+
private Image loadImage(final String resourceName)
5353
{
5454
try (InputStream iconStream = getClass().getResourceAsStream(resourceName))
5555
{
@@ -62,11 +62,10 @@ private Image loadImage(String resourceName)
6262
}
6363

6464
@Override
65-
public void handleApplicationNotification(PreloaderNotification notification)
65+
public void handleApplicationNotification(final PreloaderNotification notification)
6666
{
67-
if (notification instanceof ProgressPreloaderNotification)
67+
if (notification instanceof final ProgressPreloaderNotification progressNotification)
6868
{
69-
final ProgressPreloaderNotification progressNotification = (ProgressPreloaderNotification) notification;
7069
LOG.debug("Preloader application notification: {}", progressNotification.getNotificationType());
7170
if (progressNotification.getNotificationType() == Type.STARTUP_FINISHED)
7271
{
@@ -81,23 +80,23 @@ public void handleApplicationNotification(PreloaderNotification notification)
8180
}
8281

8382
@Override
84-
public boolean handleErrorNotification(ErrorNotification info)
83+
public boolean handleErrorNotification(final ErrorNotification info)
8584
{
8685
splashScreen.hide();
8786
final Alert alert = createAlert(info);
8887
alert.showAndWait();
8988
return false;
9089
}
9190

92-
private Alert createAlert(ErrorNotification info)
91+
private static Alert createAlert(final ErrorNotification info)
9392
{
9493
final Throwable exception = info.getCause();
9594
if (exception instanceof OtherInstanceAlreadyRunningException)
9695
{
9796
final String message = "Another instance of WhiteRabbit is already running.\n\n" + exception.getMessage();
9897
return new Alert(AlertType.WARNING, message, ButtonType.OK);
9998
}
100-
final String location = info.getLocation() != null ? info.getLocation() + "\n" : "";
99+
final String location = info.getLocation() != null ? (info.getLocation() + "\n") : "";
101100
final String message = "Error during initialization: " + location + info.getDetails() + "\n" + exception;
102101
LOG.error(message, exception);
103102
return new Alert(AlertType.ERROR, message, ButtonType.OK);

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/systemmenu/DesktopIntegration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public interface DesktopIntegration
66
{
7-
public static DesktopIntegration getInstance()
7+
static DesktopIntegration getInstance()
88
{
99
return StaticInstanceHolder.getInstance();
1010
}
1111

1212
void register();
1313

1414
void setUiActions(UiActions actions);
15-
}
15+
}

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/systemmenu/StaticInstanceHolder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import org.itsallcode.whiterabbit.jfxui.OsCheck;
66

7-
class StaticInstanceHolder
7+
final class StaticInstanceHolder
88
{
99
private static DesktopIntegration instance;
1010

@@ -26,7 +26,7 @@ static class InstanceFactory
2626
{
2727
private final OsCheck osCheck;
2828

29-
InstanceFactory(OsCheck osCheck)
29+
InstanceFactory(final OsCheck osCheck)
3030
{
3131
this.osCheck = osCheck;
3232
}

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/DelegatingChangeListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ public class DelegatingChangeListener<T> implements ChangeListener<T>
99
private final ChangeListener<T> delegate;
1010
private final BooleanProperty currentlyUpdating;
1111

12-
public DelegatingChangeListener(ChangeListener<T> delegate, BooleanProperty currentlyUpdating)
12+
public DelegatingChangeListener(final ChangeListener<T> delegate, final BooleanProperty currentlyUpdating)
1313
{
1414
this.delegate = delegate;
1515
this.currentlyUpdating = currentlyUpdating;
1616
}
1717

1818
@Override
19-
public void changed(ObservableValue<? extends T> observable, T oldValue, T newValue)
19+
public void changed(final ObservableValue<? extends T> observable, final T oldValue, final T newValue)
2020
{
2121
if (!currentlyUpdating.get())
2222
{
2323
delegate.changed(observable, oldValue, newValue);
2424
}
2525
}
26-
}
26+
}

jfxui/src/main/java/org/itsallcode/whiterabbit/jfxui/table/converter/DayTypeStringConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
public class DayTypeStringConverter extends StringConverter<DayType>
88
{
99
@Override
10-
public String toString(DayType object)
10+
public String toString(final DayType object)
1111
{
1212
return object != null ? object.name() : null;
1313
}
1414

1515
@Override
16-
public DayType fromString(String string)
16+
public DayType fromString(final String string)
1717
{
1818
return DayType.valueOf(string);
1919
}
20-
}
20+
}

jfxui/src/uiTest/java/org/itsallcode/whiterabbit/jfxui/DailyProjectReportTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void exportButtonsFromPluginsAvailable()
5050
{
5151
time().tickSeparateMinutes(2);
5252
final DailyProjectReportWindow report = app().openDailyProjectReport();
53-
report.assertExportButtons("Export to demo", "Export to pmsmart");
53+
report.assertExportButtons("Export to demo", "Export to csv");
5454
report.closeViaEscKey();
5555
}
5656

@@ -72,7 +72,7 @@ void filledProjectReport()
7272

7373
@Override
7474
@Start
75-
void start(Stage stage)
75+
void start(final Stage stage)
7676
{
7777
setLocale(Locale.GERMANY);
7878
setInitialTime(Instant.parse("2007-12-03T10:15:30.20Z"));

logic/src/main/java/org/itsallcode/whiterabbit/logic/service/plugin/origin/PluginOrigin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static PluginOrigin forJar(final Path jar)
2828

2929
private static ClassLoader getBaseClassLoader()
3030
{
31-
return PluginOrigin.class.getClassLoader();
31+
return Thread.currentThread().getContextClassLoader();
3232
}
3333

3434
private static ClassLoader createClassLoader(final Path jar)

0 commit comments

Comments
 (0)