Skip to content

Commit 45612b9

Browse files
committed
Handle sonar problems
1 parent e59239b commit 45612b9

File tree

6 files changed

+21
-25
lines changed

6 files changed

+21
-25
lines changed

src/main/java/software/xdev/saveactions/core/service/SaveActionsServiceManager.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,32 @@
1515
*/
1616
public final class SaveActionsServiceManager
1717
{
18-
private SaveActionsServiceManager()
19-
{
20-
}
18+
static SaveActionsService instance;
2119

2220
public static SaveActionsService getService()
2321
{
24-
return ServiceHandler.INSTANCE.getService();
22+
if(instance == null)
23+
{
24+
initService();
25+
}
26+
return instance;
2527
}
2628

27-
private enum ServiceHandler
29+
private static synchronized void initService()
2830
{
29-
INSTANCE;
30-
31-
private static SaveActionsService service;
32-
33-
public SaveActionsService getService()
31+
if(instance != null)
3432
{
35-
if(service == null)
36-
{
37-
this.newService();
38-
}
39-
return service;
33+
return;
4034
}
4135

42-
private void newService()
36+
instance = ApplicationManager.getApplication().getService(SaveActionsJavaService.class);
37+
if(instance == null)
4338
{
44-
service = ApplicationManager.getApplication().getService(SaveActionsJavaService.class);
45-
if(service == null)
46-
{
47-
service = ApplicationManager.getApplication().getService(SaveActionsDefaultService.class);
48-
}
39+
instance = ApplicationManager.getApplication().getService(SaveActionsDefaultService.class);
4940
}
5041
}
42+
43+
private SaveActionsServiceManager()
44+
{
45+
}
5146
}

src/main/java/software/xdev/saveactions/model/Action.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import java.util.stream.Stream;
1212

1313

14+
@SuppressWarnings("java:S115")
1415
public enum Action
1516
{
1617
// Activation
17-
1818
activate("Activate save actions on save (before saving each file, performs the configured actions below)",
1919
activation, true),
2020

@@ -28,7 +28,6 @@ public enum Action
2828
activation, false),
2929

3030
// Global
31-
3231
organizeImports("Optimize imports",
3332
global, true),
3433

@@ -43,7 +42,6 @@ public enum Action
4342
global, false),
4443

4544
// Build
46-
4745
compile("[experimental] Compile files (using \"Build > Build Project\")",
4846
build, false),
4947

@@ -55,7 +53,6 @@ public enum Action
5553
build, false),
5654

5755
// Java fixes
58-
5956
fieldCanBeFinal("Add final modifier to field",
6057
java, false),
6158

src/main/java/software/xdev/saveactions/model/java/EpfKey.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.stream.Stream;
77

88

9+
@SuppressWarnings("java:S115")
910
public enum EpfKey
1011
{
1112
add_default_serial_version_id,

src/main/java/software/xdev/saveactions/processors/BuildProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
/**
3535
* Available processors for build.
3636
*/
37+
@SuppressWarnings("java:S115")
3738
public enum BuildProcessor implements Processor
3839
{
3940
compile(

src/main/java/software/xdev/saveactions/processors/GlobalProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
/**
2424
* Available processors for global.
2525
*/
26+
@SuppressWarnings("java:S115")
2627
public enum GlobalProcessor implements Processor
2728
{
2829
organizeImports(Action.organizeImports, GlobalProcessor::optimizeImports),

src/main/java/software/xdev/saveactions/processors/java/JavaProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
/**
4040
* Available processors for java.
4141
*/
42+
@SuppressWarnings("java:S115")
4243
public enum JavaProcessor implements Processor
4344
{
4445
fieldCanBeFinal(

0 commit comments

Comments
 (0)