Skip to content

Commit c4df216

Browse files
Fix Spotbugs warnings: Add final modifier to constant fields (#4317)
* Fix Spotbugs warnings: Add final modifier to constant fields This commit resolves multiple "Field isn't final but should be" warnings identified by Spotbugs. The `final` modifier has been added to the following fields: - `ColorUtil`: `LTGRAY`, `BLUE`, `BLACK`, `WHITE`, `CYAN`, `GREEN`, `YELLOW`, `MAGENTA`, `GRAY` - `Cookie`: `STORAGE_NAME` - `Log`: `REPORTING_NONE`, `REPORTING_DEBUG`, `REPORTING_PRODUCTION` - `JavascriptContext`: `jsLookupTable` - `LocationRequest`: `PRIORITY_HIGH_ACCUARCY`, `PRIORITY_MEDIUM_ACCUARCY`, `PRIORITY_LOW_ACCUARCY` - `DocumentInfo`: `TYPE_HTML`, `TYPE_IMAGE`, `TYPE_CSS` - `PlatformDefaults`: `VISUAL_PADDING_PROPERTY` These fields are intended to be constants (or effectively final in the case of `jsLookupTable`) and enforcing immutability improves thread safety and code clarity. Existing typos in `LocationRequest` field names are preserved for backward compatibility. * Fix Spotbugs warnings: Add final modifier to constant fields This commit resolves multiple "Field isn't final but should be" warnings identified by Spotbugs. The `final` modifier has been added to the following fields: - `ColorUtil`: `LTGRAY`, `BLUE`, `BLACK`, `WHITE`, `CYAN`, `GREEN`, `YELLOW`, `MAGENTA`, `GRAY` - `Cookie`: `STORAGE_NAME` - `Log`: `REPORTING_NONE`, `REPORTING_DEBUG`, `REPORTING_PRODUCTION` - `JavascriptContext`: `DEBUG` - `LocationRequest`: `PRIORITY_HIGH_ACCUARCY`, `PRIORITY_MEDIUM_ACCUARCY`, `PRIORITY_LOW_ACCUARCY` - `DocumentInfo`: `TYPE_HTML`, `TYPE_IMAGE`, `TYPE_CSS` - `PlatformDefaults`: `VISUAL_PADDING_PROPERTY` These fields are intended to be constants (or effectively final in the case of `DEBUG`) and enforcing immutability improves thread safety and code clarity. Existing typos in `LocationRequest` field names are preserved for backward compatibility. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent bfddc08 commit c4df216

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

CodenameOne/src/com/codename1/charts/util/ColorUtil.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
* @author shannah
2828
*/
2929
public class ColorUtil {
30-
public static int LTGRAY = IColor.LightGray.argb;
31-
public static int BLUE = IColor.Blue.argb;
32-
public static int BLACK = IColor.Black.argb;
33-
public static int WHITE = IColor.White.argb;
34-
public static int CYAN = IColor.Cyan.argb;
35-
public static int GREEN = IColor.Green.argb;
36-
public static int YELLOW = IColor.Yellow.argb;
37-
public static int MAGENTA = IColor.Magenta.argb;
38-
public static int GRAY = IColor.Gray.argb;
30+
public static final int LTGRAY = IColor.LightGray.argb;
31+
public static final int BLUE = IColor.Blue.argb;
32+
public static final int BLACK = IColor.Black.argb;
33+
public static final int WHITE = IColor.White.argb;
34+
public static final int CYAN = IColor.Cyan.argb;
35+
public static final int GREEN = IColor.Green.argb;
36+
public static final int YELLOW = IColor.Yellow.argb;
37+
public static final int MAGENTA = IColor.Magenta.argb;
38+
public static final int GRAY = IColor.Gray.argb;
3939

4040

4141
public static int argb(int a, int r, int g, int b) {

CodenameOne/src/com/codename1/io/Cookie.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* @author Shai Almog
3535
*/
3636
public class Cookie implements Externalizable {
37-
public static String STORAGE_NAME = "Cookies";
37+
public static final String STORAGE_NAME = "Cookies";
3838
private static boolean autoStored = true;
3939

4040
static {

CodenameOne/src/com/codename1/io/Log.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ public class Log {
7676
/**
7777
* Indicates that log reporting to the cloud should be disabled
7878
*/
79-
public static int REPORTING_NONE = 0;
79+
public static final int REPORTING_NONE = 0;
8080
/**
8181
* Indicates that log reporting to the cloud should occur regardless of whether an error occurred
8282
*/
83-
public static int REPORTING_DEBUG = 1;
83+
public static final int REPORTING_DEBUG = 1;
8484
/**
8585
* Indicates that log reporting to the cloud should occur only if an error occurred
8686
*/
87-
public static int REPORTING_PRODUCTION = 3;
87+
public static final int REPORTING_PRODUCTION = 3;
8888
private static boolean crashBound;
8989
private static Log instance = new Log();
9090
private static boolean initialized;

CodenameOne/src/com/codename1/javascript/JavascriptContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class JavascriptContext {
8686
/**
8787
* Flag to enable/disable logging to a debug log.
8888
*/
89-
public static boolean DEBUG = false;
89+
public static final boolean DEBUG = false;
9090
/**
9191
* Running counter to mark the context ID. Each javascript context has its
9292
* own lookup table, and this running counter allows us to generate a unique

CodenameOne/src/com/codename1/location/LocationRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ public class LocationRequest {
3333
/**
3434
* When you need gps location updates
3535
*/
36-
public static int PRIORITY_HIGH_ACCUARCY = 0;
36+
public static final int PRIORITY_HIGH_ACCUARCY = 0;
3737

3838
/**
3939
* When accuracy is not highly important and you want to save battery
4040
*/
41-
public static int PRIORITY_MEDIUM_ACCUARCY = 1;
41+
public static final int PRIORITY_MEDIUM_ACCUARCY = 1;
4242

4343
/**
4444
* When accuracy is not important and you want to save battery
4545
*/
46-
public static int PRIORITY_LOW_ACCUARCY = 2;
46+
public static final int PRIORITY_LOW_ACCUARCY = 2;
4747

4848
private int priority = PRIORITY_MEDIUM_ACCUARCY;
4949

CodenameOne/src/com/codename1/ui/html/DocumentInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ public class DocumentInfo {
4545
/**
4646
* Indicates that the request is for a page
4747
*/
48-
public static int TYPE_HTML = 0;
48+
public static final int TYPE_HTML = 0;
4949

5050
/**
5151
* Indicates that the request is for an image
5252
*/
53-
public static int TYPE_IMAGE = 1;
53+
public static final int TYPE_IMAGE = 1;
5454

5555
/**
5656
* Indicates that the request is for a CSS file
5757
*/
58-
public static int TYPE_CSS = 2;
58+
public static final int TYPE_CSS = 2;
5959

6060
private static String DEFAULT_ENCODING = ENCODING_ISO;
6161

CodenameOne/src/com/codename1/ui/layouts/mig/PlatformDefaults.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public final class PlatformDefaults {
118118
* to specify the visual padding.
119119
* <p>
120120
*/
121-
public static String VISUAL_PADDING_PROPERTY = "visualPadding";
121+
public static final String VISUAL_PADDING_PROPERTY = "visualPadding";
122122
static BoundSize RELATED_X = null, RELATED_Y = null, UNRELATED_X = null, UNRELATED_Y = null;
123123
private static int DEF_H_UNIT = UnitValue.LPX;
124124
private static int DEF_V_UNIT = UnitValue.LPY;

0 commit comments

Comments
 (0)