summaryrefslogtreecommitdiffstats
path: root/javatoscachecker
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-03-21 15:01:07 +0900
committerParshad Patel <pars.patel@samsung.com>2019-03-21 15:01:13 +0900
commitaf877fe9df8af4abb0745b095fd134cbab8de29d (patch)
tree20cd80481368fc5850329f1d5e327ff947c40b5d /javatoscachecker
parentf225d6178ab9aab47d33388e8e14f6a6fa7b9049 (diff)
Fix sonar issues in modeling/toscaparsers
Fix Make "_value" transient or serializable issue Fix Extract the assignment out of this expression issue Issue-ID: MODELING-154 Change-Id: If6df4bcfcc250179078d7537010a8fb9d8376958 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'javatoscachecker')
-rw-r--r--javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java4
-rw-r--r--javatoscachecker/kwalify/src/main/java/kwalify/DefaultableHashMap.java2
-rw-r--r--javatoscachecker/kwalify/src/main/java/kwalify/PlainYamlParser.java79
3 files changed, 51 insertions, 34 deletions
diff --git a/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java b/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
index 4f959a3..cc40f58 100644
--- a/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
+++ b/javatoscachecker/kwalify/src/main/java/kwalify/BaseException.java
@@ -53,8 +53,8 @@ package kwalify;
public abstract class BaseException extends KwalifyRuntimeException implements Comparable {
String _ypath;
- Object _value;
- Rule _rule;
+ transient Object _value;
+ transient Rule _rule;
String _errorSymbol;
int _linenum = -1;
diff --git a/javatoscachecker/kwalify/src/main/java/kwalify/DefaultableHashMap.java b/javatoscachecker/kwalify/src/main/java/kwalify/DefaultableHashMap.java
index 6bc4f42..43a2268 100644
--- a/javatoscachecker/kwalify/src/main/java/kwalify/DefaultableHashMap.java
+++ b/javatoscachecker/kwalify/src/main/java/kwalify/DefaultableHashMap.java
@@ -57,7 +57,7 @@ public class DefaultableHashMap extends HashMap implements Defaultable {
private static final long serialVersionUID = -5224819562023897380L;
- private Object _default = null;
+ private transient Object _default = null;
public DefaultableHashMap() {
super();
diff --git a/javatoscachecker/kwalify/src/main/java/kwalify/PlainYamlParser.java b/javatoscachecker/kwalify/src/main/java/kwalify/PlainYamlParser.java
index e982bf1..f23146b 100644
--- a/javatoscachecker/kwalify/src/main/java/kwalify/PlainYamlParser.java
+++ b/javatoscachecker/kwalify/src/main/java/kwalify/PlainYamlParser.java
@@ -848,49 +848,66 @@ public class PlainYamlParser implements Parser {
private Object toScalar(String value) {
Matcher m;
- if ((m = Util.matcher(value, "^\"(.*)\"([ \t]*#.*$)?")).find()) {
+ m = Util.matcher(value, "^\"(.*)\"([ \t]*#.*$)?");
+ if(m.find()) {
return m.group(1);
- } else if ((m = Util.matcher(value, "^'(.*)'([ \t]*#.*$)?")).find()) {
+ }
+
+ m = Util.matcher(value, "^'(.*)'([ \t]*#.*$)?");
+ if (m.find()) {
return m.group(1);
- } else if ((m = Util.matcher(value, "^(.*\\S)[ \t]*#")).find()) {
+ }
+
+ m = Util.matcher(value, "^(.*\\S)[ \t]*#");
+ if (m.find()) {
value = m.group(1);
}
- //
- if (Util.matches(value, "^-?0x\\d+$")) return new Integer(Integer.parseInt(value, 16));
- else if (Util.matches(value, "^-?0\\d+$")) return new Integer(Integer.parseInt(value, 8));
- else if (Util.matches(value, "^-?\\d+$")) return new Integer(Integer.parseInt(value, 10));
- else if (Util.matches(value, "^-?\\d+\\.\\d+$")) return new Double(Double.parseDouble(value));
- else if (Util.matches(value, "^(true|yes|on)$")) return Boolean.TRUE;
- else if (Util.matches(value, "^(false|no|off)$")) return Boolean.FALSE;
- else if (Util.matches(value, "^(null|~)$")) return null;
- else if (Util.matches(value, "^:(\\w+)$")) return value;
- else if ((m = Util.matcher(value, "^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$")).find()) {
- int year = Integer.parseInt(m.group(1));
+
+ if (Util.matches(value, "^-?0x\\d+$"))
+ return Integer.valueOf(value, 16);
+ else if (Util.matches(value, "^-?0\\d+$"))
+ return Integer.valueOf(value, 8);
+ else if (Util.matches(value, "^-?\\d+$"))
+ return Integer.valueOf(value, 10);
+ else if (Util.matches(value, "^-?\\d+\\.\\d+$"))
+ return Double.valueOf(value);
+ else if (Util.matches(value, "^(true|yes|on)$"))
+ return Boolean.TRUE;
+ else if (Util.matches(value, "^(false|no|off)$"))
+ return Boolean.FALSE;
+ else if (Util.matches(value, "^(null|~)$"))
+ return null;
+ else if (Util.matches(value, "^:(\\w+)$"))
+ return value;
+
+ m = Util.matcher(value, "^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$");
+ if (m.find()) {
+ int year = Integer.parseInt(m.group(1));
int month = Integer.parseInt(m.group(2));
- int day = Integer.parseInt(m.group(3));
+ int day = Integer.parseInt(m.group(3));
Calendar cal = Calendar.getInstance();
cal.set(year, month, day, 0, 0, 0);
- Date date = cal.getTime();
- return date;
- } else if ((m = Util.matcher(value, "^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)(?:[Tt]|[ \t]+)(\\d\\d?):(\\d\\d):(\\d\\d)(\\.\\d*)?(?:Z|[ \t]*([-+]\\d\\d?)(?::(\\d\\d))?)?$")).find()) {
- int year = Integer.parseInt(m.group(1));
- int month = Integer.parseInt(m.group(2));
- int day = Integer.parseInt(m.group(3));
- int hour = Integer.parseInt(m.group(4));
- int min = Integer.parseInt(m.group(5));
- int sec = Integer.parseInt(m.group(6));
- //int usec = Integer.parseInt(m.group(7));
- //int tzone_h = Integer.parseInt(m.group(8));
- //int tzone_m = Integer.parseInt(m.group(9));
+ return cal.getTime();
+ }
+
+ m = Util.matcher(value, "^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)(?:[Tt]|[ \t]+)(\\d\\d?):(\\d\\d):(\\d\\d)(\\.\\d*)?(?:Z|[ \t]*([-+]\\d\\d?)(?::(\\d\\d))?)?$");
+ if (m.find()) {
+ int year = Integer.parseInt(m.group(1));
+ int month = Integer.parseInt(m.group(2));
+ int day = Integer.parseInt(m.group(3));
+ int hour = Integer.parseInt(m.group(4));
+ int min = Integer.parseInt(m.group(5));
+ int sec = Integer.parseInt(m.group(6));
+ // int usec = Integer.parseInt(m.group(7));
+ // int tzone_h = Integer.parseInt(m.group(8));
+ // int tzone_m = Integer.parseInt(m.group(9));
String timezone = "GMT" + m.group(8) + ":" + m.group(9);
Calendar cal = Calendar.getInstance();
cal.set(year, month, day, hour, min, sec);
cal.setTimeZone(TimeZone.getTimeZone(timezone));
- Date date = cal.getTime();
- return date;
- } else {
- return value;
+ return cal.getTime();
}
+ return value;
}
/*