Skip to content

Commit 85e0970

Browse files
committed
resolved some critical sonar issues
made a constant for "rgba(" -> RGBA made a constant for "Arial" -> ARIAL made a constant for "00:00:00" -> TIME_ZERO
1 parent 6b9be3f commit 85e0970

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/main/java/de/doubleslash/keeptime/view/ViewController.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ public class ViewController {
119119
private Canvas canvas;
120120

121121
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
122+
final private String RGBA = "rgba(";
123+
final private String ARIAL = "Arial";
124+
final private String TIME_ZERO = "00:00:00";
122125

123126
boolean pressed = false;
124127
double startX = -1;
@@ -168,10 +171,10 @@ public void changeProject(final Project newProject, final long minusSeconds) {
168171
@FXML
169172
private void initialize() throws IOException {
170173

171-
bigTimeLabel.setText("00:00:00");
174+
bigTimeLabel.setText(TIME_ZERO);
172175
bigTimeLabel.setFont(new Font("Arial", 60));
173-
allTimeLabel.setText("00:00:00");
174-
todayAllSeconds.setText("00:00:00");
176+
allTimeLabel.setText(TIME_ZERO);
177+
todayAllSeconds.setText(TIME_ZERO);
175178

176179
textArea.setWrapText(true);
177180
textArea.setEditable(false);
@@ -291,9 +294,9 @@ private void initialize() throws IOException {
291294
opacity = .3;
292295
}
293296
String style = changeStyleAttribute(pane.getStyle(), "fx-background-color",
294-
"rgba(" + ColorHelper.colorToCssRgba(color) + ")");
297+
RGBA + ColorHelper.colorToCssRgba(color) + ")");
295298
style = changeStyleAttribute(style, "fx-border-color",
296-
"rgba(" + ColorHelper.colorToCssRgb(color) + ", " + opacity + ")");
299+
RGBA + ColorHelper.colorToCssRgb(color) + ", " + opacity + ")");
297300
pane.setStyle(style);
298301
};
299302

@@ -335,7 +338,7 @@ private void initialize() throws IOException {
335338
// Setup textarea font color binding
336339
final Runnable textAreaColorRunnable = () -> {
337340
final String textAreaStyle = changeStyleAttribute(textArea.getStyle(), "fx-text-fill",
338-
"rgba(" + ColorHelper.colorToCssRgba(fontColorProperty.get()) + ")");
341+
RGBA + ColorHelper.colorToCssRgba(fontColorProperty.get()) + ")");
339342
textArea.setStyle(textAreaStyle);
340343
};
341344
fontColorProperty.addListener((a, b, c) -> {
@@ -597,17 +600,17 @@ private Node addProjectToProjectList(final Project p) {
597600
gridRow++;
598601
grid.add(new Label("Active project duration: " + model.activeWorkItem.get().getProject().getName()), 0,
599602
gridRow);
600-
final Label currentProjectTimeLabel = new Label("00:00:00");
603+
final Label currentProjectTimeLabel = new Label(TIME_ZERO);
601604
grid.add(currentProjectTimeLabel, 1, gridRow);
602605
gridRow++;
603606

604607
grid.add(new Label("New end and start time:"), 0, gridRow);
605-
final Label newEndTimeLabel = new Label("00:00:00");
608+
final Label newEndTimeLabel = new Label(TIME_ZERO);
606609
grid.add(newEndTimeLabel, 1, gridRow);
607610
gridRow++;
608611

609612
grid.add(new Label("New project duration: " + p.getName()), 0, gridRow);
610-
final Label newProjectTimeLabel = new Label("00:00:00");
613+
final Label newProjectTimeLabel = new Label(TIME_ZERO);
611614
grid.add(newProjectTimeLabel, 1, gridRow);
612615
gridRow++;
613616

@@ -778,7 +781,7 @@ private void updateTaskbarIcon(final long currentWorkSeconds) {
778781

779782
gcIcon.setStroke(model.taskBarColor.get());
780783
gcIcon.setTextAlign(TextAlignment.CENTER);
781-
gcIcon.setFont(new Font("Arial", 12));
784+
gcIcon.setFont(new Font(ARIAL, 12));
782785
gcIcon.strokeText(DateFormatter.secondsToHHMMSS(currentWorkSeconds).replaceFirst(":", ":\n"),
783786
Math.round(taskbarCanvas.getWidth() / 2), Math.round(taskbarCanvas.getHeight() / 2) - 5);
784787

0 commit comments

Comments
 (0)